always create a new list adapter to ensure proper scroll state
This commit is contained in:
parent
e41d5de4aa
commit
90c854dbf2
3 changed files with 21 additions and 24 deletions
|
@ -41,7 +41,7 @@ ext {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:3.6.3'
|
||||
implementation 'com.simplemobiletools:commons:3.6.11'
|
||||
|
||||
implementation files('../libs/RootTools.jar')
|
||||
|
||||
|
|
|
@ -261,7 +261,9 @@ class MainActivity : SimpleActivity() {
|
|||
if (!wasBackJustPressed) {
|
||||
wasBackJustPressed = true
|
||||
toast(R.string.press_back_again)
|
||||
Handler().postDelayed({ wasBackJustPressed = false }, BACK_PRESS_TIMEOUT.toLong())
|
||||
Handler().postDelayed({
|
||||
wasBackJustPressed = false
|
||||
}, BACK_PRESS_TIMEOUT.toLong())
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
|
@ -318,7 +320,9 @@ class MainActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
fun openedDirectory() {
|
||||
MenuItemCompat.collapseActionView(searchMenuItem)
|
||||
if (searchMenuItem != null) {
|
||||
MenuItemCompat.collapseActionView(searchMenuItem)
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkWhatsNewDialog() {
|
||||
|
|
|
@ -139,28 +139,21 @@ class ItemsFragment : Fragment(), ItemsAdapter.ItemOperationsListener, Breadcrum
|
|||
|
||||
mView.breadcrumbs.setBreadcrumb(currentPath)
|
||||
storedItems = items
|
||||
val currAdapter = items_list.adapter
|
||||
if (currAdapter == null) {
|
||||
ItemsAdapter(activity as SimpleActivity, storedItems, this@ItemsFragment, items_list, isPickMultipleIntent, items_fastscroller) {
|
||||
itemClicked(it as FileDirItem)
|
||||
}.apply {
|
||||
setupDragListener(true)
|
||||
addVerticalDividers(true)
|
||||
items_list.adapter = this
|
||||
}
|
||||
items_fastscroller.allowBubbleDisplay = context.config.showInfoBubble
|
||||
items_fastscroller.setViews(items_list, items_swipe_refresh) {
|
||||
items_fastscroller.updateBubbleText(storedItems.getOrNull(it)?.getBubbleText() ?: "")
|
||||
}
|
||||
} else {
|
||||
(currAdapter as ItemsAdapter).updateItems(storedItems)
|
||||
ItemsAdapter(activity as SimpleActivity, storedItems, this@ItemsFragment, items_list, isPickMultipleIntent, items_fastscroller) {
|
||||
itemClicked(it as FileDirItem)
|
||||
}.apply {
|
||||
setupDragListener(true)
|
||||
addVerticalDividers(true)
|
||||
items_list.adapter = this
|
||||
}
|
||||
items_fastscroller.allowBubbleDisplay = context.config.showInfoBubble
|
||||
items_fastscroller.setViews(items_list, items_swipe_refresh) {
|
||||
items_fastscroller.updateBubbleText(storedItems.getOrNull(it)?.getBubbleText() ?: "")
|
||||
}
|
||||
|
||||
val savedState = scrollStates[currentPath]
|
||||
if (savedState != null) {
|
||||
getRecyclerLayoutManager().onRestoreInstanceState(savedState)
|
||||
} else {
|
||||
getRecyclerLayoutManager().scrollToPosition(0)
|
||||
}
|
||||
getRecyclerLayoutManager().onRestoreInstanceState(scrollStates[currentPath])
|
||||
items_list.onGlobalLayout {
|
||||
items_fastscroller.setScrollTo(items_list.computeVerticalScrollOffset())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue