From e468f5a29ce56968ac2df65eda259965ced9853a Mon Sep 17 00:00:00 2001 From: Catfriend1 Date: Tue, 12 Feb 2019 01:53:09 +0100 Subject: [PATCH] Safeguard the buggy ViewPager (fixes #321) (#322) --- .../com/nutomic/syncthingandroid/activities/MainActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/nutomic/syncthingandroid/activities/MainActivity.java b/app/src/main/java/com/nutomic/syncthingandroid/activities/MainActivity.java index efd66336..a6c11084 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/activities/MainActivity.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/activities/MainActivity.java @@ -280,6 +280,7 @@ public class MainActivity extends SyncthingActivity }; try { mViewPager.setAdapter(mSectionsPagerAdapter); + mViewPager.setOffscreenPageLimit(numPages); } catch (IllegalStateException e) { /** * IllegalStateException happens due to a bug in FragmentStatePagerAdapter. @@ -294,7 +295,6 @@ public class MainActivity extends SyncthingActivity .setPositiveButton(android.R.string.ok, (dialog, which) -> {}) .show(); } - mViewPager.setOffscreenPageLimit(numPages); TabLayout tabLayout = findViewById(R.id.tabContainer); tabLayout.setupWithViewPager(mViewPager); }