mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 00:06:47 +00:00
Fix work tab is gone when leaving search mode
1. onSearchResultsChanged is not called if the query is empty. Introduce onClearSearchResult and restore the tab there 2. rebindAdapters should only perform the actual logic if showTabs != mShowTabs, except the first time when we init the layout in onFinishInflate. Fix: 71737947 Change-Id: I5485d6be0fc33b73aa6e0709be66cef8d43b4dbd
This commit is contained in:
@@ -27,7 +27,6 @@ import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.Selection;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -149,9 +148,7 @@ public class AllAppsContainerView extends RelativeLayout implements DragSource,
|
||||
*/
|
||||
public void setApps(List<AppInfo> apps) {
|
||||
boolean hasWorkProfileApp = hasWorkProfileApp(apps);
|
||||
if (mUsingTabs != hasWorkProfileApp) {
|
||||
rebindAdapters(hasWorkProfileApp);
|
||||
}
|
||||
rebindAdapters(hasWorkProfileApp);
|
||||
mComponentToAppMap.clear();
|
||||
addOrUpdateApps(apps);
|
||||
}
|
||||
@@ -261,7 +258,7 @@ public class AllAppsContainerView extends RelativeLayout implements DragSource,
|
||||
});
|
||||
|
||||
mHeader = findViewById(R.id.all_apps_header);
|
||||
rebindAdapters(mUsingTabs);
|
||||
rebindAdapters(mUsingTabs, true /* force */);
|
||||
|
||||
mSearchContainer = findViewById(R.id.search_container_all_apps);
|
||||
mSearchUiManager = (SearchUiManager) mSearchContainer;
|
||||
@@ -385,9 +382,14 @@ public class AllAppsContainerView extends RelativeLayout implements DragSource,
|
||||
}
|
||||
|
||||
private void rebindAdapters(boolean showTabs) {
|
||||
if (showTabs != mUsingTabs) {
|
||||
replaceRVContainer(showTabs);
|
||||
rebindAdapters(showTabs, false /* force */);
|
||||
}
|
||||
|
||||
private void rebindAdapters(boolean showTabs, boolean force) {
|
||||
if (showTabs == mUsingTabs && !force) {
|
||||
return;
|
||||
}
|
||||
replaceRVContainer(showTabs);
|
||||
mUsingTabs = showTabs;
|
||||
|
||||
if (mUsingTabs) {
|
||||
@@ -529,13 +531,16 @@ public class AllAppsContainerView extends RelativeLayout implements DragSource,
|
||||
for (int i = 0; i < mAH.length; i++) {
|
||||
mAH[i].adapter.setLastSearchQuery(query);
|
||||
}
|
||||
boolean hasQuery = !TextUtils.isEmpty(query);
|
||||
if (mUsingTabs && hasQuery) {
|
||||
if (mUsingTabs) {
|
||||
mSearchModeWhileUsingTabs = true;
|
||||
rebindAdapters(false); // hide tabs
|
||||
} else if (mSearchModeWhileUsingTabs && !hasQuery) {
|
||||
mSearchModeWhileUsingTabs = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void onClearSearchResult() {
|
||||
if (mSearchModeWhileUsingTabs) {
|
||||
rebindAdapters(true); // show tabs
|
||||
mSearchModeWhileUsingTabs = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user