Scroll to the current session when a Fragment is loaded
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
@@ -131,6 +131,9 @@ class BottomSheetDaySessionsFragment : DaggerFragment() {
?.startDayText ?: return@changed
binding.sessionsBottomSheetTitle.text = titleText
}
+ sessionPagesStore.firstLoadSessions.changed(viewLifecycleOwner) {
+ scrollToCurrentSession()
+ }
sessionPagesStore.filters.changed(viewLifecycleOwner) {
binding.isFiltered = it.isFiltered()
}

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
@@ -5,7 +5,9 @@ import androidx.lifecycle.MediatorLiveData
import androidx.lifecycle.ViewModel
import com.shopify.livedataktx.combineWith
import com.shopify.livedataktx.filter
+import com.shopify.livedataktx.first
import com.shopify.livedataktx.map
+import com.shopify.livedataktx.nonNull
import io.github.droidkaigi.confsched2019.action.Action
import io.github.droidkaigi.confsched2019.dispatcher.Dispatcher
import io.github.droidkaigi.confsched2019.ext.android.requireValue
@@ -125,6 +127,11 @@ class SessionPagesStore @Inject constructor(
.map { it.sessionPage }
.toSingleLiveData(SessionPage.pages[0])
+ val firstLoadSessions = filteredSessions
+ .nonNull()
+ .filter { it.isNotEmpty() }
+ .first()
+
fun filteredSessionsByDay(day: Int): LiveData<List<Session>> {
return filteredSessions
.map { sessions ->

Scroll to the current session when a Fragment is loaded