aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2020-02-23 18:17:52 -0800
committerGitHub <noreply@github.com>2020-02-23 18:17:52 -0800
commit78b972e104e96e2ffe7e48b8d9cad2c9d48c40d9 (patch)
tree761fc76615d657cc401b9becbeaeb8fc45cee6ef /app/src/main/kotlin/com
parent654cc6b943177120dc1a0a22a0d68d5cbfde2b5e (diff)
parentbfcef03d0ab960cd55e9fc5c097b12b5503d5d1f (diff)
downloadfrost-78b972e104e96e2ffe7e48b8d9cad2c9d48c40d9.tar.gz
frost-78b972e104e96e2ffe7e48b8d9cad2c9d48c40d9.tar.bz2
frost-78b972e104e96e2ffe7e48b8d9cad2c9d48c40d9.zip
Merge pull request #1649 from AllanWang/nullable-main-fragment
Allow currentFragment to be nullable
Diffstat (limited to 'app/src/main/kotlin/com')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt6
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt2
2 files changed, 4 insertions, 4 deletions
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 b22ef999..8d580ebd 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt
@@ -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) {
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
index e0053402..6522721d 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
@@ -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) {