For #3004 - Restore MotionLayout on Home View only in onCreateView
parent
fe3c163a20
commit
704f1e6a3d
|
@ -144,8 +144,14 @@ class HomeFragment : Fragment(), CoroutineScope, AccountObserver {
|
|||
}
|
||||
|
||||
postponeEnterTransition()
|
||||
|
||||
ActionBusFactory.get(this).logMergedObservables()
|
||||
val activity = activity as HomeActivity
|
||||
ThemeManager.applyStatusBarTheme(activity.window, activity.themeManager, activity)
|
||||
|
||||
val listener = object : ViewTreeObserver.OnPreDrawListener {
|
||||
override fun onPreDraw(): Boolean {
|
||||
restoreLayoutState()
|
||||
startPostponedEnterTransition()
|
||||
sessionControlComponent.view.viewTreeObserver.removeOnPreDrawListener(this)
|
||||
return true
|
||||
|
@ -153,13 +159,22 @@ class HomeFragment : Fragment(), CoroutineScope, AccountObserver {
|
|||
}
|
||||
sessionControlComponent.view.viewTreeObserver.addOnPreDrawListener(listener)
|
||||
|
||||
ActionBusFactory.get(this).logMergedObservables()
|
||||
val activity = activity as HomeActivity
|
||||
ThemeManager.applyStatusBarTheme(activity.window, activity.themeManager, activity)
|
||||
|
||||
return view
|
||||
}
|
||||
|
||||
private fun restoreLayoutState() {
|
||||
val homeViewModel = activity?.run {
|
||||
ViewModelProviders.of(this).get(HomeScreenViewModel::class.java)
|
||||
}
|
||||
homeViewModel?.layoutManagerState?.also { parcelable ->
|
||||
sessionControlComponent.view.layoutManager?.onRestoreInstanceState(parcelable)
|
||||
}
|
||||
val progress = homeViewModel?.motionLayoutProgress
|
||||
homeLayout?.progress =
|
||||
if (progress ?: 0F > MOTION_LAYOUT_PROGRESS_ROUND_POINT) 1.0f else 0f
|
||||
homeViewModel?.layoutManagerState = null
|
||||
}
|
||||
|
||||
@SuppressWarnings("LongMethod")
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
@ -250,7 +265,6 @@ class HomeFragment : Fragment(), CoroutineScope, AccountObserver {
|
|||
is SessionControlAction.Tab -> handleTabAction(it.action)
|
||||
is SessionControlAction.Collection -> handleCollectionAction(it.action)
|
||||
is SessionControlAction.Onboarding -> handleOnboardingAction(it.action)
|
||||
is SessionControlAction.ReloadData -> { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,7 +124,6 @@ sealed class SessionControlAction : Action {
|
|||
data class Tab(val action: TabAction) : SessionControlAction()
|
||||
data class Collection(val action: CollectionAction) : SessionControlAction()
|
||||
data class Onboarding(val action: OnboardingAction) : SessionControlAction()
|
||||
object ReloadData : SessionControlAction()
|
||||
}
|
||||
|
||||
fun Observer<SessionControlAction>.onNext(tabAction: TabAction) {
|
||||
|
|
|
@ -152,6 +152,5 @@ class SessionControlUIView(
|
|||
|
||||
override fun updateView() = Consumer<SessionControlState> {
|
||||
sessionControlAdapter.submitList(it.toAdapterList())
|
||||
actionEmitter.onNext(SessionControlAction.ReloadData)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
android:id="@+id/collections_header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="20dp">
|
||||
android:layout_marginBottom="8dp">
|
||||
|
||||
<View
|
||||
android:id="@+id/divider_line"
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
android:id="@+id/item_collection"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:background="@drawable/rounded_all_corners"
|
||||
android:clickable="true"
|
||||
android:clipToPadding="false"
|
||||
|
|
Loading…
Reference in New Issue