1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2025-01-07 10:42:07 +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 {
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);
}