parent
975ec47adf
commit
fc847db389
1 changed files with 15 additions and 6 deletions
|
@ -21,13 +21,11 @@ import android.annotation.SuppressLint;
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.database.ContentObserver;
|
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
@ -557,9 +555,15 @@ public final class MediaPreviewActivity extends PassphraseRequiredActivity
|
||||||
|
|
||||||
int mediaPosition = Objects.requireNonNull(data.second);
|
int mediaPosition = Objects.requireNonNull(data.second);
|
||||||
|
|
||||||
CursorPagerAdapter adapter = new CursorPagerAdapter(getSupportFragmentManager(),this, cursor, mediaPosition, leftIsRecent);
|
CursorPagerAdapter oldAdapter = (CursorPagerAdapter) mediaPager.getAdapter();
|
||||||
mediaPager.setAdapter(adapter);
|
if (oldAdapter == null) {
|
||||||
adapter.setActive(true);
|
CursorPagerAdapter adapter = new CursorPagerAdapter(getSupportFragmentManager(), this, cursor, mediaPosition, leftIsRecent);
|
||||||
|
mediaPager.setAdapter(adapter);
|
||||||
|
adapter.setActive(true);
|
||||||
|
} else {
|
||||||
|
oldAdapter.setCursor(cursor, mediaPosition);
|
||||||
|
oldAdapter.setActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
viewModel.setCursor(this, cursor, leftIsRecent);
|
viewModel.setCursor(this, cursor, leftIsRecent);
|
||||||
|
|
||||||
|
@ -715,10 +719,10 @@ public final class MediaPreviewActivity extends PassphraseRequiredActivity
|
||||||
private final Map<Integer, MediaPreviewFragment> mediaFragments = new HashMap<>();
|
private final Map<Integer, MediaPreviewFragment> mediaFragments = new HashMap<>();
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
private final Cursor cursor;
|
|
||||||
private final boolean leftIsRecent;
|
private final boolean leftIsRecent;
|
||||||
|
|
||||||
private boolean active;
|
private boolean active;
|
||||||
|
private Cursor cursor;
|
||||||
private int autoPlayPosition;
|
private int autoPlayPosition;
|
||||||
|
|
||||||
CursorPagerAdapter(@NonNull FragmentManager fragmentManager,
|
CursorPagerAdapter(@NonNull FragmentManager fragmentManager,
|
||||||
|
@ -739,6 +743,11 @@ public final class MediaPreviewActivity extends PassphraseRequiredActivity
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCursor(@NonNull Cursor cursor, int autoPlayPosition) {
|
||||||
|
this.cursor = cursor;
|
||||||
|
this.autoPlayPosition = autoPlayPosition;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
if (!active) return 0;
|
if (!active) return 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue