forked from github/wulkanowy-mirror
Fix selected semester after change account (#1097)
This commit is contained in:
parent
f37ddfe00f
commit
e0b067fadd
@ -33,7 +33,6 @@ class GradeFragment : BaseFragment<FragmentGradeBinding>(R.layout.fragment_grade
|
||||
private var semesterSwitchMenu: MenuItem? = null
|
||||
|
||||
companion object {
|
||||
private const val SAVED_SEMESTER_KEY = "CURRENT_SEMESTER"
|
||||
|
||||
fun newInstance() = GradeFragment()
|
||||
}
|
||||
@ -52,7 +51,7 @@ class GradeFragment : BaseFragment<FragmentGradeBinding>(R.layout.fragment_grade
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
binding = FragmentGradeBinding.bind(view)
|
||||
presenter.onAttachView(this, savedInstanceState?.getInt(SAVED_SEMESTER_KEY))
|
||||
presenter.onAttachView(this)
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
@ -161,11 +160,6 @@ class GradeFragment : BaseFragment<FragmentGradeBinding>(R.layout.fragment_grade
|
||||
(pagerAdapter.getFragmentInstance(index) as? GradeView.GradeChildView)?.onParentChangeSemester()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
outState.putInt(SAVED_SEMESTER_KEY, presenter.selectedIndex)
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
presenter.onDetachView()
|
||||
super.onDestroyView()
|
||||
|
@ -21,8 +21,7 @@ class GradePresenter @Inject constructor(
|
||||
private val analytics: AnalyticsHelper
|
||||
) : BasePresenter<GradeView>(errorHandler, studentRepository) {
|
||||
|
||||
var selectedIndex = 0
|
||||
private set
|
||||
private var selectedIndex = 0
|
||||
|
||||
private var schoolYear = 0
|
||||
|
||||
@ -32,9 +31,8 @@ class GradePresenter @Inject constructor(
|
||||
|
||||
private lateinit var lastError: Throwable
|
||||
|
||||
fun onAttachView(view: GradeView, savedIndex: Int?) {
|
||||
override fun onAttachView(view: GradeView) {
|
||||
super.onAttachView(view)
|
||||
selectedIndex = savedIndex ?: 0
|
||||
view.initView()
|
||||
Timber.i("Grade view was initialized with $selectedIndex index")
|
||||
errorHandler.showErrorMessage = ::showErrorViewOnError
|
||||
|
Loading…
Reference in New Issue
Block a user