Don't hide games immediately

This commit is contained in:
Cameron Gutman 2020-08-11 18:47:01 -07:00
parent 4cae6959df
commit 56394471fa
2 changed files with 20 additions and 11 deletions

View File

@ -113,7 +113,7 @@ public class AppView extends Activity implements AdapterFragmentCallbacks {
return; return;
} }
appGridAdapter.updateHiddenApps(hiddenAppIds); appGridAdapter.updateHiddenApps(hiddenAppIds, true);
// Now make the binder visible. We must do this after appGridAdapter // Now make the binder visible. We must do this after appGridAdapter
// is set to prevent us from reaching updateUiWithServerinfo() and // is set to prevent us from reaching updateUiWithServerinfo() and
@ -314,7 +314,7 @@ public class AppView extends Activity implements AdapterFragmentCallbacks {
Service.BIND_AUTO_CREATE); Service.BIND_AUTO_CREATE);
} }
private void updateHiddenApps() { private void updateHiddenApps(boolean hideImmediately) {
HashSet<String> hiddenAppIdStringSet = new HashSet<>(); HashSet<String> hiddenAppIdStringSet = new HashSet<>();
for (Integer hiddenAppId : hiddenAppIds) { for (Integer hiddenAppId : hiddenAppIds) {
@ -326,7 +326,7 @@ public class AppView extends Activity implements AdapterFragmentCallbacks {
.putStringSet(uuidString, hiddenAppIdStringSet) .putStringSet(uuidString, hiddenAppIdStringSet)
.apply(); .apply();
appGridAdapter.updateHiddenApps(hiddenAppIds); appGridAdapter.updateHiddenApps(hiddenAppIds, hideImmediately);
} }
private void populateAppGridWithCache() { private void populateAppGridWithCache() {
@ -481,7 +481,7 @@ public class AppView extends Activity implements AdapterFragmentCallbacks {
// Transitioning shown to hidden // Transitioning shown to hidden
hiddenAppIds.add(app.app.getAppId()); hiddenAppIds.add(app.app.getAppId());
} }
updateHiddenApps(); updateHiddenApps(false);
return true; return true;
case CREATE_SHORTCUT_ID: case CREATE_SHORTCUT_ID:

View File

@ -48,19 +48,28 @@ public class AppGridAdapter extends GenericGridAdapter<AppView.AppObject> {
updateLayoutWithPreferences(context, prefs); updateLayoutWithPreferences(context, prefs);
} }
public void updateHiddenApps(Set<Integer> newHiddenAppIds) { public void updateHiddenApps(Set<Integer> newHiddenAppIds, boolean hideImmediately) {
this.hiddenAppIds.clear(); this.hiddenAppIds.clear();
this.hiddenAppIds.addAll(newHiddenAppIds); this.hiddenAppIds.addAll(newHiddenAppIds);
// Reconstruct the itemList with the new hidden app set if (hideImmediately) {
itemList.clear(); // Reconstruct the itemList with the new hidden app set
for (AppView.AppObject app : allApps) { itemList.clear();
app.isHidden = hiddenAppIds.contains(app.app.getAppId()); for (AppView.AppObject app : allApps) {
app.isHidden = hiddenAppIds.contains(app.app.getAppId());
if (!app.isHidden || showHiddenApps) { if (!app.isHidden || showHiddenApps) {
itemList.add(app); 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(); notifyDataSetChanged();
} }