add ui
@@ -30,6 +30,8 @@ import com.mogo.eagle.core.function.hmi.ui.notice.NoticeBannerView
|
||||
import com.mogo.eagle.core.function.hmi.ui.notice.NoticeNormalBannerView
|
||||
import com.mogo.eagle.core.function.hmi.ui.setting.DebugSettingView
|
||||
import com.mogo.eagle.core.function.hmi.ui.tools.AutoPilotAndCheckView
|
||||
import com.mogo.eagle.core.function.hmi.ui.turnlight.BrakeView
|
||||
import com.mogo.eagle.core.function.hmi.ui.turnlight.TurnLightView
|
||||
import com.mogo.eagle.core.function.hmi.ui.widget.V2XNotificationView
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
@@ -67,6 +69,7 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
|
||||
// 检测、自动驾驶速度设置
|
||||
private var toolsViewFloat: WarningFloat.Builder? = null
|
||||
|
||||
|
||||
override fun vipIdentification(visible: Boolean) {
|
||||
ThreadUtils.runOnUiThread {
|
||||
Logger.d(TAG, "vipIdentification")
|
||||
@@ -636,17 +639,27 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示转向灯效果
|
||||
* 显示转向灯效果 TODO
|
||||
*/
|
||||
override fun showTurnLight(light: Int) {
|
||||
turnLightView?.visibility = View.VISIBLE
|
||||
turnLightView.setTurnLight(light)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示刹车效果
|
||||
*/
|
||||
override fun showBrakeLight(brakeLight: Int) {
|
||||
|
||||
override fun showBrakeLight(light: Int) {
|
||||
brakeView?.visibility = View.VISIBLE
|
||||
brakeView.setBrakeLight(light)
|
||||
|
||||
// context?.let {
|
||||
// if (brakeLight == null) {
|
||||
// brakeLight = BrakeView(it)
|
||||
// brakeLight!!.setBrakeLight(light)
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.turnlight;
|
||||
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.animation.AlphaAnimation;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.mogo.eagle.core.function.hmi.R;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description 刹车
|
||||
* @since: 1/26/22
|
||||
*/
|
||||
public class BrakeView extends ConstraintLayout {
|
||||
|
||||
private LinearLayout brakeLayout;
|
||||
private ImageView imageBrake;
|
||||
private TextView tvBrake;
|
||||
private Context mContext;
|
||||
|
||||
public BrakeView(@NonNull Context context) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
LayoutInflater.from(context).inflate(R.layout.view_brake_light, this);
|
||||
initView();
|
||||
}
|
||||
|
||||
public BrakeView(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public BrakeView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
public BrakeView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
public void initView() {
|
||||
brakeLayout = findViewById(R.id.layout_brake);
|
||||
imageBrake = findViewById(R.id.image_brake);
|
||||
tvBrake = findViewById(R.id.tv_brake);
|
||||
}
|
||||
|
||||
/**
|
||||
* 刹车动画
|
||||
*/
|
||||
public void setBrakeLight(int brakeLight) {
|
||||
AlphaAnimation appearAnimation = new AlphaAnimation(0, 1f);
|
||||
appearAnimation.setDuration(300);
|
||||
|
||||
brakeLayout.startAnimation(appearAnimation);
|
||||
imageBrake.startAnimation(appearAnimation);
|
||||
tvBrake.startAnimation(appearAnimation);
|
||||
brakeLayout.setVisibility(View.VISIBLE);
|
||||
imageBrake.setVisibility(View.VISIBLE);
|
||||
tvBrake.setVisibility(View.VISIBLE);
|
||||
|
||||
if (brakeLight == 1) { //TODO 暂时还不知道数据
|
||||
|
||||
} else { //不踩刹车,就消失
|
||||
AlphaAnimation disappearAnimation = new AlphaAnimation(1, 0);
|
||||
disappearAnimation.setDuration(300);
|
||||
|
||||
scaleImageAndTv();
|
||||
|
||||
brakeLayout.startAnimation(disappearAnimation);
|
||||
imageBrake.startAnimation(disappearAnimation);
|
||||
tvBrake.startAnimation(disappearAnimation);
|
||||
brakeLayout.setVisibility(View.GONE);
|
||||
imageBrake.setVisibility(View.GONE);
|
||||
tvBrake.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void scaleImageAndTv() {
|
||||
AnimatorSet animatorSuofang = new AnimatorSet();//组合动画
|
||||
ObjectAnimator scaleX = ObjectAnimator.ofFloat(imageBrake, "scaleX", 1f, 1.3f);
|
||||
ObjectAnimator scaleY = ObjectAnimator.ofFloat(imageBrake, "scaleY", 1f, 1.3f);
|
||||
animatorSuofang.setDuration(200);
|
||||
animatorSuofang.setInterpolator(new DecelerateInterpolator());
|
||||
animatorSuofang.play(scaleX).with(scaleY);
|
||||
animatorSuofang.start();
|
||||
|
||||
ObjectAnimator scaleXTv = ObjectAnimator.ofFloat(tvBrake, "scaleX", 1f, 1.3f);
|
||||
ObjectAnimator scaleYTv = ObjectAnimator.ofFloat(tvBrake, "scaleY", 1f, 1.3f);
|
||||
animatorSuofang.setDuration(200);
|
||||
animatorSuofang.setInterpolator(new DecelerateInterpolator());
|
||||
animatorSuofang.play(scaleXTv).with(scaleYTv);
|
||||
animatorSuofang.start();
|
||||
}
|
||||
|
||||
private void stopAnimate() {
|
||||
tvBrake.clearAnimation();
|
||||
imageBrake.clearAnimation();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.turnlight;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.animation.AlphaAnimation;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.mogo.eagle.core.function.hmi.R;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description 顶部转向灯
|
||||
* @since: 1/26/22
|
||||
*/
|
||||
public class TurnLightView extends ConstraintLayout {
|
||||
|
||||
private FrameLayout mTurnLightBgLayout;
|
||||
private ImageView mLeftNormalImage, mLeftSelectImage;
|
||||
private ImageView mRightNormalImage, mRightSelectImage;
|
||||
private Context mContext;
|
||||
|
||||
public TurnLightView(@NonNull Context context) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
LayoutInflater.from(context).inflate(R.layout.view_turn_light, this);
|
||||
initView();
|
||||
}
|
||||
|
||||
public TurnLightView(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public TurnLightView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
public TurnLightView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
public void initView() {
|
||||
mTurnLightBgLayout = findViewById(R.id.turn_light_layout);
|
||||
mLeftNormalImage = findViewById(R.id.left_nor_image);
|
||||
mLeftSelectImage = findViewById(R.id.left_select_image);
|
||||
mRightNormalImage = findViewById(R.id.right_nor_image);
|
||||
mRightSelectImage = findViewById(R.id.right_select_image);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转向灯动画
|
||||
*/
|
||||
public void setTurnLight(int directionLight) {
|
||||
//显示背景
|
||||
AlphaAnimation appearAnimation = new AlphaAnimation(0, 1f);
|
||||
appearAnimation.setDuration(600);
|
||||
|
||||
AlphaAnimation appearAnimationImage = new AlphaAnimation(0, 1f);
|
||||
appearAnimation.setDuration(900);
|
||||
|
||||
mTurnLightBgLayout.startAnimation(appearAnimation);
|
||||
mLeftNormalImage.startAnimation(appearAnimationImage);
|
||||
mRightNormalImage.startAnimation(appearAnimationImage);
|
||||
mTurnLightBgLayout.setVisibility(View.VISIBLE);
|
||||
mLeftNormalImage.setVisibility(View.VISIBLE);
|
||||
mRightNormalImage.setVisibility(View.VISIBLE);
|
||||
|
||||
//根据左右进行显示和隐藏,实际要判断每个来的时间和频度 TODO
|
||||
if (directionLight == 1) { //左转向
|
||||
mLeftSelectImage.setVisibility(View.VISIBLE);
|
||||
mRightSelectImage.setVisibility(View.GONE);
|
||||
setAnimation(mLeftSelectImage);
|
||||
} else if (directionLight == 2) { //右转向
|
||||
mLeftSelectImage.setVisibility(View.GONE);
|
||||
mRightSelectImage.setVisibility(View.VISIBLE);
|
||||
setAnimation(mRightSelectImage);
|
||||
} else { //消失
|
||||
animationDisappear();
|
||||
}
|
||||
}
|
||||
|
||||
//消失动画,当转向等数据为空时候
|
||||
private void animationDisappear() {
|
||||
mLeftSelectImage.setVisibility(View.GONE);
|
||||
mRightSelectImage.setVisibility(View.GONE);
|
||||
|
||||
AlphaAnimation disappearAnimationLeft = new AlphaAnimation(1, 0);
|
||||
disappearAnimationLeft.setDuration(150);
|
||||
AlphaAnimation disappearAnimationBg = new AlphaAnimation(1, 0);
|
||||
disappearAnimationBg.setDuration(900);
|
||||
|
||||
mTurnLightBgLayout.startAnimation(disappearAnimationBg);
|
||||
mLeftNormalImage.startAnimation(disappearAnimationLeft);
|
||||
mRightNormalImage.startAnimation(disappearAnimationLeft);
|
||||
mTurnLightBgLayout.setVisibility(View.GONE);
|
||||
mLeftNormalImage.setVisibility(View.GONE);
|
||||
mRightNormalImage.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
//实现图片闪烁效果
|
||||
private void setAnimation(ImageView imageView) {
|
||||
AlphaAnimation animation = new AlphaAnimation(1, 0);
|
||||
|
||||
animation.setDuration(800);
|
||||
animation.setInterpolator(new LinearInterpolator());
|
||||
animation.setRepeatCount(Animation.INFINITE);
|
||||
animation.setRepeatMode(Animation.REVERSE);
|
||||
imageView.startAnimation(animation);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 5.2 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 5.2 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 30 KiB |
@@ -127,6 +127,29 @@
|
||||
app:layout_goneMarginTop="40px"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<!--左右转向灯-->
|
||||
<com.mogo.eagle.core.function.hmi.ui.turnlight.TurnLightView
|
||||
android:id="@+id/turnLightView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:layout_marginTop="42px" />
|
||||
|
||||
<!--刹车ui-->
|
||||
<com.mogo.eagle.core.function.hmi.ui.turnlight.BrakeView
|
||||
android:id="@+id/brakeView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="visible"
|
||||
tools:visibility="visible"
|
||||
android:background="#ffffff"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:layout_marginBottom="80px" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/layout_brake"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|center"
|
||||
android:layout_marginBottom="20px"
|
||||
android:background="@drawable/module_blank_nor"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="visible">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image_brake"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:src="@drawable/module_light_nor"
|
||||
android:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_brake"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="20px"
|
||||
android:text="刹车中"
|
||||
android:textColor="#ffffff"
|
||||
android:textSize="45px"
|
||||
android:visibility="visible" />
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/turn_light_layout"
|
||||
android:background="@drawable/module_turn_light_bg"
|
||||
android:layout_gravity="top|center_horizontal"
|
||||
android:visibility="visible"
|
||||
tools:visibility="visible"
|
||||
android:layout_marginTop="220px"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/left_nor_image"
|
||||
android:src="@drawable/module_arrow_left_nor"
|
||||
android:layout_gravity="left|center_vertical"
|
||||
android:layout_marginLeft="15px"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/right_nor_image"
|
||||
android:src="@drawable/module_arrow_right_nor"
|
||||
android:layout_gravity="right|center_vertical"
|
||||
android:layout_marginRight="15px"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/left_select_image"
|
||||
android:src="@drawable/module_arrow_left_select_nor"
|
||||
android:layout_gravity="left|center_vertical"
|
||||
android:layout_marginLeft="15px"
|
||||
android:layout_marginTop="3px"
|
||||
android:visibility="gone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/right_select_image"
|
||||
android:visibility="gone"
|
||||
android:src="@drawable/module_arrow_right_select_nor"
|
||||
android:layout_gravity="right|center_vertical"
|
||||
android:layout_marginRight="15px"
|
||||
android:layout_marginTop="3px"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
</FrameLayout>
|
||||