From 56394471fa7179f39aaf65efc8ede258ed55014e Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 11 Aug 2020 18:47:01 -0700 Subject: [PATCH] Don't hide games immediately --- app/src/main/java/com/limelight/AppView.java | 8 +++---- .../com/limelight/grid/AppGridAdapter.java | 23 +++++++++++++------ 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/limelight/AppView.java b/app/src/main/java/com/limelight/AppView.java index de5f91ec..6937c5d5 100644 --- a/app/src/main/java/com/limelight/AppView.java +++ b/app/src/main/java/com/limelight/AppView.java @@ -113,7 +113,7 @@ public class AppView extends Activity implements AdapterFragmentCallbacks { return; } - appGridAdapter.updateHiddenApps(hiddenAppIds); + appGridAdapter.updateHiddenApps(hiddenAppIds, true); // Now make the binder visible. We must do this after appGridAdapter // is set to prevent us from reaching updateUiWithServerinfo() and @@ -314,7 +314,7 @@ public class AppView extends Activity implements AdapterFragmentCallbacks { Service.BIND_AUTO_CREATE); } - private void updateHiddenApps() { + private void updateHiddenApps(boolean hideImmediately) { HashSet hiddenAppIdStringSet = new HashSet<>(); for (Integer hiddenAppId : hiddenAppIds) { @@ -326,7 +326,7 @@ public class AppView extends Activity implements AdapterFragmentCallbacks { .putStringSet(uuidString, hiddenAppIdStringSet) .apply(); - appGridAdapter.updateHiddenApps(hiddenAppIds); + appGridAdapter.updateHiddenApps(hiddenAppIds, hideImmediately); } private void populateAppGridWithCache() { @@ -481,7 +481,7 @@ public class AppView extends Activity implements AdapterFragmentCallbacks { // Transitioning shown to hidden hiddenAppIds.add(app.app.getAppId()); } - updateHiddenApps(); + updateHiddenApps(false); return true; case CREATE_SHORTCUT_ID: diff --git a/app/src/main/java/com/limelight/grid/AppGridAdapter.java b/app/src/main/java/com/limelight/grid/AppGridAdapter.java index a7a65c79..de594bba 100644 --- a/app/src/main/java/com/limelight/grid/AppGridAdapter.java +++ b/app/src/main/java/com/limelight/grid/AppGridAdapter.java @@ -48,19 +48,28 @@ public class AppGridAdapter extends GenericGridAdapter { updateLayoutWithPreferences(context, prefs); } - public void updateHiddenApps(Set newHiddenAppIds) { + public void updateHiddenApps(Set newHiddenAppIds, boolean hideImmediately) { this.hiddenAppIds.clear(); this.hiddenAppIds.addAll(newHiddenAppIds); - // Reconstruct the itemList with the new hidden app set - itemList.clear(); - for (AppView.AppObject app : allApps) { - app.isHidden = hiddenAppIds.contains(app.app.getAppId()); + if (hideImmediately) { + // Reconstruct the itemList with the new hidden app set + itemList.clear(); + for (AppView.AppObject app : allApps) { + app.isHidden = hiddenAppIds.contains(app.app.getAppId()); - if (!app.isHidden || showHiddenApps) { - itemList.add(app); + if (!app.isHidden || showHiddenApps) { + itemList.add(app); + } } } + else { + // Just update the isHidden state to show the correct UI indication + for (AppView.AppObject app : allApps) { + app.isHidden = hiddenAppIds.contains(app.app.getAppId()); + } + } + notifyDataSetChanged(); }