mirror of
https://github.com/AllanWang/Frost-for-Facebook.git
synced 2024-11-08 12:02:33 +01:00
Allow currentFragment to be nullable
This commit is contained in:
parent
654cc6b943
commit
0498f26dc6
@ -791,7 +791,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
|
||||
return true
|
||||
}
|
||||
}
|
||||
if (currentFragment.onBackPressed()) return true
|
||||
if (currentFragment?.onBackPressed() == true) return true
|
||||
if (prefs.exitConfirmation) {
|
||||
materialDialog {
|
||||
title(R.string.kau_exit)
|
||||
@ -807,10 +807,10 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
|
||||
return false
|
||||
}
|
||||
|
||||
inline val currentFragment: BaseFragment
|
||||
inline val currentFragment: BaseFragment?
|
||||
get() {
|
||||
val viewpager = contentBinding.viewpager
|
||||
return supportFragmentManager.findFragmentByTag("android:switcher:${viewpager.id}:${viewpager.currentItem}") as BaseFragment
|
||||
return supportFragmentManager.findFragmentByTag("android:switcher:${viewpager.id}:${viewpager.currentItem}") as? BaseFragment
|
||||
}
|
||||
|
||||
override fun reloadFragment(fragment: BaseFragment) {
|
||||
|
@ -82,7 +82,7 @@ class MainActivity : BaseMainActivity() {
|
||||
tabs.addOnTabSelectedListener(object : TabLayout.ViewPagerOnTabSelectedListener(viewpager) {
|
||||
override fun onTabReselected(tab: TabLayout.Tab) {
|
||||
super.onTabReselected(tab)
|
||||
currentFragment.onTabClick()
|
||||
currentFragment?.onTabClick()
|
||||
}
|
||||
|
||||
override fun onTabSelected(tab: TabLayout.Tab) {
|
||||
|
Loading…
Reference in New Issue
Block a user