Fixing search behavior in Launcher3
> Showing no-result found only when there are no results > Removing unnecessary view inflation in RecyclerViewPool for various search vide types > Removing unused market-search link and no-empty-result illustration Bug: 240343082 Bug: 207573083 Test: Verified Launcher3 Change-Id: Ia44799cd2385ea5dc837ef25732ca237975abde7
This commit is contained in:
1 parent
f6003ff070
commit
af95ddbadc
16 files changed
+33
-623
No files matched your search
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.android.launcher3.allapps.search;
|
||||
|
||||
import static com.android.launcher3.allapps.BaseAllAppsAdapter.VIEW_TYPE_EMPTY_SEARCH;
|
||||
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
|
||||
|
||||
import android.content.Context;
|
||||
@@ -44,10 +45,16 @@ public class DefaultAppSearchAlgorithm implements SearchAlgorithm<AdapterItem> {
|
||||
|
||||
private final LauncherAppState mAppState;
|
||||
private final Handler mResultHandler;
|
||||
private final boolean mAddNoResultsMessage;
|
||||
|
||||
public DefaultAppSearchAlgorithm(Context context) {
|
||||
this(context, false);
|
||||
}
|
||||
|
||||
public DefaultAppSearchAlgorithm(Context context, boolean addNoResultsMessage) {
|
||||
mAppState = LauncherAppState.getInstance(context);
|
||||
mResultHandler = new Handler(MAIN_EXECUTOR.getLooper());
|
||||
mAddNoResultsMessage = addNoResultsMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,11 +70,23 @@ public class DefaultAppSearchAlgorithm implements SearchAlgorithm<AdapterItem> {
|
||||
@Override
|
||||
public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList apps) {
|
||||
ArrayList<AdapterItem> result = getTitleMatchResult(apps.data, query);
|
||||
if (mAddNoResultsMessage && result.isEmpty()) {
|
||||
result.add(getEmptyMessageAdapterItem(query));
|
||||
}
|
||||
mResultHandler.post(() -> callback.onSearchResult(query, result));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static AdapterItem getEmptyMessageAdapterItem(String query) {
|
||||
AdapterItem item = new AdapterItem(VIEW_TYPE_EMPTY_SEARCH);
|
||||
// Add a place holder info to propagate the query
|
||||
AppInfo placeHolder = new AppInfo();
|
||||
placeHolder.title = query;
|
||||
item.itemInfo = placeHolder;
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters {@link AppInfo}s matching specified query
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user