|
|
@ -120,11 +120,13 @@ class HomeFragment : Fragment(), AccountObserver {
|
|
|
|
|
|
|
|
|
|
|
|
private val preDrawListener = object : ViewTreeObserver.OnPreDrawListener {
|
|
|
|
private val preDrawListener = object : ViewTreeObserver.OnPreDrawListener {
|
|
|
|
override fun onPreDraw(): Boolean {
|
|
|
|
override fun onPreDraw(): Boolean {
|
|
|
|
viewLifecycleOwner.lifecycleScope.launch {
|
|
|
|
if (view != null) {
|
|
|
|
delay(ANIM_SCROLL_DELAY)
|
|
|
|
viewLifecycleOwner.lifecycleScope.launch {
|
|
|
|
restoreLayoutState()
|
|
|
|
delay(ANIM_SCROLL_DELAY)
|
|
|
|
|
|
|
|
restoreLayoutState()
|
|
|
|
// startPostponedEnterTransition()
|
|
|
|
// startPostponedEnterTransition()
|
|
|
|
}.invokeOnCompletion { sessionControlComponent.view.viewTreeObserver.removeOnPreDrawListener(this) }
|
|
|
|
}.invokeOnCompletion { sessionControlComponent.view.viewTreeObserver.removeOnPreDrawListener(this) }
|
|
|
|
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -753,37 +755,40 @@ class HomeFragment : Fragment(), AccountObserver {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private fun scrollAndAnimateCollection(tabsAddedToCollectionSize: Int, changedCollection: TabCollection? = null) {
|
|
|
|
private fun scrollAndAnimateCollection(tabsAddedToCollectionSize: Int, changedCollection: TabCollection? = null) {
|
|
|
|
viewLifecycleOwner.lifecycleScope.launch {
|
|
|
|
if (view != null) {
|
|
|
|
val recyclerView = sessionControlComponent.view
|
|
|
|
viewLifecycleOwner.lifecycleScope.launch {
|
|
|
|
delay(ANIM_SCROLL_DELAY)
|
|
|
|
val recyclerView = sessionControlComponent.view
|
|
|
|
val tabsSize = getListOfSessions().size
|
|
|
|
delay(ANIM_SCROLL_DELAY)
|
|
|
|
|
|
|
|
val tabsSize = getListOfSessions().size
|
|
|
|
var indexOfCollection = tabsSize + NON_TAB_ITEM_NUM
|
|
|
|
|
|
|
|
changedCollection?.let { changedCollection ->
|
|
|
|
var indexOfCollection = tabsSize + NON_TAB_ITEM_NUM
|
|
|
|
requireComponents.core.tabCollectionStorage.cachedTabCollections.filterIndexed { index, tabCollection ->
|
|
|
|
changedCollection?.let { changedCollection ->
|
|
|
|
if (tabCollection.id == changedCollection.id) {
|
|
|
|
requireComponents.core.tabCollectionStorage.cachedTabCollections
|
|
|
|
indexOfCollection = tabsSize + NON_TAB_ITEM_NUM + index
|
|
|
|
.filterIndexed { index, tabCollection ->
|
|
|
|
return@filterIndexed true
|
|
|
|
if (tabCollection.id == changedCollection.id) {
|
|
|
|
}
|
|
|
|
indexOfCollection = tabsSize + NON_TAB_ITEM_NUM + index
|
|
|
|
false
|
|
|
|
return@filterIndexed true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
false
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
val lastVisiblePosition =
|
|
|
|
val lastVisiblePosition =
|
|
|
|
(recyclerView.layoutManager as? LinearLayoutManager)?.findLastCompletelyVisibleItemPosition() ?: 0
|
|
|
|
(recyclerView.layoutManager as? LinearLayoutManager)?.findLastCompletelyVisibleItemPosition() ?: 0
|
|
|
|
if (lastVisiblePosition < indexOfCollection) {
|
|
|
|
if (lastVisiblePosition < indexOfCollection) {
|
|
|
|
val onScrollListener = object : RecyclerView.OnScrollListener() {
|
|
|
|
val onScrollListener = object : RecyclerView.OnScrollListener() {
|
|
|
|
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
|
|
|
|
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
|
|
|
|
super.onScrollStateChanged(recyclerView, newState)
|
|
|
|
super.onScrollStateChanged(recyclerView, newState)
|
|
|
|
if (newState == SCROLL_STATE_IDLE) {
|
|
|
|
if (newState == SCROLL_STATE_IDLE) {
|
|
|
|
animateCollection(tabsAddedToCollectionSize, indexOfCollection)
|
|
|
|
animateCollection(tabsAddedToCollectionSize, indexOfCollection)
|
|
|
|
recyclerView.removeOnScrollListener(this)
|
|
|
|
recyclerView.removeOnScrollListener(this)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
recyclerView.addOnScrollListener(onScrollListener)
|
|
|
|
|
|
|
|
recyclerView.smoothScrollToPosition(indexOfCollection)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
animateCollection(tabsAddedToCollectionSize, indexOfCollection)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
recyclerView.addOnScrollListener(onScrollListener)
|
|
|
|
|
|
|
|
recyclerView.smoothScrollToPosition(indexOfCollection)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
animateCollection(tabsAddedToCollectionSize, indexOfCollection)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|