diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/EventListFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/EventListFragment.kt index 9ea09b5e5..d720681a5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/EventListFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/EventListFragment.kt @@ -3,6 +3,7 @@ package com.simplemobiletools.calendar.fragments import android.app.Activity import android.content.Intent import android.os.Bundle +import android.os.Parcelable import android.support.v4.app.Fragment import android.view.* import android.widget.AbsListView @@ -30,6 +31,7 @@ class EventListFragment : Fragment(), DBHelper.GetEventsListener, AdapterView.On var mSelectedItemsCnt = 0 var mListItems: ArrayList = ArrayList() var mAllEvents: MutableList? = null + var mState: Parcelable? = null lateinit var mToBeDeleted: MutableList lateinit var mView: View @@ -44,6 +46,11 @@ class EventListFragment : Fragment(), DBHelper.GetEventsListener, AdapterView.On checkEvents() } + override fun onPause() { + super.onPause() + mState = mView.calendar_events_list.onSaveInstanceState() + } + private fun checkEvents() { val fromTS = (DateTime().millis / 1000).toInt() val toTS = (DateTime().plusYears(1).millis / 1000).toInt() @@ -72,6 +79,9 @@ class EventListFragment : Fragment(), DBHelper.GetEventsListener, AdapterView.On adapter = eventsAdapter onItemClickListener = this@EventListFragment setMultiChoiceModeListener(this@EventListFragment) + + if (mState != null) + onRestoreInstanceState(mState) } checkPlaceholderVisibility() }