From 0f500024a3b4196623dba9ef75e7f604bec32040 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Thu, 7 Mar 2019 19:01:30 -0500 Subject: Move viewpager page setup to adapter --- .../kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt index 1f96f076..458e97c9 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt @@ -32,6 +32,7 @@ import android.webkit.WebView import android.widget.FrameLayout import androidx.annotation.StringRes import androidx.coordinatorlayout.widget.CoordinatorLayout +import androidx.core.view.size import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentPagerAdapter import ca.allanwang.kau.searchview.SearchItem @@ -165,9 +166,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, onNestedCreate(savedInstanceState) L.i { "Main finished loading UI in ${System.currentTimeMillis() - start} ms" } launch { - val tabs = tabDao.selectAll() - adapter.setPages(tabs) - viewPager.offscreenPageLimit = tabs.size + adapter.setPages(tabDao.selectAll()) } controlWebview = WebView(this) if (BuildConfig.VERSION_CODE > Prefs.versionCode) { @@ -551,6 +550,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, } lastPosition = 0 viewPager.setCurrentItem(0, false) + viewPager.offscreenPageLimit = pages.size viewPager.post { if (!fragmentChannel.isClosedForSend) fragmentChannel.offer(0) -- cgit v1.2.3