From 42a8522e9858d0729aaaf0222a0eb4efa815a3c6 Mon Sep 17 00:00:00 2001 From: Alan Evans Date: Thu, 2 May 2019 11:36:20 -0300 Subject: [PATCH] Manually call the onPageSelected when entering page 0. Fixes #7610 --- .../securesms/MediaPreviewActivity.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/org/thoughtcrime/securesms/MediaPreviewActivity.java b/src/org/thoughtcrime/securesms/MediaPreviewActivity.java index adf7a03617..a3a994cb54 100644 --- a/src/org/thoughtcrime/securesms/MediaPreviewActivity.java +++ b/src/org/thoughtcrime/securesms/MediaPreviewActivity.java @@ -36,8 +36,6 @@ import android.support.v4.util.Pair; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.support.v7.app.AlertDialog; -import org.thoughtcrime.securesms.logging.Log; - import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.GestureDetector; @@ -60,8 +58,9 @@ import org.thoughtcrime.securesms.components.viewpager.ExtendedOnPageChangedList import org.thoughtcrime.securesms.database.Address; import org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord; import org.thoughtcrime.securesms.database.loaders.PagingMediaLoader; -import org.thoughtcrime.securesms.mediapreview.MediaRailAdapter; +import org.thoughtcrime.securesms.logging.Log; import org.thoughtcrime.securesms.mediapreview.MediaPreviewViewModel; +import org.thoughtcrime.securesms.mediapreview.MediaRailAdapter; import org.thoughtcrime.securesms.mms.GlideApp; import org.thoughtcrime.securesms.mms.GlideRequests; import org.thoughtcrime.securesms.permissions.Permissions; @@ -111,6 +110,7 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im private boolean leftIsRecent; private GestureDetector clickDetector; private MediaPreviewViewModel viewModel; + private ViewPagerListener viewPagerListener; private int restartItem = -1; @@ -213,7 +213,9 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im private void initializeViews() { mediaPager = findViewById(R.id.media_pager); mediaPager.setOffscreenPageLimit(1); - mediaPager.addOnPageChangeListener(new ViewPagerListener()); + + viewPagerListener = new ViewPagerListener(); + mediaPager.addOnPageChangeListener(viewPagerListener); albumRail = findViewById(R.id.media_preview_album_rail); albumRailAdapter = new MediaRailAdapter(GlideApp.with(this), this, false); @@ -453,8 +455,12 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im viewModel.setCursor(this, data.first, leftIsRecent); - if (restartItem < 0) mediaPager.setCurrentItem(data.second); - else mediaPager.setCurrentItem(restartItem); + int item = restartItem >= 0 ? restartItem : data.second; + mediaPager.setCurrentItem(item); + + if (item == 0) { + viewPagerListener.onPageSelected(0); + } } }