From f66b6802392bc473d7e1f86a58cf65b25ed2148c Mon Sep 17 00:00:00 2001 From: Hyunyoung Song Date: Mon, 25 Jul 2016 14:24:08 -0700 Subject: [PATCH] Refresh the all apps container search result when apps are installed b/30102209 > After user comes back from the play store after installing the app that didn't exist when searched, the app will now be shown in the filtered search result list. Change-Id: Ia5fe501596127a7401928e5db2d6f425ad753701 --- .../launcher3/allapps/AllAppsContainerView.java | 3 +++ .../allapps/AllAppsSearchBarController.java | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java index 3ef510c3f7..d81300c784 100644 --- a/src/com/android/launcher3/allapps/AllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java @@ -207,6 +207,7 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc */ public void addApps(List apps) { mApps.addApps(apps); + mSearchBarController.refreshSearchResult(); } /** @@ -214,6 +215,7 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc */ public void updateApps(List apps) { mApps.updateApps(apps); + mSearchBarController.refreshSearchResult(); } /** @@ -221,6 +223,7 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc */ public void removeApps(List apps) { mApps.removeApps(apps); + mSearchBarController.refreshSearchResult(); } public void setSearchBarVisible(boolean visible) { diff --git a/src/com/android/launcher3/allapps/AllAppsSearchBarController.java b/src/com/android/launcher3/allapps/AllAppsSearchBarController.java index b4a71caf8b..a99139cc08 100644 --- a/src/com/android/launcher3/allapps/AllAppsSearchBarController.java +++ b/src/com/android/launcher3/allapps/AllAppsSearchBarController.java @@ -46,6 +46,7 @@ public abstract class AllAppsSearchBarController protected AlphabeticalAppsList mApps; protected Callbacks mCb; protected ExtendedEditText mInput; + private String mQuery; protected DefaultAppSearchAlgorithm mSearchAlgorithm; protected InputMethodManager mInputMethodManager; @@ -94,16 +95,25 @@ public abstract class AllAppsSearchBarController @Override public void afterTextChanged(final Editable s) { - String query = s.toString(); - if (query.isEmpty()) { + mQuery = s.toString(); + if (mQuery.isEmpty()) { mSearchAlgorithm.cancel(true); mCb.clearSearchResult(); } else { mSearchAlgorithm.cancel(false); - mSearchAlgorithm.doSearch(query, mCb); + mSearchAlgorithm.doSearch(mQuery, mCb); } } + protected void refreshSearchResult() { + if (mQuery == null) { + return; + } + // If play store continues auto updating an app, we want to show partial result. + mSearchAlgorithm.cancel(false); + mSearchAlgorithm.doSearch(mQuery, mCb); + } + @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { // Skip if it's not the right action @@ -155,6 +165,7 @@ public abstract class AllAppsSearchBarController * Resets the search bar state. */ public void reset() { + mQuery = null; unfocusSearchField(); mCb.clearSearchResult(); mInput.setText("");