From 9e6139881bf8f72936cb1ae5c94f6512042260c7 Mon Sep 17 00:00:00 2001 From: Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> Date: Thu, 17 Oct 2024 15:05:55 -0400 Subject: Lazy mode in HistoryPostFragment. --- .../fragments/HistoryPostFragment.java | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'app/src/main/java/ml/docilealligator') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java index 369da42b..3ea7ae13 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java @@ -9,6 +9,9 @@ import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; @@ -54,6 +57,7 @@ import ml.docilealligator.infinityforreddit.post.HistoryPostViewModel; import ml.docilealligator.infinityforreddit.postfilter.PostFilter; import ml.docilealligator.infinityforreddit.postfilter.PostFilterUsage; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; +import ml.docilealligator.infinityforreddit.utils.Utils; import ml.docilealligator.infinityforreddit.videoautoplay.ExoCreator; import ml.docilealligator.infinityforreddit.videoautoplay.media.PlaybackInfo; import ml.docilealligator.infinityforreddit.videoautoplay.media.VolumeInfo; @@ -356,6 +360,34 @@ public class HistoryPostFragment extends PostFragmentBase implements FragmentCom view -> mAdapter.retry()))); } + @Override + public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) { + inflater.inflate(R.menu.history_post_fragment, menu); + for (int i = 0; i < menu.size(); i++) { + Utils.setTitleWithCustomFontToMenuItem(activity.typeface, menu.getItem(i), null); + } + lazyModeItem = menu.findItem(R.id.action_lazy_mode_history_post_fragment); + + if (isInLazyMode) { + Utils.setTitleWithCustomFontToMenuItem(activity.typeface, lazyModeItem, getString(R.string.action_stop_lazy_mode)); + } else { + Utils.setTitleWithCustomFontToMenuItem(activity.typeface, lazyModeItem, getString(R.string.action_start_lazy_mode)); + } + } + + @Override + public boolean onOptionsItemSelected(@NonNull MenuItem item) { + if (item.getItemId() == R.id.action_lazy_mode_history_post_fragment) { + if (isInLazyMode) { + stopLazyMode(); + } else { + startLazyMode(); + } + return true; + } + return false; + } + private void noPostFound() { hasPost = false; if (isInLazyMode) { -- cgit v1.2.3