[6.7.0][Fix]解决右下角高德地图消失的问题
This commit is contained in:
@@ -7,6 +7,7 @@ import android.animation.ValueAnimator
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.util.AttributeSet
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.animation.AccelerateDecelerateInterpolator
|
||||
@@ -42,7 +43,9 @@ class MapContainerLayout @JvmOverloads constructor(
|
||||
private var maxMarginStart = 0
|
||||
private var maxMarginTop = 0
|
||||
|
||||
private var valueAnimator: ValueAnimator? = null
|
||||
private var zoomInAnimator: ValueAnimator? = null
|
||||
private var zoomOutAnimator: ValueAnimator? = null
|
||||
private val evaluator = IntEvaluator()
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_map_container, this, true)
|
||||
@@ -111,12 +114,17 @@ class MapContainerLayout @JvmOverloads constructor(
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
MogoMapListenerHandler.mogoMapListenerHandler.unregisterHostMapListener("${TAG}${this.hashCode()}")
|
||||
valueAnimator?.removeAllListeners()
|
||||
CallerDataCenterBizListener.removeListener("${TAG}${this.hashCode()}")
|
||||
zoomInAnimator?.removeListener(listenerAdapter)
|
||||
zoomOutAnimator?.removeListener(listenerAdapter)
|
||||
zoomInAnimator = null
|
||||
zoomOutAnimator = null
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
shadowView.setOnClickListener(object : OnPreventFastClickListener() {
|
||||
override fun onClickImpl(v: View?) {
|
||||
Log.d(TAG, "点击了shadowView按钮!")
|
||||
scaleMapWithAnim()
|
||||
}
|
||||
})
|
||||
@@ -136,48 +144,55 @@ class MapContainerLayout @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
private fun scaleMapWithAnim() {
|
||||
if (isPlayingAnim) return
|
||||
if (isPlayingAnim) {
|
||||
Log.d(TAG, "动画执行中,直接return")
|
||||
return
|
||||
}
|
||||
Log.d(TAG, "scaleMapWithAnim")
|
||||
if (mapMaxWidth == 0 && maxMarginStart == 0 && !isScaled) {
|
||||
calculate()
|
||||
}
|
||||
if (!isScaled) {
|
||||
valueAnimator = ValueAnimator.ofInt(mapMinWidth, mapMaxWidth)
|
||||
val evaluator = IntEvaluator()
|
||||
valueAnimator?.addUpdateListener {
|
||||
overMapView.layoutParams =
|
||||
(overMapView.layoutParams as LayoutParams).also { layoutParams ->
|
||||
layoutParams.width = it.animatedValue as Int
|
||||
layoutParams.height = evaluator.evaluate(it.animatedFraction, mapMinHeight, mapMaxHeight)
|
||||
layoutParams.leftMargin = evaluator.evaluate(it.animatedFraction, maxMarginStart, 0)
|
||||
layoutParams.topMargin = evaluator.evaluate(it.animatedFraction, maxMarginTop, 0)
|
||||
}
|
||||
if (zoomInAnimator == null) {
|
||||
zoomInAnimator = ValueAnimator.ofInt(mapMinWidth, mapMaxWidth)
|
||||
zoomInAnimator?.addUpdateListener {
|
||||
overMapView.layoutParams =
|
||||
(overMapView.layoutParams as LayoutParams).also { layoutParams ->
|
||||
layoutParams.width = it.animatedValue as Int
|
||||
layoutParams.height = evaluator.evaluate(it.animatedFraction, mapMinHeight, mapMaxHeight)
|
||||
layoutParams.leftMargin = evaluator.evaluate(it.animatedFraction, maxMarginStart, 0)
|
||||
layoutParams.topMargin = evaluator.evaluate(it.animatedFraction, maxMarginTop, 0)
|
||||
}
|
||||
}
|
||||
zoomInAnimator?.interpolator = AccelerateDecelerateInterpolator()
|
||||
zoomInAnimator?.addListener(listenerAdapter)
|
||||
zoomInAnimator?.duration = 400
|
||||
}
|
||||
valueAnimator?.interpolator = AccelerateDecelerateInterpolator()
|
||||
valueAnimator?.addListener(listenerAdapter)
|
||||
valueAnimator?.duration = 400
|
||||
valueAnimator?.start()
|
||||
zoomInAnimator?.start()
|
||||
} else {
|
||||
valueAnimator = ValueAnimator.ofInt(mapMaxWidth, mapMinWidth)
|
||||
val evaluator = IntEvaluator()
|
||||
valueAnimator?.addUpdateListener {
|
||||
overMapView.layoutParams =
|
||||
(overMapView.layoutParams as LayoutParams).also { layoutParams ->
|
||||
layoutParams.width = it.animatedValue as Int
|
||||
layoutParams.height = evaluator.evaluate(it.animatedFraction, mapMaxHeight, mapMinHeight)
|
||||
layoutParams.leftMargin = evaluator.evaluate(it.animatedFraction, 0, maxMarginStart)
|
||||
layoutParams.topMargin = evaluator.evaluate(it.animatedFraction, 0, maxMarginTop)
|
||||
}
|
||||
if (zoomOutAnimator == null) {
|
||||
zoomOutAnimator = ValueAnimator.ofInt(mapMaxWidth, mapMinWidth)
|
||||
zoomOutAnimator?.addUpdateListener {
|
||||
overMapView.layoutParams =
|
||||
(overMapView.layoutParams as LayoutParams).also { layoutParams ->
|
||||
layoutParams.width = it.animatedValue as Int
|
||||
layoutParams.height = evaluator.evaluate(it.animatedFraction, mapMaxHeight, mapMinHeight)
|
||||
layoutParams.leftMargin = evaluator.evaluate(it.animatedFraction, 0, maxMarginStart)
|
||||
layoutParams.topMargin = evaluator.evaluate(it.animatedFraction, 0, maxMarginTop)
|
||||
}
|
||||
}
|
||||
zoomOutAnimator?.interpolator = AccelerateDecelerateInterpolator()
|
||||
zoomOutAnimator?.addListener(listenerAdapter)
|
||||
zoomOutAnimator?.duration = 400
|
||||
}
|
||||
valueAnimator?.interpolator = AccelerateDecelerateInterpolator()
|
||||
valueAnimator?.addListener(listenerAdapter)
|
||||
valueAnimator?.duration = 400
|
||||
valueAnimator?.start()
|
||||
zoomOutAnimator?.start()
|
||||
}
|
||||
}
|
||||
|
||||
private val listenerAdapter = object : AnimatorListenerAdapter() {
|
||||
override fun onAnimationStart(animation: Animator) {
|
||||
super.onAnimationStart(animation)
|
||||
Log.d(TAG, "onAnimationStart")
|
||||
isPlayingAnim = true
|
||||
overMapView.setIsPlaying(true)
|
||||
overMapView.setMapFlag(isScaled)
|
||||
@@ -185,6 +200,7 @@ class MapContainerLayout @JvmOverloads constructor(
|
||||
|
||||
override fun onAnimationCancel(animation: Animator) {
|
||||
super.onAnimationCancel(animation)
|
||||
Log.d(TAG, "onAnimationCancel")
|
||||
isPlayingAnim = false
|
||||
overMapView.setIsPlaying(false)
|
||||
overMapView.swapSettings()
|
||||
@@ -200,6 +216,7 @@ class MapContainerLayout @JvmOverloads constructor(
|
||||
|
||||
override fun onAnimationEnd(animation: Animator) {
|
||||
super.onAnimationEnd(animation)
|
||||
Log.d(TAG, "onAnimationEnd")
|
||||
isPlayingAnim = false
|
||||
overMapView.setIsPlaying(false)
|
||||
overMapView.swapSettings()
|
||||
@@ -215,6 +232,7 @@ class MapContainerLayout @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
private fun updateShadowBg(isSmallMap: Boolean) {
|
||||
Log.d(TAG, "updateShadowBg")
|
||||
if (!isSmallMap) {
|
||||
shadowView.setBackgroundResource(R.drawable.gaojing_bg)
|
||||
} else {
|
||||
|
||||
@@ -335,6 +335,7 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
fun swapSettings() {
|
||||
Log.d(TAG, "swapSettings")
|
||||
if (isSmallMap) {
|
||||
Message.obtain().apply {
|
||||
what = CLEAR_ALL_DATA
|
||||
|
||||
Reference in New Issue
Block a user