Fix crash on reselecting fragment (#339)

This commit is contained in:
Rafał Borcz 2019-05-15 15:11:29 +02:00 committed by Mikołaj Pich
parent d169f964f2
commit 0cb4eda32b
6 changed files with 6 additions and 9 deletions

View File

@ -103,7 +103,7 @@ class AttendanceFragment : BaseSessionFragment(), AttendanceView, MainView.MainC
}
override fun onFragmentReselected() {
presenter.onViewReselected()
if (::presenter.isInitialized) presenter.onViewReselected()
}
override fun popView() {

View File

@ -88,7 +88,7 @@ class ExamFragment : BaseSessionFragment(), ExamView, MainView.MainChildView, Ma
}
override fun onFragmentReselected() {
presenter.onViewReselected()
if (::presenter.isInitialized) presenter.onViewReselected()
}
override fun showEmpty(show: Boolean) {

View File

@ -88,7 +88,7 @@ class GradeFragment : BaseSessionFragment(), GradeView, MainView.MainChildView,
}
override fun onFragmentReselected() {
presenter.onViewReselected()
if (::presenter.isInitialized) presenter.onViewReselected()
}
override fun showContent(show: Boolean) {

View File

@ -5,7 +5,6 @@ import android.content.Intent
import android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
import android.os.Bundle
import android.os.Handler
import android.view.Menu
import android.view.MenuItem
import androidx.appcompat.app.AlertDialog
@ -165,9 +164,7 @@ class MainActivity : BaseActivity(), MainView {
}
override fun notifyMenuViewReselected() {
Handler().postDelayed({
(navController.currentStack?.get(0) as? MainView.MainChildView)?.onFragmentReselected()
}, 250)
(navController.currentStack?.getOrNull(0) as? MainView.MainChildView)?.onFragmentReselected()
}
fun showDialogFragment(dialog: DialogFragment) {

View File

@ -104,7 +104,7 @@ class MoreFragment : BaseFragment(), MoreView, MainView.TitledView, MainView.Mai
}
override fun onFragmentReselected() {
presenter.onViewReselected()
if (::presenter.isInitialized) presenter.onViewReselected()
}
override fun updateData(data: List<MoreItem>) {

View File

@ -110,7 +110,7 @@ class TimetableFragment : BaseSessionFragment(), TimetableView, MainView.MainChi
}
override fun onFragmentReselected() {
presenter.onViewReselected()
if (::presenter.isInitialized) presenter.onViewReselected()
}
override fun popView() {