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