/*
* ModernAndroidPreferences Example Application
* Copyright (C) 2018 Max Rumpf alias Maxr1998
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package de.Maxr1998.modernpreferences.example
import android.os.Bundle
import de.Maxr1998.modernpreferences.PreferencesAdapter
class TestActivity : BaseActivity() {
override val preferencesAdapter = PreferencesAdapter()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
preferencesAdapter.setRootScreen(Common.createRootScreen(this))
// Restore adapter state from saved state
savedInstanceState?.getParcelable("adapter")
?.let(preferencesAdapter::loadSavedState)
preferencesAdapter.onScreenChangeListener = this
}
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
// Save the adapter state as a parcelable into the Android-managed instance state
outState.putParcelable("adapter", preferencesAdapter.getSavedState())
}
}