aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-05-12 12:22:29 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-05-12 12:22:29 +0000
commit8533a2bcca554e5e9603bbd846b6cde8e41e1084 (patch)
treece76670ce58a0605af19904e0ee5a3da0aa58d90 /app/src
parent9490c37a09e4c7920a5129974da7a0f40a84d75a (diff)
downloadinfinity-for-reddit-8533a2bcca554e5e9603bbd846b6cde8e41e1084.tar
infinity-for-reddit-8533a2bcca554e5e9603bbd846b6cde8e41e1084.tar.gz
infinity-for-reddit-8533a2bcca554e5e9603bbd846b6cde8e41e1084.tar.bz2
infinity-for-reddit-8533a2bcca554e5e9603bbd846b6cde8e41e1084.tar.lz
infinity-for-reddit-8533a2bcca554e5e9603bbd846b6cde8e41e1084.tar.xz
infinity-for-reddit-8533a2bcca554e5e9603bbd846b6cde8e41e1084.tar.zst
infinity-for-reddit-8533a2bcca554e5e9603bbd846b6cde8e41e1084.zip
Disable video autoply in lazy mode.
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java17
2 files changed, 21 insertions, 0 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
index 19df7a8c..9840d050 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
@@ -1305,6 +1305,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
mAutoplay = autoplay;
}
+ public boolean isAutoplay() {
+ return mAutoplay;
+ }
+
@Override
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
super.onViewRecycled(holder);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
index 9d058e3b..53dd904b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
@@ -674,6 +674,11 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
return false;
}
+ if (mAdapter != null && mAdapter.isAutoplay()) {
+ mAdapter.setAutoplay(false);
+ refreshAdapter();
+ }
+
isInLazyMode = true;
isLazyModePaused = false;
@@ -688,6 +693,14 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
@Override
public void stopLazyMode() {
+ if (mAdapter != null) {
+ String autoplayString = mSharedPreferences.getString(SharedPreferencesUtils.VIDEO_AUTOPLAY, SharedPreferencesUtils.VIDEO_AUTOPLAY_VALUE_NEVER);
+ if (autoplayString.equals(SharedPreferencesUtils.VIDEO_AUTOPLAY_VALUE_ALWAYS_ON) ||
+ (autoplayString.equals(SharedPreferencesUtils.VIDEO_AUTOPLAY_VALUE_ON_WIFI) && Utils.isConnectedToWifi(activity))) {
+ mAdapter.setAutoplay(true);
+ refreshAdapter();
+ }
+ }
isInLazyMode = false;
isLazyModePaused = false;
lazyModeRunnable.resetOldPosition();
@@ -700,6 +713,10 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
@Override
public void resumeLazyMode(boolean resumeNow) {
if (isInLazyMode) {
+ if (mAdapter != null && mAdapter.isAutoplay()) {
+ mAdapter.setAutoplay(false);
+ refreshAdapter();
+ }
isLazyModePaused = false;
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);