From d730b719b8811eca930e5a0e88faba0737098a55 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Wed, 23 Sep 2020 12:28:42 +0800 Subject: Always close the account section in the navigation drawer when dismissed. --- .../infinityforreddit/Activity/MainActivity.java | 13 ++++++--- .../NavigationDrawerRecyclerViewAdapter.java | 31 +++++++++++++--------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java index 58c05954..6d78ad7b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java @@ -256,11 +256,19 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb setSupportActionBar(toolbar); setToolbarGoToTop(toolbar); - drawer = findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); toggle.getDrawerArrowDrawable().setColor(mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor()); drawer.addDrawerListener(toggle); + drawer.addDrawerListener(new DrawerLayout.SimpleDrawerListener() { + @Override + public void onDrawerClosed(View drawerView) { + if (adapter != null) { + adapter.closeAccountSectionWithoutChangeIconResource(); + adapter.notifyItemChanged(0); + } + } + }); toggle.syncState(); params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams(); @@ -799,8 +807,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb } @Override - public void onBackPressed() { - DrawerLayout drawer = findViewById(R.id.drawer_layout); + public void onBackPressed() {; if (drawer.isDrawerOpen(GravityCompat.START)) { drawer.closeDrawer(GravityCompat.START); } else { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/NavigationDrawerRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/NavigationDrawerRecyclerViewAdapter.java index 2bd5d4b2..fc330b00 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/NavigationDrawerRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/NavigationDrawerRecyclerViewAdapter.java @@ -14,6 +14,7 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.biometric.BiometricManager; import androidx.biometric.BiometricPrompt; import androidx.core.content.ContextCompat; +import androidx.core.content.res.ResourcesCompat; import androidx.recyclerview.widget.RecyclerView; import com.bumptech.glide.Glide; @@ -221,18 +222,8 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter