mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 00:06:47 +00:00
Add All Apps search delegate for inflating search box.
Test: Manual Bug: 216683257 Flag: not needed Change-Id: I2e1d9b0abf6d370d7ff6d6af2bab002b87330d86
This commit is contained in:
@@ -70,7 +70,7 @@ import com.android.launcher3.InsettableFrameLayout;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.allapps.BaseAllAppsAdapter.AdapterItem;
|
||||
import com.android.launcher3.allapps.search.DefaultSearchAdapterProvider;
|
||||
import com.android.launcher3.allapps.search.AllAppsSearchUiDelegate;
|
||||
import com.android.launcher3.allapps.search.SearchAdapterProvider;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.keyboard.FocusedItemDecorator;
|
||||
@@ -132,6 +132,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
protected final Point mFastScrollerOffset = new Point();
|
||||
protected final int mScrimColor;
|
||||
protected final float mHeaderThreshold;
|
||||
protected final AllAppsSearchUiDelegate mSearchUiDelegate;
|
||||
|
||||
// Used to animate Search results out and A-Z apps in, or vice-versa.
|
||||
private final SearchTransitionController mSearchTransitionController;
|
||||
@@ -217,11 +218,17 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
getActiveRecyclerView().requestFocus();
|
||||
}
|
||||
});
|
||||
mSearchUiDelegate = createSearchUiDelegate();
|
||||
initContent();
|
||||
|
||||
mSearchTransitionController = new SearchTransitionController(this);
|
||||
}
|
||||
|
||||
/** Creates the delegate for initializing search. */
|
||||
protected AllAppsSearchUiDelegate createSearchUiDelegate() {
|
||||
return new AllAppsSearchUiDelegate(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the view hierarchy and internal variables. Any initialization which actually uses
|
||||
* these members should be done in {@link #onFinishInflate()}.
|
||||
@@ -231,7 +238,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
* onFinishInflate -> onPostCreate
|
||||
*/
|
||||
protected void initContent() {
|
||||
mMainAdapterProvider = createMainAdapterProvider();
|
||||
mMainAdapterProvider = mSearchUiDelegate.createMainAdapterProvider();
|
||||
|
||||
mAH.set(AdapterHolder.MAIN, new AdapterHolder(AdapterHolder.MAIN,
|
||||
new AlphabeticalAppsList<>(mActivityContext, mAllAppsStore, null)));
|
||||
@@ -252,6 +259,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
mSearchContainer = inflateSearchBox();
|
||||
addView(mSearchContainer);
|
||||
mSearchUiManager = (SearchUiManager) mSearchContainer;
|
||||
mSearchUiDelegate.onInitializeSearchBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -341,6 +349,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
*/
|
||||
public void setSearchResults(ArrayList<AdapterItem> results, int searchResultCode) {
|
||||
setSearchResults(results);
|
||||
mSearchUiDelegate.onSearchResultsChanged(results, searchResultCode);
|
||||
}
|
||||
|
||||
private void animateToSearchState(boolean goingToSearch) {
|
||||
@@ -788,12 +797,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
* Inflates the search box
|
||||
*/
|
||||
protected View inflateSearchBox() {
|
||||
return getLayoutInflater().inflate(R.layout.search_container_all_apps, this, false);
|
||||
}
|
||||
|
||||
/** Creates the adapter provider for the main section. */
|
||||
protected SearchAdapterProvider<?> createMainAdapterProvider() {
|
||||
return new DefaultSearchAdapterProvider(mActivityContext);
|
||||
return mSearchUiDelegate.inflateSearchBox();
|
||||
}
|
||||
|
||||
/** The adapter provider for the main section. */
|
||||
@@ -998,7 +1002,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
}
|
||||
|
||||
public LayoutInflater getLayoutInflater() {
|
||||
return LayoutInflater.from(getContext());
|
||||
return mSearchUiDelegate.getLayoutInflater();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1306,6 +1310,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
|
||||
protected void onInitializeRecyclerView(RecyclerView rv) {
|
||||
rv.addOnScrollListener(mScrollListener);
|
||||
mSearchUiDelegate.onInitializeRecyclerView(rv);
|
||||
}
|
||||
|
||||
/** Returns the instance of @{code SearchTransitionController}. */
|
||||
|
||||
Reference in New Issue
Block a user