diff options
author | Docile-Alligator <chineseperson5@gmail.com> | 2022-05-14 11:26:26 +0000 |
---|---|---|
committer | Docile-Alligator <chineseperson5@gmail.com> | 2022-05-14 11:26:26 +0000 |
commit | 67d30b90e445163b09e325f8fc28154037f93266 (patch) | |
tree | a9cbb41eb3e8210f5fda2046e37e3f4e5a3aca57 /app | |
parent | 4f7d8321fc6bec7008b7a95d29a4f1119d1c3b81 (diff) | |
download | infinity-for-reddit-67d30b90e445163b09e325f8fc28154037f93266.tar infinity-for-reddit-67d30b90e445163b09e325f8fc28154037f93266.tar.gz infinity-for-reddit-67d30b90e445163b09e325f8fc28154037f93266.tar.bz2 infinity-for-reddit-67d30b90e445163b09e325f8fc28154037f93266.tar.lz infinity-for-reddit-67d30b90e445163b09e325f8fc28154037f93266.tar.xz infinity-for-reddit-67d30b90e445163b09e325f8fc28154037f93266.tar.zst infinity-for-reddit-67d30b90e445163b09e325f8fc28154037f93266.zip |
Fix inbox count not updating after reading a message.
Diffstat (limited to 'app')
2 files changed, 10 insertions, 2 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java index dce42d12..1fd5f7f0 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java @@ -17,6 +17,8 @@ import androidx.paging.PagedListAdapter; import androidx.recyclerview.widget.DiffUtil; import androidx.recyclerview.widget.RecyclerView; +import org.greenrobot.eventbus.EventBus; + import java.util.ArrayList; import butterknife.BindView; @@ -40,6 +42,7 @@ import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity; import ml.docilealligator.infinityforreddit.activities.ViewPrivateMessagesActivity; import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; +import ml.docilealligator.infinityforreddit.events.ChangeInboxCountEvent; import ml.docilealligator.infinityforreddit.markdown.SpoilerParserPlugin; import ml.docilealligator.infinityforreddit.markdown.SuperscriptInlineProcessor; import ml.docilealligator.infinityforreddit.message.FetchMessage; @@ -171,7 +174,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl if (markAllMessagesAsRead) { message.setNew(false); } else { - ((DataViewHolder) holder).itemView.setBackgroundColor( + holder.itemView.setBackgroundColor( mUnreadMessageBackgroundColor); } } @@ -209,6 +212,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl new ReadMessage.ReadMessageListener() { @Override public void readSuccess() { + EventBus.getDefault().post(new ChangeInboxCountEvent(-1)); } @Override 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 18c98c6f..16de7142 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 @@ -147,7 +147,11 @@ public class AccountSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recy } public void setInboxCount(int inboxCount) { - this.inboxCount = inboxCount; + if (inboxCount < 0) { + this.inboxCount = Math.max(0, this.inboxCount + inboxCount); + } else { + this.inboxCount = inboxCount; + } notifyDataSetChanged(); } |