From 9a6da8956697e99962fc845290b9ee4b4266acdf Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Wed, 10 Jun 2020 19:45:59 +0000 Subject: [PATCH] merge two drawer listeners --- .../ui/activity/MainActivity.java | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java index 360f3006..b44c30f2 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java @@ -185,24 +185,6 @@ public class MainActivity extends ProfileThemedActivity { drawer.addDrawerListener(barDrawerToggle); } barDrawerToggle.syncState(); - drawer.addDrawerListener(new DrawerLayout.DrawerListener() { - @Override - public void onDrawerSlide(@NonNull View drawerView, float slideOffset) { - if (slideOffset > 0.2) - fabHide(); - } - @Override - public void onDrawerOpened(@NonNull View drawerView) { - fabHide(); - } - @Override - public void onDrawerClosed(@NonNull View drawerView) { - fabShouldShow(); - } - @Override - public void onDrawerStateChanged(int newState) {} - }); - try { PackageInfo pi = getApplicationContext().getPackageManager() @@ -312,16 +294,25 @@ public class MainActivity extends ProfileThemedActivity { (v) -> mProfileListAdapter.flipEditingProfiles()); if (drawerListener == null) { drawerListener = new DrawerLayout.SimpleDrawerListener() { + @Override + public void onDrawerSlide(@NonNull View drawerView, float slideOffset) { + if (slideOffset > 0.2) + fabHide(); + } @Override public void onDrawerClosed(View drawerView) { super.onDrawerClosed(drawerView); mProfileListAdapter.setAnimationsEnabled(false); mProfileListAdapter.editingProfiles.setValue(false); + Data.drawerOpen.setValue(false); + fabShouldShow(); } @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); mProfileListAdapter.setAnimationsEnabled(true); + Data.drawerOpen.setValue(true); + fabHide(); } }; drawer.addDrawerListener(drawerListener); -- 2.39.5