diff options
author | ByteHamster <ByteHamster@users.noreply.github.com> | 2024-01-10 17:12:31 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-10 17:12:31 -0500 |
commit | 6e2a8b86a7d59a2e18cebab4cf8e057d8dcfa9e4 (patch) | |
tree | 903fe1d991130051908cfdaf804ef43890160721 /app/src/main | |
parent | b1e6da935b21ec466c04782d987f0f326ac7b424 (diff) | |
parent | 0361e05ca8551fe117cedda77b87c744a85af712 (diff) | |
download | AntennaPod-6e2a8b86a7d59a2e18cebab4cf8e057d8dcfa9e4.zip |
Merge pull request #6859 from ByteHamster/echo-tweaks
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/ui/home/sections/EchoSection.java | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/ui/home/sections/EchoSection.java b/app/src/main/java/de/danoeh/antennapod/ui/home/sections/EchoSection.java index 813ca4d1e..05b716abb 100644 --- a/app/src/main/java/de/danoeh/antennapod/ui/home/sections/EchoSection.java +++ b/app/src/main/java/de/danoeh/antennapod/ui/home/sections/EchoSection.java @@ -34,11 +34,7 @@ public class EchoSection extends Fragment { viewBinding = HomeSectionEchoBinding.inflate(inflater); viewBinding.titleLabel.setText(getString(R.string.antennapod_echo_year, EchoActivity.RELEASE_YEAR)); viewBinding.echoButton.setOnClickListener(v -> startActivity(new Intent(getContext(), EchoActivity.class))); - viewBinding.closeButton.setOnClickListener(v -> { - getContext().getSharedPreferences(HomeFragment.PREF_NAME, Context.MODE_PRIVATE) - .edit().putInt(HomeFragment.PREF_HIDE_ECHO, EchoActivity.RELEASE_YEAR).apply(); - ((MainActivity) getActivity()).loadFragment(HomeFragment.TAG, null); - }); + viewBinding.closeButton.setOnClickListener(v -> hideThisYear()); updateVisibility(); return viewBinding.getRoot(); } @@ -70,8 +66,18 @@ public class EchoSection extends Fragment { }) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) - .subscribe(totalTime -> viewBinding.getRoot() - .setVisibility((totalTime >= 3600 * 10) ? View.VISIBLE : View.GONE), - Throwable::printStackTrace); + .subscribe(totalTime -> { + boolean shouldShow = (totalTime >= 3600 * 10); + viewBinding.getRoot().setVisibility(shouldShow ? View.VISIBLE : View.GONE); + if (!shouldShow) { + hideThisYear(); + } + }, Throwable::printStackTrace); + } + + void hideThisYear() { + getContext().getSharedPreferences(HomeFragment.PREF_NAME, Context.MODE_PRIVATE) + .edit().putInt(HomeFragment.PREF_HIDE_ECHO, EchoActivity.RELEASE_YEAR).apply(); + ((MainActivity) getActivity()).loadFragment(HomeFragment.TAG, null); } } |