mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-05 18:36:49 +00:00
Refactor SearchAlgorithm and SearchCallback interface to work on generic search result type.
Test: Manually tested that 'All apps' search works fine Bug: b/157286785 Change-Id: Id4b7fb133149e9211f871b46b47d5853ec0e0050
This commit is contained in:
@@ -31,10 +31,10 @@ import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.search.SearchAlgorithm;
|
||||
import com.android.launcher3.search.SearchCallback;
|
||||
import com.android.launcher3.util.PackageManagerHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* An interface to a search box that AllApps can command.
|
||||
*/
|
||||
@@ -43,11 +43,11 @@ public class AllAppsSearchBarController
|
||||
OnFocusChangeListener {
|
||||
|
||||
protected BaseDraggingActivity mLauncher;
|
||||
protected Callbacks mCb;
|
||||
protected SearchCallback<AdapterItem> mCallback;
|
||||
protected ExtendedEditText mInput;
|
||||
protected String mQuery;
|
||||
|
||||
protected SearchAlgorithm mSearchAlgorithm;
|
||||
protected SearchAlgorithm<AdapterItem> mSearchAlgorithm;
|
||||
|
||||
public void setVisibility(int visibility) {
|
||||
mInput.setVisibility(visibility);
|
||||
@@ -57,9 +57,9 @@ public class AllAppsSearchBarController
|
||||
* Sets the references to the apps model and the search result callback.
|
||||
*/
|
||||
public final void initialize(
|
||||
SearchAlgorithm searchAlgorithm, ExtendedEditText input,
|
||||
BaseDraggingActivity launcher, Callbacks cb) {
|
||||
mCb = cb;
|
||||
SearchAlgorithm<AdapterItem> searchAlgorithm, ExtendedEditText input,
|
||||
BaseDraggingActivity launcher, SearchCallback<AdapterItem> callback) {
|
||||
mCallback = callback;
|
||||
mLauncher = launcher;
|
||||
|
||||
mInput = input;
|
||||
@@ -85,10 +85,10 @@ public class AllAppsSearchBarController
|
||||
mQuery = s.toString();
|
||||
if (mQuery.isEmpty()) {
|
||||
mSearchAlgorithm.cancel(true);
|
||||
mCb.clearSearchResult();
|
||||
mCallback.clearSearchResult();
|
||||
} else {
|
||||
mSearchAlgorithm.cancel(false);
|
||||
mSearchAlgorithm.doSearch(mQuery, mCb);
|
||||
mSearchAlgorithm.doSearch(mQuery, mCallback);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ public class AllAppsSearchBarController
|
||||
}
|
||||
// If play store continues auto updating an app, we want to show partial result.
|
||||
mSearchAlgorithm.cancel(false);
|
||||
mSearchAlgorithm.doSearch(mQuery, mCb);
|
||||
mSearchAlgorithm.doSearch(mQuery, mCallback);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -149,7 +149,7 @@ public class AllAppsSearchBarController
|
||||
* Resets the search bar state.
|
||||
*/
|
||||
public void reset() {
|
||||
mCb.clearSearchResult();
|
||||
mCallback.clearSearchResult();
|
||||
mInput.reset();
|
||||
mQuery = null;
|
||||
}
|
||||
@@ -167,31 +167,4 @@ public class AllAppsSearchBarController
|
||||
public boolean isSearchFieldFocused() {
|
||||
return mInput.isFocused();
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for getting search results.
|
||||
*/
|
||||
public interface Callbacks {
|
||||
|
||||
/**
|
||||
* Called when the search from primary source is complete.
|
||||
*
|
||||
* @param items sorted list of search result adapter items
|
||||
*/
|
||||
void onSearchResult(String query, ArrayList<AdapterItem> items);
|
||||
|
||||
/**
|
||||
* Called when the search from secondary source is complete.
|
||||
*
|
||||
* @param items sorted list of search result adapter items
|
||||
*/
|
||||
void onAppendSearchResult(String query, ArrayList<AdapterItem> items);
|
||||
|
||||
/**
|
||||
* Called when the search results should be cleared.
|
||||
*/
|
||||
void clearSearchResult();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user