mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 00:06:47 +00:00
[Work] Fix duplicate work button issue
Bug: 195623679 Test: manual Change-Id: I882c5f7a196e07fa0dab3a2f27437abd233ec782
This commit is contained in:
@@ -454,7 +454,6 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
||||
mAllAppsStore.unregisterIconContainer(mAH[AdapterHolder.WORK].recyclerView);
|
||||
|
||||
if (mUsingTabs) {
|
||||
setupWorkToggle();
|
||||
mAH[AdapterHolder.MAIN].setup(mViewPager.getChildAt(0), mPersonalMatcher);
|
||||
mAH[AdapterHolder.WORK].setup(mViewPager.getChildAt(1), mWorkMatcher);
|
||||
mAH[AdapterHolder.WORK].recyclerView.setId(R.id.apps_list_view_work);
|
||||
@@ -485,6 +484,7 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
||||
}
|
||||
|
||||
private void setupWorkToggle() {
|
||||
removeWorkToggle();
|
||||
if (Utilities.ATLEAST_P) {
|
||||
mWorkModeSwitch = (WorkModeSwitch) mLauncher.getLayoutInflater().inflate(
|
||||
R.layout.work_mode_fab, this, false);
|
||||
@@ -497,6 +497,14 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
||||
}
|
||||
}
|
||||
|
||||
private void removeWorkToggle() {
|
||||
if (mWorkModeSwitch == null) return;
|
||||
if (mWorkModeSwitch.getParent() == this) {
|
||||
this.removeView(mWorkModeSwitch);
|
||||
}
|
||||
mWorkModeSwitch = null;
|
||||
}
|
||||
|
||||
private void replaceRVContainer(boolean showTabs) {
|
||||
for (int i = 0; i < mAH.length; i++) {
|
||||
if (mAH[i].recyclerView != null) {
|
||||
@@ -517,8 +525,10 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
||||
mViewPager = (AllAppsPagedView) newView;
|
||||
mViewPager.initParentViews(this);
|
||||
mViewPager.getPageIndicator().setOnActivePageChangedListener(this);
|
||||
setupWorkToggle();
|
||||
} else {
|
||||
mViewPager = null;
|
||||
removeWorkToggle();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -537,14 +547,6 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
||||
mWorkModeSwitch.setWorkTabVisible(currentActivePage == AdapterHolder.WORK
|
||||
&& mAllAppsStore.hasModelFlag(
|
||||
FLAG_HAS_SHORTCUT_PERMISSION | FLAG_QUIET_MODE_CHANGE_PERMISSION));
|
||||
|
||||
if (currentActivePage == AdapterHolder.WORK) {
|
||||
if (mWorkModeSwitch.getParent() == null) {
|
||||
addView(mWorkModeSwitch);
|
||||
}
|
||||
} else {
|
||||
removeView(mWorkModeSwitch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user