Skip to content

Commit 0676f52

Browse files
committed
Fix bottom sheet state restoration using KTX doOnLayout
1 parent 72c8376 commit 0676f52

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Diff for: app/src/main/java/com/ricknout/rugbyranker/ui/rankings/RankingsFragment.kt

+8-5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import com.ricknout.rugbyranker.common.ui.SimpleTextWatcher
2929
import com.ricknout.rugbyranker.util.FlagUtils
3030
import androidx.core.content.getSystemService
3131
import androidx.core.os.bundleOf
32+
import androidx.core.view.doOnLayout
3233
import androidx.work.State
3334
import com.google.android.material.snackbar.Snackbar
3435
import com.ricknout.rugbyranker.vo.RankingsType
@@ -160,12 +161,14 @@ class RankingsFragment : DaggerFragment() {
160161
}
161162
})
162163
if (bottomSheetState != BOTTOM_SHEET_STATE_NONE) bottomSheetBehavior.state = bottomSheetState
163-
val slideOffset = when (bottomSheetBehavior.state) {
164-
BottomSheetBehavior.STATE_EXPANDED -> 1f
165-
BottomSheetBehavior.STATE_COLLAPSED -> 0f
166-
else -> -1f
164+
bottomSheet.doOnLayout {
165+
val slideOffset = when (bottomSheetBehavior.state) {
166+
BottomSheetBehavior.STATE_EXPANDED -> 1f
167+
BottomSheetBehavior.STATE_COLLAPSED -> 0f
168+
else -> -1f
169+
}
170+
updateAlphaForBottomSheetSlide(slideOffset, hasMatchResults(), isEditingMatchResult())
167171
}
168-
updateAlphaForBottomSheetSlide(slideOffset, hasMatchResults(), isEditingMatchResult())
169172
}
170173

171174
private fun setupAddOrEditMatchInput() {

0 commit comments

Comments
 (0)