diff options
author | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2024-10-17 19:05:55 +0000 |
---|---|---|
committer | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2024-10-17 19:05:55 +0000 |
commit | 9e6139881bf8f72936cb1ae5c94f6512042260c7 (patch) | |
tree | b2a00d8d4bfdcfc91a8bb2bd185a07f07627a0ac /app/src | |
parent | 368ad6606f460f784994874c254789ada5a4fe20 (diff) | |
download | infinity-for-reddit-9e6139881bf8f72936cb1ae5c94f6512042260c7.tar infinity-for-reddit-9e6139881bf8f72936cb1ae5c94f6512042260c7.tar.gz infinity-for-reddit-9e6139881bf8f72936cb1ae5c94f6512042260c7.tar.bz2 infinity-for-reddit-9e6139881bf8f72936cb1ae5c94f6512042260c7.tar.lz infinity-for-reddit-9e6139881bf8f72936cb1ae5c94f6512042260c7.tar.xz infinity-for-reddit-9e6139881bf8f72936cb1ae5c94f6512042260c7.tar.zst infinity-for-reddit-9e6139881bf8f72936cb1ae5c94f6512042260c7.zip |
Lazy mode in HistoryPostFragment.
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/fragments/HistoryPostFragment.java | 32 | ||||
-rw-r--r-- | app/src/main/res/menu/history_post_fragment.xml | 8 |
2 files changed, 40 insertions, 0 deletions
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) { diff --git a/app/src/main/res/menu/history_post_fragment.xml b/app/src/main/res/menu/history_post_fragment.xml new file mode 100644 index 00000000..31fa8e8c --- /dev/null +++ b/app/src/main/res/menu/history_post_fragment.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<menu xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto"> + <item + android:id="@+id/action_lazy_mode_history_post_fragment" + android:orderInCategory="100" + app:showAsAction="never" /> +</menu>
\ No newline at end of file |