1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2025-01-08 11:11:34 +00:00

Safeguard the buggy ViewPager (fixes #321) (#322)

This commit is contained in:
Catfriend1 2019-02-12 01:53:09 +01:00 committed by GitHub
parent 30efd903b5
commit e468f5a29c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -280,6 +280,7 @@ public class MainActivity extends SyncthingActivity
}; };
try { try {
mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setAdapter(mSectionsPagerAdapter);
mViewPager.setOffscreenPageLimit(numPages);
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
/** /**
* IllegalStateException happens due to a bug in FragmentStatePagerAdapter. * IllegalStateException happens due to a bug in FragmentStatePagerAdapter.
@ -294,7 +295,6 @@ public class MainActivity extends SyncthingActivity
.setPositiveButton(android.R.string.ok, (dialog, which) -> {}) .setPositiveButton(android.R.string.ok, (dialog, which) -> {})
.show(); .show();
} }
mViewPager.setOffscreenPageLimit(numPages);
TabLayout tabLayout = findViewById(R.id.tabContainer); TabLayout tabLayout = findViewById(R.id.tabContainer);
tabLayout.setupWithViewPager(mViewPager); tabLayout.setupWithViewPager(mViewPager);
} }