mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-07 11:17:25 +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;
|
mAutoplay = autoplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAutoplay() {
|
||||||
|
return mAutoplay;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
|
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
|
||||||
super.onViewRecycled(holder);
|
super.onViewRecycled(holder);
|
||||||
|
@ -674,6 +674,11 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mAdapter != null && mAdapter.isAutoplay()) {
|
||||||
|
mAdapter.setAutoplay(false);
|
||||||
|
refreshAdapter();
|
||||||
|
}
|
||||||
|
|
||||||
isInLazyMode = true;
|
isInLazyMode = true;
|
||||||
isLazyModePaused = false;
|
isLazyModePaused = false;
|
||||||
|
|
||||||
@ -688,6 +693,14 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stopLazyMode() {
|
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;
|
isInLazyMode = false;
|
||||||
isLazyModePaused = false;
|
isLazyModePaused = false;
|
||||||
lazyModeRunnable.resetOldPosition();
|
lazyModeRunnable.resetOldPosition();
|
||||||
@ -700,6 +713,10 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
@Override
|
@Override
|
||||||
public void resumeLazyMode(boolean resumeNow) {
|
public void resumeLazyMode(boolean resumeNow) {
|
||||||
if (isInLazyMode) {
|
if (isInLazyMode) {
|
||||||
|
if (mAdapter != null && mAdapter.isAutoplay()) {
|
||||||
|
mAdapter.setAutoplay(false);
|
||||||
|
refreshAdapter();
|
||||||
|
}
|
||||||
isLazyModePaused = false;
|
isLazyModePaused = false;
|
||||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user