Fix removal of apps in app list updates

This commit is contained in:
Cameron Gutman 2015-02-22 18:04:42 -05:00
parent 59df38ae8a
commit bf795ab7a5
2 changed files with 25 additions and 0 deletions

View File

@ -366,6 +366,7 @@ public class AppView extends Activity implements AdapterFragmentCallbacks {
public void run() { public void run() {
boolean updated = false; boolean updated = false;
// First handle app updates and additions
for (NvApp app : appList) { for (NvApp app : appList) {
boolean foundExistingApp = false; 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) { if (updated) {
appGridAdapter.notifyDataSetChanged(); appGridAdapter.notifyDataSetChanged();
} }

View File

@ -130,6 +130,10 @@ public class AppGridAdapter extends GenericGridAdapter<AppView.AppObject> {
sortList(); sortList();
} }
public void removeApp(AppView.AppObject app) {
itemList.remove(app);
}
public void abortPendingRequests() { public void abortPendingRequests() {
HashMap<ImageView, Future> tempMap; HashMap<ImageView, Future> tempMap;