Skip to content

Commit

Permalink
Lazy mode in HistoryPostFragment.
Browse files Browse the repository at this point in the history
  • Loading branch information
Docile-Alligator committed Oct 17, 2024
1 parent 368ad66 commit 9e61398
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
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;

Expand Down Expand Up @@ -54,6 +57,7 @@
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;
Expand Down Expand Up @@ -356,6 +360,34 @@ private void bindPostViewModel() {
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) {
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/menu/history_post_fragment.xml
Original file line number Diff line number Diff line change
@@ -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>

0 comments on commit 9e61398

Please sign in to comment.