From e362f2ecf06f12be4ff511cb0f489abc880e7bc7 Mon Sep 17 00:00:00 2001 From: Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> Date: Thu, 3 Nov 2022 15:34:45 +1100 Subject: Fix issues related to hiding account karma in the navigation drawer. --- .../infinityforreddit/activities/MainActivity.java | 9 ++++++++- .../HeaderSectionRecyclerViewAdapter.java | 18 +++++++++++++----- .../NavigationDrawerRecyclerViewMergedAdapter.java | 4 ++++ .../infinityforreddit/events/ChangeHideKarmaEvent.java | 9 +++++++++ .../settings/NavigationDrawerPreferenceFragment.java | 9 +++++++++ 5 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeHideKarmaEvent.java (limited to 'app/src/main') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java index 5eff56e8..194ddd0f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java @@ -30,7 +30,6 @@ import androidx.appcompat.app.ActionBarDrawerToggle; import androidx.appcompat.app.AppCompatDelegate; import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.core.app.ActivityCompat; -import androidx.core.view.GravityCompat; import androidx.drawerlayout.widget.DrawerLayout; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; @@ -100,6 +99,7 @@ import ml.docilealligator.infinityforreddit.events.ChangeLockBottomAppBarEvent; import ml.docilealligator.infinityforreddit.events.ChangeNSFWEvent; import ml.docilealligator.infinityforreddit.events.ChangeRequireAuthToAccountSectionEvent; import ml.docilealligator.infinityforreddit.events.ChangeShowAvatarOnTheRightInTheNavigationDrawerEvent; +import ml.docilealligator.infinityforreddit.events.ChangeHideKarmaEvent; import ml.docilealligator.infinityforreddit.events.RecreateActivityEvent; import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.fragments.PostFragment; @@ -1276,6 +1276,13 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb } } + @Subscribe + public void onChangeHideKarmaEvent(ChangeHideKarmaEvent event) { + if (adapter != null) { + adapter.setHideKarma(event.hideKarma); + } + } + @Override public void onLongPress() { if (sectionsPagerAdapter != null) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/HeaderSectionRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/HeaderSectionRecyclerViewAdapter.java index bc051f76..270de60b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/HeaderSectionRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/navigationdrawer/HeaderSectionRecyclerViewAdapter.java @@ -47,7 +47,7 @@ public class HeaderSectionRecyclerViewAdapter extends RecyclerView.Adapter { @@ -28,5 +30,12 @@ public class NavigationDrawerPreferenceFragment extends CustomFontPreferenceFrag return true; }); } + + if (hideKarmaSwitch != null) { + hideKarmaSwitch.setOnPreferenceChangeListener((preference, newValue) -> { + EventBus.getDefault().post(new ChangeHideKarmaEvent((Boolean) newValue)); + return true; + }); + } } } \ No newline at end of file -- cgit v1.2.3