mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-02-05 21:04:18 +01:00
always create a new list adapter to ensure proper scroll state
This commit is contained in:
parent
e41d5de4aa
commit
90c854dbf2
@ -41,7 +41,7 @@ ext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.simplemobiletools:commons:3.6.3'
|
implementation 'com.simplemobiletools:commons:3.6.11'
|
||||||
|
|
||||||
implementation files('../libs/RootTools.jar')
|
implementation files('../libs/RootTools.jar')
|
||||||
|
|
||||||
|
@ -261,7 +261,9 @@ class MainActivity : SimpleActivity() {
|
|||||||
if (!wasBackJustPressed) {
|
if (!wasBackJustPressed) {
|
||||||
wasBackJustPressed = true
|
wasBackJustPressed = true
|
||||||
toast(R.string.press_back_again)
|
toast(R.string.press_back_again)
|
||||||
Handler().postDelayed({ wasBackJustPressed = false }, BACK_PRESS_TIMEOUT.toLong())
|
Handler().postDelayed({
|
||||||
|
wasBackJustPressed = false
|
||||||
|
}, BACK_PRESS_TIMEOUT.toLong())
|
||||||
} else {
|
} else {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
@ -318,8 +320,10 @@ class MainActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun openedDirectory() {
|
fun openedDirectory() {
|
||||||
|
if (searchMenuItem != null) {
|
||||||
MenuItemCompat.collapseActionView(searchMenuItem)
|
MenuItemCompat.collapseActionView(searchMenuItem)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun checkWhatsNewDialog() {
|
private fun checkWhatsNewDialog() {
|
||||||
arrayListOf<Release>().apply {
|
arrayListOf<Release>().apply {
|
||||||
|
@ -139,8 +139,6 @@ class ItemsFragment : Fragment(), ItemsAdapter.ItemOperationsListener, Breadcrum
|
|||||||
|
|
||||||
mView.breadcrumbs.setBreadcrumb(currentPath)
|
mView.breadcrumbs.setBreadcrumb(currentPath)
|
||||||
storedItems = items
|
storedItems = items
|
||||||
val currAdapter = items_list.adapter
|
|
||||||
if (currAdapter == null) {
|
|
||||||
ItemsAdapter(activity as SimpleActivity, storedItems, this@ItemsFragment, items_list, isPickMultipleIntent, items_fastscroller) {
|
ItemsAdapter(activity as SimpleActivity, storedItems, this@ItemsFragment, items_list, isPickMultipleIntent, items_fastscroller) {
|
||||||
itemClicked(it as FileDirItem)
|
itemClicked(it as FileDirItem)
|
||||||
}.apply {
|
}.apply {
|
||||||
@ -152,15 +150,10 @@ class ItemsFragment : Fragment(), ItemsAdapter.ItemOperationsListener, Breadcrum
|
|||||||
items_fastscroller.setViews(items_list, items_swipe_refresh) {
|
items_fastscroller.setViews(items_list, items_swipe_refresh) {
|
||||||
items_fastscroller.updateBubbleText(storedItems.getOrNull(it)?.getBubbleText() ?: "")
|
items_fastscroller.updateBubbleText(storedItems.getOrNull(it)?.getBubbleText() ?: "")
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
(currAdapter as ItemsAdapter).updateItems(storedItems)
|
|
||||||
|
|
||||||
val savedState = scrollStates[currentPath]
|
getRecyclerLayoutManager().onRestoreInstanceState(scrollStates[currentPath])
|
||||||
if (savedState != null) {
|
items_list.onGlobalLayout {
|
||||||
getRecyclerLayoutManager().onRestoreInstanceState(savedState)
|
items_fastscroller.setScrollTo(items_list.computeVerticalScrollOffset())
|
||||||
} else {
|
|
||||||
getRecyclerLayoutManager().scrollToPosition(0)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user