Skip to content

Commit

Permalink
fix road label position not updating in some cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Zayankovsky committed Oct 25, 2022
1 parent 8273101 commit 1509057
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Mapbox welcomes participation and contributions from everyone.
## Unreleased
#### Features
#### Bug fixes and improvements
- Fixed an issue with `NavigationView` that caused road label position to not update in some cases. [#6463](https://github.com/mapbox/mapbox-navigation-android/pull/6463)

## Mapbox Navigation SDK 2.9.0-beta.3 - 21 October, 2022
### Changelog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.mapbox.navigation.dropin.infopanel

import android.view.View
import android.view.ViewGroup
import android.view.ViewTreeObserver
import androidx.constraintlayout.widget.Guideline
import androidx.core.graphics.Insets
import androidx.core.view.ViewCompat
Expand Down Expand Up @@ -48,17 +49,17 @@ internal class InfoPanelCoordinator(

@OptIn(ExperimentalCoroutinesApi::class)
private val infoPanelTop = callbackFlow {
val onLayoutChangeListener = View.OnLayoutChangeListener { _, _, _, _, _, _, _, _, _ ->
val onGlobalLayoutListener = ViewTreeObserver.OnGlobalLayoutListener {
trySend(infoPanel.top)
}
val parent = infoPanel.parent as View
parent.addOnLayoutChangeListener(onLayoutChangeListener)
awaitClose { parent.removeOnLayoutChangeListener(onLayoutChangeListener) }
val viewTreeObserver = infoPanel.viewTreeObserver
viewTreeObserver.addOnGlobalLayoutListener(onGlobalLayoutListener)
awaitClose { viewTreeObserver.removeOnGlobalLayoutListener(onGlobalLayoutListener) }
}.distinctUntilChanged()

init {
infoPanel.addOnLayoutChangeListener(FixBottomSheetLayoutWhenHidden(infoPanel, behavior))
behavior.setPeekHeight(context.styles.infoPanelPeekHeight.value, true)
behavior.peekHeight = context.styles.infoPanelPeekHeight.value
behavior.hide()
}

Expand Down Expand Up @@ -94,7 +95,7 @@ internal class InfoPanelCoordinator(
}
}
coroutineScope.launch {
bottomSheetPeekHeight().collect { behavior.setPeekHeight(it, true) }
bottomSheetPeekHeight().collect { behavior.peekHeight = it }
}
coroutineScope.launch {
infoPanelTop.collect { updateGuidelinePosition() }
Expand Down

0 comments on commit 1509057

Please sign in to comment.