remember the scrollstate of events list

This commit is contained in:
tibbi 2016-10-24 20:50:56 +02:00
parent db06fcd683
commit fbfe752f44
1 changed files with 10 additions and 0 deletions

View File

@ -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<ListItem> = ArrayList()
var mAllEvents: MutableList<Event>? = null
var mState: Parcelable? = null
lateinit var mToBeDeleted: MutableList<Int>
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()
}