From bf795ab7a51f2bee3f2055a5152ba2a32e928a41 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 22 Feb 2015 18:04:42 -0500 Subject: [PATCH] Fix removal of apps in app list updates --- app/src/main/java/com/limelight/AppView.java | 21 +++++++++++++++++++ .../com/limelight/grid/AppGridAdapter.java | 4 ++++ 2 files changed, 25 insertions(+) diff --git a/app/src/main/java/com/limelight/AppView.java b/app/src/main/java/com/limelight/AppView.java index ea838010..f160181c 100644 --- a/app/src/main/java/com/limelight/AppView.java +++ b/app/src/main/java/com/limelight/AppView.java @@ -366,6 +366,7 @@ public class AppView extends Activity implements AdapterFragmentCallbacks { public void run() { boolean updated = false; + // First handle app updates and additions for (NvApp app : appList) { boolean foundExistingApp = false; @@ -395,6 +396,26 @@ public class AppView extends Activity implements AdapterFragmentCallbacks { } } + // Next handle app removals + for (int i = 0; i < appGridAdapter.getCount(); i++) { + boolean foundExistingApp = false; + AppObject existingApp = (AppObject) appGridAdapter.getItem(i); + + // Check if this app is in the latest list + for (NvApp app : appList) { + if (existingApp.app.getAppId() == app.getAppId()) { + foundExistingApp = true; + break; + } + } + + // This app was removed in the latest app list + if (!foundExistingApp) { + appGridAdapter.removeApp(existingApp); + updated = true; + } + } + if (updated) { appGridAdapter.notifyDataSetChanged(); } diff --git a/app/src/main/java/com/limelight/grid/AppGridAdapter.java b/app/src/main/java/com/limelight/grid/AppGridAdapter.java index 2056c320..477a1a99 100644 --- a/app/src/main/java/com/limelight/grid/AppGridAdapter.java +++ b/app/src/main/java/com/limelight/grid/AppGridAdapter.java @@ -130,6 +130,10 @@ public class AppGridAdapter extends GenericGridAdapter { sortList(); } + public void removeApp(AppView.AppObject app) { + itemList.remove(app); + } + public void abortPendingRequests() { HashMap tempMap;