mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-23 03:12:15 +00:00
Improve: No need to save layoutState
This commit is contained in:
parent
54719f28e7
commit
32baac8f98
@ -2,7 +2,6 @@ package com.looker.droidify.ui.appsList
|
||||
|
||||
import android.database.Cursor
|
||||
import android.os.Bundle
|
||||
import android.os.Parcelable
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@ -32,7 +31,6 @@ class AppListFragment() : BaseFragment(), CursorOwner.Callback {
|
||||
|
||||
companion object {
|
||||
private const val EXTRA_SOURCE = "source"
|
||||
private const val STATE_LAYOUT_MANAGER = "layoutManager"
|
||||
}
|
||||
|
||||
enum class Source(val titleResId: Int, val sections: Boolean, val order: Boolean) {
|
||||
@ -50,8 +48,6 @@ class AppListFragment() : BaseFragment(), CursorOwner.Callback {
|
||||
val source: Source
|
||||
get() = requireArguments().getString(EXTRA_SOURCE)!!.let(Source::valueOf)
|
||||
|
||||
private var layoutManagerState: Parcelable? = null
|
||||
|
||||
private var recyclerView: RecyclerView? = null
|
||||
|
||||
private var repositoriesDisposable: Disposable? = null
|
||||
@ -77,7 +73,6 @@ class AppListFragment() : BaseFragment(), CursorOwner.Callback {
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
layoutManagerState = savedInstanceState?.getParcelable(STATE_LAYOUT_MANAGER)
|
||||
|
||||
screenActivity.cursorOwner.attach(this, viewModel.request(source))
|
||||
repositoriesDisposable = Observable.just(Unit)
|
||||
@ -99,12 +94,6 @@ class AppListFragment() : BaseFragment(), CursorOwner.Callback {
|
||||
repositoriesDisposable = null
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
(layoutManagerState ?: recyclerView?.layoutManager?.onSaveInstanceState())
|
||||
?.let { outState.putParcelable(STATE_LAYOUT_MANAGER, it) }
|
||||
}
|
||||
|
||||
override fun onCursorData(request: CursorOwner.Request, cursor: Cursor?) {
|
||||
(recyclerView?.adapter as? AppListAdapter)?.apply {
|
||||
this.cursor = cursor
|
||||
@ -123,10 +112,6 @@ class AppListFragment() : BaseFragment(), CursorOwner.Callback {
|
||||
}
|
||||
}
|
||||
}
|
||||
layoutManagerState?.let {
|
||||
layoutManagerState = null
|
||||
recyclerView?.layoutManager?.onRestoreInstanceState(it)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun setSearchQuery(searchQuery: String) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user