Do not use a bundle and use a isFirstLoadScrolled flag
MODIFY
feature/session/src/main/java/io/github/droidkaigi/confsched2019/session/ui/BottomSheetDaySessionsFragment.kt
feature/session/src/main/java/io/github/droidkaigi/confsched2019/session/ui/BottomSheetDaySessionsFragment.kt
@@ -153,9 +153,10 @@ class BottomSheetDaySessionsFragment : DaggerFragment() {
}
}
- if (savedInstanceState == null) {
- sessionPagesStore.firstLoadSessions.observe(viewLifecycleOwner) {
+ sessionPagesStore.firstLoadSessions.changed(viewLifecycleOwner) {
+ if (!sessionPagesStore.isFirstLoadScrolled) {
scrollToCurrentSession()
+ sessionPagesStore.isFirstLoadScrolled = true
}
}
}

MODIFY
feature/session/src/main/java/io/github/droidkaigi/confsched2019/session/ui/store/SessionPagesStore.kt
feature/session/src/main/java/io/github/droidkaigi/confsched2019/session/ui/store/SessionPagesStore.kt
@@ -22,6 +22,8 @@ import javax.inject.Inject
class SessionPagesStore @Inject constructor(
dispatcher: Dispatcher
) : ViewModel() {
+ var isFirstLoadScrolled: Boolean = false
+
private val sessions: LiveData<List<Session>> = dispatcher
.subscribe<Action.SessionsLoaded>()
.map { it.sessions }

Do not use a bundle and use a isFirstLoadScrolled flag