aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorDocile-Alligator <chineseperson5@gmail.com>2022-03-11 04:10:35 +0000
committerDocile-Alligator <chineseperson5@gmail.com>2022-03-11 04:10:35 +0000
commitaab502238dce0a84dfc94dbabb67f98eabb7f074 (patch)
tree33373701dbc04020e40212c7b45e4ce80cf34917 /app/src/main
parent53755d438168f3830dba2dad9ae63d7262909fc3 (diff)
downloadinfinity-for-reddit-aab502238dce0a84dfc94dbabb67f98eabb7f074.tar
infinity-for-reddit-aab502238dce0a84dfc94dbabb67f98eabb7f074.tar.gz
infinity-for-reddit-aab502238dce0a84dfc94dbabb67f98eabb7f074.tar.bz2
infinity-for-reddit-aab502238dce0a84dfc94dbabb67f98eabb7f074.tar.lz
infinity-for-reddit-aab502238dce0a84dfc94dbabb67f98eabb7f074.tar.xz
infinity-for-reddit-aab502238dce0a84dfc94dbabb67f98eabb7f074.tar.zst
infinity-for-reddit-aab502238dce0a84dfc94dbabb67f98eabb7f074.zip
Fix navigation drawer issues.
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/AccountSectionRecyclerViewAdapter.java13
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/PostSectionRecyclerViewAdapter.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/PreferenceSectionRecyclerViewAdapter.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/RedditSectionRecyclerViewAdapter.java2
4 files changed, 9 insertions, 10 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/AccountSectionRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/AccountSectionRecyclerViewAdapter.java
index 348eb199..18c98c6f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/AccountSectionRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/AccountSectionRecyclerViewAdapter.java
@@ -2,6 +2,7 @@ package ml.docilealligator.infinityforreddit.adapters.navigationdrawer;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -25,6 +26,7 @@ public class AccountSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recy
private static final int VIEW_TYPE_MENU_GROUP_TITLE = 1;
private static final int VIEW_TYPE_MENU_ITEM = 2;
private static final int ACCOUNT_SECTION_ITEMS = 4;
+ private static final int ANONYMOUS_ACCOUNT_SECTION_ITEMS = 2;
private BaseActivity baseActivity;
private int inboxCount;
@@ -77,10 +79,10 @@ public class AccountSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recy
holder.itemView.setOnClickListener(view -> {
if (collapseAccountSection) {
collapseAccountSection = !collapseAccountSection;
- notifyItemRangeInserted(holder.getBindingAdapterPosition() + 1, ACCOUNT_SECTION_ITEMS);
+ notifyItemRangeInserted(holder.getBindingAdapterPosition() + 1, isLoggedIn ? ACCOUNT_SECTION_ITEMS : ANONYMOUS_ACCOUNT_SECTION_ITEMS);
} else {
collapseAccountSection = !collapseAccountSection;
- notifyItemRangeRemoved(holder.getBindingAdapterPosition() + 1, ACCOUNT_SECTION_ITEMS);
+ notifyItemRangeRemoved(holder.getBindingAdapterPosition() + 1, isLoggedIn ? ACCOUNT_SECTION_ITEMS : ANONYMOUS_ACCOUNT_SECTION_ITEMS);
}
notifyItemChanged(holder.getBindingAdapterPosition());
});
@@ -103,7 +105,7 @@ public class AccountSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recy
stringId = R.string.multi_reddit;
drawableId = R.drawable.ic_multi_reddit_24dp;
break;
- case 4:
+ default:
setOnClickListener = false;
if (inboxCount > 0) {
((MenuItemViewHolder) holder).menuTextView.setText(baseActivity.getString(R.string.inbox_with_count, inboxCount));
@@ -141,10 +143,7 @@ public class AccountSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recy
@Override
public int getItemCount() {
- if (isLoggedIn) {
- return ACCOUNT_SECTION_ITEMS + 1;
- }
- return 3;
+ return collapseAccountSection ? 1 : (isLoggedIn ? ACCOUNT_SECTION_ITEMS + 1 : ANONYMOUS_ACCOUNT_SECTION_ITEMS + 1);
}
public void setInboxCount(int inboxCount) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/PostSectionRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/PostSectionRecyclerViewAdapter.java
index 608d1e18..2d9f7406 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/PostSectionRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/PostSectionRecyclerViewAdapter.java
@@ -119,7 +119,7 @@ public class PostSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recycle
@Override
public int getItemCount() {
- return isLoggedIn ? POST_SECTION_ITEMS + 1 : 0;
+ return isLoggedIn ? (collapsePostSection ? 1: POST_SECTION_ITEMS + 1) : 0;
}
class MenuGroupTitleViewHolder extends RecyclerView.ViewHolder {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/PreferenceSectionRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/PreferenceSectionRecyclerViewAdapter.java
index 788b4895..32485929 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/PreferenceSectionRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/PreferenceSectionRecyclerViewAdapter.java
@@ -143,7 +143,7 @@ public class PreferenceSectionRecyclerViewAdapter extends RecyclerView.Adapter<R
@Override
public int getItemCount() {
- return PREFERENCES_SECTION_ITEMS + 1;
+ return collapsePreferencesSection ? 1 : PREFERENCES_SECTION_ITEMS + 1;
}
public void setNSFWEnabled(boolean isNSFWEnabled) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/RedditSectionRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/RedditSectionRecyclerViewAdapter.java
index 4d33b3ef..ab6ed539 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/RedditSectionRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/RedditSectionRecyclerViewAdapter.java
@@ -103,7 +103,7 @@ public class RedditSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
@Override
public int getItemCount() {
- return REDDIT_SECTION_ITEMS + 1;
+ return collapseRedditSection ? 1 : REDDIT_SECTION_ITEMS + 1;
}
class MenuGroupTitleViewHolder extends RecyclerView.ViewHolder {