[6.7.0][视角切换/蘑方状态展示] 细节优化
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 2.9 KiB |
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/iv"
|
||||
android:layout_width="@dimen/dp_51_5"
|
||||
android:layout_height="@dimen/dp_40_5" />
|
||||
android:layout_width="@dimen/dp_54"
|
||||
android:layout_height="@dimen/dp_54" />
|
||||
@@ -10,8 +10,7 @@ import android.view.LayoutInflater
|
||||
import android.view.MotionEvent
|
||||
import android.view.ViewConfiguration
|
||||
import android.view.animation.AccelerateDecelerateInterpolator
|
||||
import android.widget.LinearLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import android.widget.FrameLayout
|
||||
import com.mogo.eagle.core.function.angle.scenes.Default
|
||||
import com.mogo.eagle.core.function.angle.scenes.LongSight
|
||||
import com.mogo.eagle.core.function.api.map.angle.IMoGoVisualAngleChangeProvider
|
||||
@@ -20,27 +19,26 @@ import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.utilcode.kotlin.scope
|
||||
import kotlinx.android.synthetic.main.layout_visual_angle_toggle.view.iv_toggle_block
|
||||
import kotlinx.android.synthetic.main.layout_visual_angle_toggle.view.ll_visual_toggle
|
||||
import kotlinx.coroutines.launch
|
||||
import me.jessyan.autosize.utils.AutoSizeUtils
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.max
|
||||
|
||||
class VisualAngleToggleView : LinearLayout, IMoGoVisualAngleChangeProvider.OnMoGoVisualAngleSceneChangeListener {
|
||||
class VisualAngleToggleView : FrameLayout, IMoGoVisualAngleChangeProvider.OnMoGoVisualAngleSceneChangeListener {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "VisualAngleToggleView"
|
||||
}
|
||||
|
||||
constructor(context: Context?) : this(context, null)
|
||||
constructor(context: Context?, attrs: AttributeSet?) : this(context, attrs, 0)
|
||||
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
|
||||
orientation = VERTICAL
|
||||
constructor(context: Context) : this(context, null)
|
||||
constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
|
||||
isClickable = true
|
||||
LayoutInflater.from(context).inflate(R.layout.layout_visual_angle_toggle, this, true)
|
||||
val defaultSlop = AutoSizeUtils.dp2px(context, 12.0f)
|
||||
val scrollSlop = max(context?.let { ViewConfiguration.get(it).scaledTouchSlop } ?: defaultSlop, defaultSlop)
|
||||
val scrollSlop = max(context.let { ViewConfiguration.get(it).scaledTouchSlop }, defaultSlop)
|
||||
val gestureDetector = GestureDetector(context, object : GestureDetector.SimpleOnGestureListener() {
|
||||
|
||||
override fun onDown(e: MotionEvent): Boolean {
|
||||
return true
|
||||
}
|
||||
@@ -63,19 +61,16 @@ class VisualAngleToggleView : LinearLayout, IMoGoVisualAngleChangeProvider.OnMoG
|
||||
}
|
||||
})
|
||||
iv_toggle_block?.setOnTouchListener { _, event -> gestureDetector.onTouchEvent(event) }
|
||||
if (context != null) {
|
||||
background = ContextCompat.getDrawable(context, R.drawable.bg_visual_angle_toggle)
|
||||
}
|
||||
}
|
||||
|
||||
private fun moveToBottom() {
|
||||
if (iv_toggle_block?.tag == "0") {
|
||||
return
|
||||
}
|
||||
val start = if (iv_toggle_block?.tag == 1) AutoSizeUtils.dp2px(context, 185.0f) else AutoSizeUtils.dp2px(context, 109.0f)
|
||||
val start = if (iv_toggle_block?.tag == 1) AutoSizeUtils.dp2px(context, 180.0f) else AutoSizeUtils.dp2px(context, 103.0f)
|
||||
iv_toggle_block?.tag = "0"
|
||||
iv_toggle_block?.isEnabled = false
|
||||
val end = AutoSizeUtils.dp2px(context, 276.0f)
|
||||
val end = AutoSizeUtils.dp2px(context, 272.0f)
|
||||
val animator = ValueAnimator.ofInt(start, end)
|
||||
animator.addUpdateListener { l ->
|
||||
val current = l.animatedValue as? Int ?: 0
|
||||
@@ -85,6 +80,7 @@ class VisualAngleToggleView : LinearLayout, IMoGoVisualAngleChangeProvider.OnMoG
|
||||
override fun onAnimationStart(animation: Animator, isReverse: Boolean) {
|
||||
CallerVisualAngleManager.changeScene(Default())
|
||||
}
|
||||
|
||||
override fun onAnimationEnd(animation: Animator, isReverse: Boolean) {
|
||||
super.onAnimationEnd(animation, isReverse)
|
||||
iv_toggle_block?.isEnabled = true
|
||||
@@ -99,10 +95,10 @@ class VisualAngleToggleView : LinearLayout, IMoGoVisualAngleChangeProvider.OnMoG
|
||||
if (iv_toggle_block?.tag == "2") {
|
||||
return
|
||||
}
|
||||
val start = if (iv_toggle_block?.tag == 1) AutoSizeUtils.dp2px(context, 185.0f) else AutoSizeUtils.dp2px(context, 276.0f)
|
||||
val start = if (iv_toggle_block?.tag == 1) AutoSizeUtils.dp2px(context, 180.0f) else AutoSizeUtils.dp2px(context, 272.0f)
|
||||
iv_toggle_block?.tag = "2"
|
||||
iv_toggle_block?.isEnabled = false
|
||||
val end = AutoSizeUtils.dp2px(context, 109.0f)
|
||||
val end = AutoSizeUtils.dp2px(context, 103.0f)
|
||||
val animator = ValueAnimator.ofInt(start, end)
|
||||
animator.addUpdateListener { l ->
|
||||
val current = l.animatedValue as? Int ?: 0
|
||||
@@ -113,6 +109,7 @@ class VisualAngleToggleView : LinearLayout, IMoGoVisualAngleChangeProvider.OnMoG
|
||||
CallerVisualAngleManager.changeScene(LongSight())
|
||||
|
||||
}
|
||||
|
||||
override fun onAnimationEnd(animation: Animator, isReverse: Boolean) {
|
||||
iv_toggle_block?.isEnabled = true
|
||||
}
|
||||
@@ -126,10 +123,10 @@ class VisualAngleToggleView : LinearLayout, IMoGoVisualAngleChangeProvider.OnMoG
|
||||
if (iv_toggle_block?.tag == "1") {
|
||||
return
|
||||
}
|
||||
val start = if (iv_toggle_block?.tag == 2) AutoSizeUtils.dp2px(context, 109.0f) else AutoSizeUtils.dp2px(context, 276.0f)
|
||||
val start = if (iv_toggle_block?.tag == 2) AutoSizeUtils.dp2px(context, 103.0f) else AutoSizeUtils.dp2px(context, 272.0f)
|
||||
iv_toggle_block?.tag = "1"
|
||||
iv_toggle_block?.isEnabled = false
|
||||
val end = AutoSizeUtils.dp2px(context, 185.0f)
|
||||
val end = AutoSizeUtils.dp2px(context, 180.0f)
|
||||
val animator = ValueAnimator.ofInt(start, end)
|
||||
animator.addUpdateListener { l ->
|
||||
val current = l.animatedValue as? Int ?: 0
|
||||
@@ -153,8 +150,8 @@ class VisualAngleToggleView : LinearLayout, IMoGoVisualAngleChangeProvider.OnMoG
|
||||
override fun onSceneChanged(scene: Scene) {
|
||||
val isCanSwitch = scene.isCanSwitch()
|
||||
scope.launch {
|
||||
if (isCanSwitch != isEnabled) {
|
||||
isEnabled = isCanSwitch
|
||||
if (ll_visual_toggle?.isEnabled != isCanSwitch) {
|
||||
ll_visual_toggle?.isEnabled = isCanSwitch
|
||||
}
|
||||
if (iv_toggle_block?.isEnabled != isCanSwitch) {
|
||||
iv_toggle_block?.isEnabled = isCanSwitch
|
||||
|
||||
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 52 KiB |
@@ -13,8 +13,7 @@
|
||||
android:layout_height="@dimen/dp_64"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:scaleType="centerInside"
|
||||
android:layout_marginStart="@dimen/dp_3"
|
||||
android:layout_marginTop="@dimen/dp_48"
|
||||
android:layout_marginTop="@dimen/dp_45"
|
||||
android:tag="0"
|
||||
android:src="@drawable/icon_mofang_key_default" />
|
||||
|
||||
@@ -24,7 +23,6 @@
|
||||
android:layout_height="@dimen/dp_64"
|
||||
android:scaleType="centerInside"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginStart="@dimen/dp_3"
|
||||
android:layout_marginTop="@dimen/dp_6"
|
||||
android:tag="0"
|
||||
android:src="@drawable/icon_mofang_key_default" />
|
||||
@@ -35,7 +33,6 @@
|
||||
android:layout_height="@dimen/dp_64"
|
||||
android:scaleType="centerInside"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginStart="@dimen/dp_3"
|
||||
android:layout_marginTop="@dimen/dp_6"
|
||||
android:tag="0"
|
||||
android:src="@drawable/icon_mofang_key_default" />
|
||||
@@ -46,7 +43,6 @@
|
||||
android:layout_height="@dimen/dp_64"
|
||||
android:scaleType="centerInside"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginStart="@dimen/dp_3"
|
||||
android:layout_marginTop="@dimen/dp_6"
|
||||
android:tag="0"
|
||||
android:src="@drawable/icon_mofang_key_default" />
|
||||
@@ -57,7 +53,6 @@
|
||||
android:layout_height="@dimen/dp_64"
|
||||
android:scaleType="centerInside"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginStart="@dimen/dp_3"
|
||||
android:layout_marginTop="@dimen/dp_6"
|
||||
android:tag="0"
|
||||
android:src="@drawable/icon_mofang_key_default" />
|
||||
|
||||
@@ -1,19 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:background="@drawable/bg_visual_angle_toggle"
|
||||
tools:layout_height="wrap_content"
|
||||
tools:layout_width="wrap_content"
|
||||
tools:orientation="vertical"
|
||||
tools:parentTag="android.widget.LinearLayout">
|
||||
tools:parentTag="android.widget.FrameLayout">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_visual_toggle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:background="@drawable/bg_visual_angle_toggle"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_toggle_block"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_10"
|
||||
android:background="@drawable/bg_visual_angle_toggle_block"
|
||||
android:layout_marginTop="@dimen/dp_276"
|
||||
android:layout_marginTop="@dimen/dp_272"
|
||||
android:tag="0"
|
||||
tools:layout_marginTop="@dimen/dp_276" />
|
||||
tools:layout_marginTop="@dimen/dp_180" />
|
||||
</merge>
|
||||