mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-28 11:58:23 +01:00
Disable video autoply in lazy mode.
This commit is contained in:
parent
9490c37a09
commit
8533a2bcca
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user