From 45c0cd41544a16eca06dfefdc9680bb80b6dc84c Mon Sep 17 00:00:00 2001 From: liujing Date: Fri, 24 Sep 2021 12:57:05 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E9=A1=B5=E9=9D=A2=E8=B5=8B?= =?UTF-8?q?=E5=80=BC,=E5=B7=AE=E4=BA=8C=E7=BA=A7=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E8=B5=8B=E5=80=BC=E5=92=8CUI=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../function/check/net/CheckResultData.java | 21 ++++++- .../function/check/view/CheckActivity.java | 46 +++++++------- .../function/check/view/CheckAdapter.java | 60 ++++++++++++------- .../check/view/CheckInfoGridItemDivider.java | 2 +- .../check/view/CheckInfoListDialog.java | 12 +++- .../src/main/res/layout/check_titel.xml | 8 +-- .../src/main/res/values/colors.xml | 1 + 7 files changed, 96 insertions(+), 54 deletions(-) diff --git a/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/net/CheckResultData.java b/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/net/CheckResultData.java index 1ecd01ae5a..3dfab31efe 100644 --- a/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/net/CheckResultData.java +++ b/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/net/CheckResultData.java @@ -42,8 +42,9 @@ public class CheckResultData extends BaseData { private Vehicle vehicle; private List soft; private List devices; + private Integer deviceState = 1;//硬件状态 + private Integer softState = 0;//系统(软件)状态 - // public Vehicle getVehicle() { return vehicle; } @@ -68,12 +69,30 @@ public class CheckResultData extends BaseData { this.devices = devices; } + public Integer getSoftState() { + return softState; + } + + public void setSoftState(Integer softState) { + this.softState = softState; + } + + public Integer getDeviceState() { + return deviceState; + } + + public void setDeviceState(Integer deviceState) { + this.deviceState = deviceState; + } + @Override public String toString() { return "Data{" + "vehicle=" + vehicle + ", soft=" + soft + ", devices=" + devices + + ", softState=" + softState + + ", deviceState=" + deviceState + '}'; } } diff --git a/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/view/CheckActivity.java b/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/view/CheckActivity.java index e57eb6562e..9292cd1797 100644 --- a/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/view/CheckActivity.java +++ b/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/view/CheckActivity.java @@ -33,6 +33,7 @@ import com.mogo.eagle.core.function.check.net.CheckResultData; import com.mogo.module.common.view.ImageViewClipBounds; import com.mogo.module.common.view.SpacesItemDecoration; import com.mogo.module.service.receiver.MogoReceiver; +import com.mogo.utils.TipToast; import com.mogo.utils.network.RequestOptions; import com.mogo.utils.network.utils.NetworkStatusUtil; @@ -51,8 +52,8 @@ import io.reactivex.schedulers.Schedulers; public class CheckActivity extends AppCompatActivity { private static final String TAG = "CheckActivity"; - private RecyclerView mRecyclerView; - private static ArrayList dataArrayList = new ArrayList(); + private static RecyclerView mRecyclerView; + private static CheckResultData sCheckResultData; private static Context context; private static NetworkStatusUtil.NetWorkStatus sNetWorkStatus; private ImageView mImageView; @@ -72,6 +73,7 @@ public class CheckActivity extends AppCompatActivity { //进度条 private ProgressBar mProgressBar; private final static long DURATION_TIME = 3000; + private static CheckAdapter mCheckAdapter; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { @@ -99,7 +101,6 @@ public class CheckActivity extends AppCompatActivity { animation(); checkMonitor(); mRecyclerView = findViewById(R.id.check_list); - mRecyclerView.setAdapter(new CheckAdapter(context, dataArrayList)); CheckLinearLayout linearLayoutManager = new CheckLinearLayout(this, CheckLinearLayout.VERTICAL, false); mRecyclerView.addItemDecoration(new SpacesItemDecoration((int) getResources().getDimension(R.dimen.check_item_space_vr))); @@ -110,12 +111,8 @@ public class CheckActivity extends AppCompatActivity { * 自动驾驶状态下指标监测 */ public static boolean checkMonitor() { - dataArrayList.clear(); Log.d(TAG, "checkMonitor"); loadDetail(); - //根据以上结果插入第一个元素(自动驾驶车辆是否存在风险) - topListTitle(); - CallerCheckManager.updateMonitoringStatus(MogoReceiver.ACTION_CHECK_VEHICLE_MONITORING, false); return true; } @@ -127,35 +124,35 @@ public class CheckActivity extends AppCompatActivity { CheckApiServiceFactory.getDataApiService(context).loadMonitorDetail(params) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) - .subscribe(new SubscribeImpl(RequestOptions.create(context)) { + .subscribe(new SubscribeImpl(RequestOptions.create(context)) { @Override - public void onSuccess(CheckResultData o) { + public void onSuccess(BaseData o) { super.onSuccess(o); Log.d(TAG, "车辆自检结果是:" + o.toString()); + if (o instanceof CheckResultData) { + sCheckResultData = (CheckResultData) o; + } + if (mCheckAdapter == null && sCheckResultData != null) { + mCheckAdapter = new CheckAdapter(context, sCheckResultData); + mRecyclerView.setAdapter(mCheckAdapter); + mCheckAdapter.notifyDataSetChanged(); + } + if (((CheckResultData) o).getData().getVehicle().getState() == 1) { + CallerCheckManager.updateMonitoringStatus(MogoReceiver.ACTION_CHECK_VEHICLE_MONITORING, true); + } else { + CallerCheckManager.updateMonitoringStatus(MogoReceiver.ACTION_CHECK_VEHICLE_MONITORING, false); + } } @Override public void onError(String message, int code) { - Log.d(TAG, "车辆自检失败:" + "message:" + message + "code:" + code); super.onError(message, code); + TipToast.shortTip("车辆自检失败,请稍后重试"); } }); } - /** - * 自动驾驶是否存在风险 - */ - private static void topListTitle() { - ArrayList list = new ArrayList(1); - CheckItemInfo info = new CheckItemInfo(); - info.setUsual(false); - info.setTitle("自动驾驶车辆存在风险"); - info.setStyle(CheckItemInfo.CheckAdapterStyleEnum.ITEM_TYPE_CHECK_TITLE); - list.add(info); - dataArrayList.add(0, list); - } - /** * @param context * @return 当前应用的版本名称 @@ -180,7 +177,7 @@ public class CheckActivity extends AppCompatActivity { ObjectAnimator animatorX = ObjectAnimator.ofFloat(scanLineImage, "translationX", scanBottomCarImage.getWidth(), 0); ObjectAnimator animatorAl = ObjectAnimator.ofFloat(scanLineImage, "alpha", 0, 1); setAnimation.playTogether(animatorX, animatorAl); - setAnimation.setDuration(200); + setAnimation.setDuration(800); setAnimation.start(); setAnimation.addListener(new AnimatorListenerAdapter() { @Override @@ -275,7 +272,6 @@ public class CheckActivity extends AppCompatActivity { @Override protected void onDestroy() { super.onDestroy(); - dataArrayList.clear(); } @Override diff --git a/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/view/CheckAdapter.java b/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/view/CheckAdapter.java index 2030839c76..2cfc7358cc 100644 --- a/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/view/CheckAdapter.java +++ b/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/view/CheckAdapter.java @@ -8,11 +8,13 @@ import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; +import androidx.annotation.CheckResult; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import com.mogo.eagle.core.function.check.R; import com.mogo.eagle.core.function.check.model.CheckItemInfo; +import com.mogo.eagle.core.function.check.net.CheckResultData; import java.util.ArrayList; @@ -26,15 +28,14 @@ public class CheckAdapter extends RecyclerView.Adapter private static final String TAG = "CheckActivity"; LayoutInflater mLayoutInflater; - ArrayList dataArrayList; + CheckResultData mCheckResultData; private Context mContext; private CheckInfoListDialog mCheckInfoListDialog; - public CheckAdapter(@NonNull Context context, @NonNull ArrayList checkArray) { + public CheckAdapter(@NonNull Context context, @NonNull CheckResultData checkResult) { mContext = context; mLayoutInflater = LayoutInflater.from(context); - dataArrayList = checkArray; - Log.d(TAG, dataArrayList.toString()); + mCheckResultData = checkResult; } @Override @@ -70,8 +71,8 @@ public class CheckAdapter extends RecyclerView.Adapter public CheckTitleViewHolder(@NonNull View itemView) { super(itemView); - errorImage = itemView.findViewById(R.id.error_tip_image); - mTextView = itemView.findViewById(R.id.error_title); + errorImage = itemView.findViewById(R.id.check_tip_image); + mTextView = itemView.findViewById(R.id.check_title); } } @@ -96,22 +97,50 @@ public class CheckAdapter extends RecyclerView.Adapter @Override public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { + if (mCheckResultData == null || mCheckResultData.getData() == null) { + Log.d(TAG, "onBindViewHolder 无数据或数据结构错误"); + return; + } try { if (position == 0) { - ((CheckTitleViewHolder) holder).errorImage.setImageResource(R.drawable.check_right); + if (mCheckResultData.getData().getVehicle().getState() == 1) { + ((CheckTitleViewHolder) holder).errorImage.setImageResource(R.drawable.check_right); + ((CheckTitleViewHolder) holder).mTextView.setText("车辆自检正常"); + } else { + ((CheckTitleViewHolder) holder).errorImage.setImageResource(R.drawable.check_wrong); + ((CheckTitleViewHolder) holder).mTextView.setText("车辆存在异常项"); + } } else if (position == 1) { ((CheckListViewHolder) holder).viewTitle.setText("硬件检测:"); + if (mCheckResultData.getData().getDeviceState() == 1) { + ((CheckListViewHolder) holder).autoRiskState.setTextColor( + (mContext.getResources().getColor(R.color.check_little_btn_green))); + ((CheckListViewHolder) holder).autoRiskState.setText("运行正常"); + } else { + ((CheckListViewHolder) holder).autoRiskState.setTextColor( + (mContext.getResources().getColor(R.color.check_icon_error_color))); + ((CheckListViewHolder) holder).autoRiskState.setText("存在异常项"); + } ((CheckListViewHolder) holder).iconAuto.setOnClickListener(v -> { Log.d(TAG, "硬件检测结果:"); - mCheckInfoListDialog = new CheckInfoListDialog(mContext); + mCheckInfoListDialog = new CheckInfoListDialog(mContext, "硬件自检结果"); mCheckInfoListDialog.show(); }); } else if (position == 2) { ((CheckListViewHolder) holder).viewTitle.setText("系统检测:"); + if (mCheckResultData.getData().getSoftState() == 1) { + ((CheckListViewHolder) holder).autoRiskState.setTextColor( + (mContext.getResources().getColor(R.color.check_little_btn_green))); + ((CheckListViewHolder) holder).autoRiskState.setText("运行正常"); + } else { + ((CheckListViewHolder) holder).autoRiskState.setTextColor( + (mContext.getResources().getColor(R.color.check_icon_error_color))); + ((CheckListViewHolder) holder).autoRiskState.setText("存在异常项"); + } ((CheckListViewHolder) holder).iconAuto.setOnClickListener(v -> { Log.d(TAG, "系统检测结果:"); - mCheckInfoListDialog = new CheckInfoListDialog(mContext); + mCheckInfoListDialog = new CheckInfoListDialog(mContext, "系统自检结果"); mCheckInfoListDialog.show(); }); } @@ -121,19 +150,6 @@ public class CheckAdapter extends RecyclerView.Adapter } } - - /** - * 硬件检测指标 - * - * @param list - */ - public void refreshHardware(@NonNull RecyclerView.ViewHolder holder, ArrayList list) { - if (list.size() > 0) { - CheckItemInfo info = (CheckItemInfo) list.get(0); - } - - } - @Override public int getItemCount() { return 3; diff --git a/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/view/CheckInfoGridItemDivider.java b/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/view/CheckInfoGridItemDivider.java index fbde44758d..cbc7bdf1ef 100644 --- a/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/view/CheckInfoGridItemDivider.java +++ b/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/view/CheckInfoGridItemDivider.java @@ -16,7 +16,7 @@ import androidx.recyclerview.widget.StaggeredGridLayoutManager; /** * @author liujing - * @description 描述 + * @description 网格布局网格绘制类 * @since: 9/22/21 */ public class CheckInfoGridItemDivider extends RecyclerView.ItemDecoration { diff --git a/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/view/CheckInfoListDialog.java b/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/view/CheckInfoListDialog.java index 0fc65015b1..592dde915a 100644 --- a/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/view/CheckInfoListDialog.java +++ b/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/view/CheckInfoListDialog.java @@ -2,6 +2,7 @@ package com.mogo.eagle.core.function.check.view; import android.content.Context; import android.graphics.Color; +import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.GridLayoutManager; @@ -19,12 +20,15 @@ public class CheckInfoListDialog extends BaseFloatDialog { private RecyclerView mRecyclerView; private Context mContext; + private TextView titleView; private int span; + private String mTitle; - public CheckInfoListDialog(@NonNull Context context) { + public CheckInfoListDialog(@NonNull Context context, String title) { super(context); mContext = context; + mTitle = title; initView(); } @@ -35,6 +39,8 @@ public class CheckInfoListDialog extends BaseFloatDialog { public void initView() { setContentView(R.layout.check_info_list); mRecyclerView = findViewById(R.id.check_list_recycler); + titleView = findViewById(R.id.check_info_title); + titleView.setText(mTitle); //网格布局 GridLayoutManager layoutManager = new GridLayoutManager(mContext, 4); mRecyclerView.setLayoutManager(layoutManager); @@ -57,4 +63,8 @@ public class CheckInfoListDialog extends BaseFloatDialog { super.dismiss(); } + @Override + public void dismiss() { + + } } diff --git a/core/function-impl/mogo-core-function-check/src/main/res/layout/check_titel.xml b/core/function-impl/mogo-core-function-check/src/main/res/layout/check_titel.xml index e226db0ae3..79a4bcba6a 100644 --- a/core/function-impl/mogo-core-function-check/src/main/res/layout/check_titel.xml +++ b/core/function-impl/mogo-core-function-check/src/main/res/layout/check_titel.xml @@ -9,7 +9,7 @@ android:layout_marginBottom="@dimen/dp_15"> + app:layout_constraintLeft_toRightOf="@+id/check_tip_image" + app:layout_constraintTop_toTopOf="@+id/check_tip_image" /> \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-check/src/main/res/values/colors.xml b/core/function-impl/mogo-core-function-check/src/main/res/values/colors.xml index 3d6008947a..aa4edb9c95 100644 --- a/core/function-impl/mogo-core-function-check/src/main/res/values/colors.xml +++ b/core/function-impl/mogo-core-function-check/src/main/res/values/colors.xml @@ -8,5 +8,6 @@ #997AFF87 #7AFF87 #242B59 + #EE3132 \ No newline at end of file