Reverse media order in ViewPager

Fixes #7354
This commit is contained in:
Moxie Marlinspike 2018-01-22 09:31:52 -08:00
parent be0ddb9756
commit 24e6605024
2 changed files with 3 additions and 8 deletions

View File

@ -460,11 +460,10 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im
View itemView = LayoutInflater.from(context).inflate(R.layout.media_view_page, container, false); View itemView = LayoutInflater.from(context).inflate(R.layout.media_view_page, container, false);
MediaView mediaView = itemView.findViewById(R.id.media_view); MediaView mediaView = itemView.findViewById(R.id.media_view);
boolean autoplay = position == autoPlayPosition; boolean autoplay = position == autoPlayPosition;
int cursorPosition = getCursorPosition(position);
autoPlayPosition = -1; autoPlayPosition = -1;
cursor.moveToPosition(cursorPosition); cursor.moveToPosition(position);
MediaRecord mediaRecord = MediaRecord.from(context, masterSecret, cursor); MediaRecord mediaRecord = MediaRecord.from(context, masterSecret, cursor);
@ -491,7 +490,7 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im
} }
public MediaItem getMediaItemFor(int position) { public MediaItem getMediaItemFor(int position) {
cursor.moveToPosition(getCursorPosition(position)); cursor.moveToPosition(position);
MediaRecord mediaRecord = MediaRecord.from(context, masterSecret, cursor); MediaRecord mediaRecord = MediaRecord.from(context, masterSecret, cursor);
Address address = mediaRecord.getAddress(); Address address = mediaRecord.getAddress();
@ -509,10 +508,6 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im
MediaView mediaView = mediaViews.get(position); MediaView mediaView = mediaViews.get(position);
if (mediaView != null) mediaView.pause(); if (mediaView != null) mediaView.pause();
} }
private int getCursorPosition(int position) {
return cursor.getCount() - 1 - position;
}
} }
private static class MediaItem { private static class MediaItem {

View File

@ -40,7 +40,7 @@ public class PagingMediaLoader extends AsyncLoader<Pair<Cursor, Integer>> {
Uri attachmentUri = PartAuthority.getAttachmentDataUri(attachmentId); Uri attachmentUri = PartAuthority.getAttachmentDataUri(attachmentId);
if (attachmentUri.equals(uri)) { if (attachmentUri.equals(uri)) {
return new Pair<>(cursor, cursor.getCount() - 1 - cursor.getPosition()); return new Pair<>(cursor, cursor.getPosition());
} }
} }