From 2eaf8a8a01d69d0624b39b22460fedc5497ebfaf Mon Sep 17 00:00:00 2001 From: Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> Date: Sun, 13 Nov 2022 17:00:37 +1100 Subject: Show correct image in the gallery in ViewRedditGalleryActivity. --- .../infinityforreddit/activities/ViewRedditGalleryActivity.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java index e0350c63..1c4b8c04 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java @@ -169,14 +169,14 @@ public class ViewRedditGalleryActivity extends AppCompatActivity implements SetA haulerView.setDragEnabled(false); } - setupViewPager(); + setupViewPager(savedInstanceState); } public boolean isUseBottomAppBar() { return useBottomAppBar; } - private void setupViewPager() { + private void setupViewPager(Bundle savedInstanceState) { if (!useBottomAppBar) { setToolbarTitle(0); viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @@ -189,6 +189,9 @@ public class ViewRedditGalleryActivity extends AppCompatActivity implements SetA sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(sectionsPagerAdapter); viewPager.setOffscreenPageLimit(3); + if (savedInstanceState == null) { + viewPager.setCurrentItem(getIntent().getIntExtra(EXTRA_GALLERY_ITEM_INDEX, 0), false); + } } private void setToolbarTitle(int position) { -- cgit v1.2.3