aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java13
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/NavigationDrawerRecyclerViewAdapter.java31
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<Re
openAccountSection(((NavHeaderViewHolder) holder).dropIconImageView);
}
} else {
- ((NavHeaderViewHolder) holder).dropIconImageView.setImageDrawable(resources.getDrawable(R.drawable.ic_baseline_arrow_drop_down_24px));
- notifyItemRangeRemoved(1, getItemCount() - 1);
- if (isLoggedIn) {
- if (subscribedSubreddits != null) {
- notifyItemRangeInserted(1, subscribedSubreddits.size() + CURRENT_MENU_ITEMS - 1);
- } else {
- notifyItemRangeInserted(1, CURRENT_MENU_ITEMS - 1);
- }
- } else {
- notifyItemRangeInserted(1, 2);
- }
- isInMainPage = true;
+ ((NavHeaderViewHolder) holder).dropIconImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ic_baseline_arrow_drop_down_24px, null));
+ closeAccountSectionWithoutChangeIconResource();
}
});
} else if (holder instanceof MenuGroupTitleViewHolder) {
@@ -422,8 +413,22 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
}
}
+ public void closeAccountSectionWithoutChangeIconResource() {
+ notifyItemRangeRemoved(1, getItemCount() - 1);
+ if (isLoggedIn) {
+ if (subscribedSubreddits != null) {
+ notifyItemRangeInserted(1, subscribedSubreddits.size() + CURRENT_MENU_ITEMS - 1);
+ } else {
+ notifyItemRangeInserted(1, CURRENT_MENU_ITEMS - 1);
+ }
+ } else {
+ notifyItemRangeInserted(1, 2);
+ }
+ isInMainPage = true;
+ }
+
private void openAccountSection(ImageView dropIconImageView) {
- dropIconImageView.setImageDrawable(resources.getDrawable(R.drawable.ic_baseline_arrow_drop_up_24px));
+ dropIconImageView.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.ic_baseline_arrow_drop_up_24px, null));
notifyItemRangeRemoved(1, getItemCount() - 1);
if (accounts != null) {
notifyItemRangeInserted(1, accounts.size() + 3);