From da153b0ba35eeac366141badbddcbc7f941349c6 Mon Sep 17 00:00:00 2001 From: liujing Date: Sat, 20 Nov 2021 17:44:37 +0800 Subject: [PATCH] =?UTF-8?q?1.=E9=94=99=E8=AF=AFmsg=E5=91=88=E7=8E=B0=202.?= =?UTF-8?q?=E5=A4=9A=E4=BD=99=E5=8D=95=E5=85=83=E6=A0=BC=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E9=80=BB=E8=BE=91(=E9=80=82=E9=85=8DUI)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/gradle.xml | 3 +- .../check/VehicleMonitoringManager.kt | 28 ++++++++++------ .../check/api/ICheckResultCallBack.java | 2 ++ .../core/function/check/net/CheckNetWork.kt | 1 + .../function/check/view/CheckActivity.java | 12 +++++++ .../function/check/view/CheckAdapter.java | 33 +++++++++++++++++-- .../function/check/view/CheckInfoAdapter.java | 9 +++-- .../main/res/layout/check_info_adapter.xml | 4 +-- .../src/main/res/layout/check_list.xml | 2 +- .../module/main/service/MogoMainService.java | 2 +- 10 files changed, 75 insertions(+), 21 deletions(-) diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 3dda1fe044..cf5757e710 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -4,7 +4,7 @@ diff --git a/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/VehicleMonitoringManager.kt b/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/VehicleMonitoringManager.kt index 31d323f2a6..e7c6518596 100644 --- a/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/VehicleMonitoringManager.kt +++ b/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/VehicleMonitoringManager.kt @@ -2,11 +2,14 @@ package com.mogo.eagle.core.function.check import android.content.Context import android.content.Intent +import android.util.Log import com.alibaba.android.arouter.facade.annotation.Route +import com.mogo.eagle.core.data.constants.MogoServicePaths import com.mogo.eagle.core.function.api.check.ICheckProvider import com.mogo.eagle.core.function.api.check.IMogoCheckListener import com.mogo.eagle.core.function.check.api.ICheckResultCallBack -import com.mogo.eagle.core.function.check.net.CheckNetWork +import com.mogo.eagle.core.function.check.net.CheckNetWork.checkNetWork +import com.mogo.eagle.core.function.check.net.CheckResultData import com.mogo.eagle.core.function.check.view.CheckActivity import com.mogo.eagle.core.function.check.view.CheckDialog import com.mogo.eagle.core.utilcode.util.ActivityUtils @@ -14,7 +17,6 @@ import com.mogo.eagle.core.utilcode.util.AppUtils import com.mogo.eagle.core.utilcode.util.LogUtils import com.mogo.module.common.MogoApisHandler import com.mogo.module.service.receiver.MogoReceiver -import com.mogo.eagle.core.data.constants.MogoServicePaths import com.mogo.service.statusmanager.IMogoStatusChangedListener import com.mogo.service.statusmanager.StatusDescriptor import com.mogo.utils.ActivityLifecycleManager @@ -63,16 +65,22 @@ class VehicleMonitoringManager : ICheckProvider, IMogoStatusChangedListener { } override fun checkMonitor(context: Context) { - CheckNetWork.checkNetWork(context, ICheckResultCallBack { state -> - updateMonitoringStatus(MogoReceiver.ACTION_CHECK_VEHICLE_MONITORING, state.data.vehicle.state) - if (state.data.vehicle.state == 1) { - hasTipShow = false - } else { - if (!hasTipShow) { - showDialog(context) - hasTipShow = true //已弹框 + checkNetWork(context, object : ICheckResultCallBack { + override fun callBackWithCheckData(data: CheckResultData) { + updateMonitoringStatus(MogoReceiver.ACTION_CHECK_VEHICLE_MONITORING, data.data.vehicle.state) + if (data.data.vehicle.state == 1) { + hasTipShow = false + } else { + if (!hasTipShow) { + showDialog(context) + hasTipShow = true //已弹框 + } } } + + override fun callBackWithError(message: String, code: Int) { + + } }) } diff --git a/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/api/ICheckResultCallBack.java b/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/api/ICheckResultCallBack.java index 24a1e17378..2d630b7abf 100644 --- a/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/api/ICheckResultCallBack.java +++ b/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/api/ICheckResultCallBack.java @@ -9,4 +9,6 @@ import com.mogo.eagle.core.function.check.net.CheckResultData; */ public interface ICheckResultCallBack { void callBackWithCheckData(CheckResultData data); + + void callBackWithError(String message, int code); } diff --git a/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/net/CheckNetWork.kt b/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/net/CheckNetWork.kt index 80699fad92..026d8836ce 100644 --- a/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/net/CheckNetWork.kt +++ b/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/net/CheckNetWork.kt @@ -35,6 +35,7 @@ object CheckNetWork { override fun onError(message: String, code: Int) { super.onError(message, code) + ThreadUtils.runOnUiThread { callbackFlow?.callBackWithError(message,code) } } }) } 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 4e2c61f4aa..e02fbd27c8 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 @@ -101,15 +101,27 @@ public class CheckActivity extends AppCompatActivity { @Override public void run() { if (data != null && mCheckAdapter != null) { + mCheckAdapter.errorMsg = null; mCheckAdapter.mCheckResultData = data; mCheckAdapter.notifyDataSetChanged(); } } }); } + + @Override + public void callBackWithError(String message, int code) { + if (message != null) { + mCheckAdapter.errorMsg = message; + mCheckAdapter.notifyDataSetChanged(); + } + } }); + } + + /** * **************************************************************************************检测动画 */ 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 cb6589f6ae..cfbde3bc19 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 @@ -28,6 +28,7 @@ public class CheckAdapter extends RecyclerView.Adapter CheckResultData mCheckResultData; private Context mContext; CheckInfoListDialog mCheckInfoListDialog; + String errorMsg; public CheckAdapter(@NonNull Context context, @NonNull CheckResultData checkResult) { mContext = context; @@ -60,7 +61,7 @@ public class CheckAdapter extends RecyclerView.Adapter } public void dismissDialog() { - if (mCheckInfoListDialog!=null && mCheckInfoListDialog.isShowing()){ + if (mCheckInfoListDialog != null && mCheckInfoListDialog.isShowing()) { mCheckInfoListDialog.dismiss(); } } @@ -105,9 +106,14 @@ public class CheckAdapter extends RecyclerView.Adapter @Override public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { + if (errorMsg != null) { + errorMsgShow(holder, position); + } + if (mCheckResultData == null || mCheckResultData.getData() == null) { return; } + try { if (position == 0) { if (mCheckResultData.getData().getVehicle().getState() == 1) { @@ -130,7 +136,7 @@ public class CheckAdapter extends RecyclerView.Adapter } ((CheckListViewHolder) holder).iconAuto.setOnClickListener(v -> { Log.d(TAG, "硬件检测结果:"); - if (mCheckInfoListDialog != null){ + if (mCheckInfoListDialog != null) { mCheckInfoListDialog.dismiss(); } mCheckInfoListDialog = new CheckInfoListDialog(mContext, CheckItemInfo.CheckInfoStyle.CHECK_INFO_STYLE_DEVICES, mCheckResultData); @@ -150,7 +156,7 @@ public class CheckAdapter extends RecyclerView.Adapter } ((CheckListViewHolder) holder).iconAuto.setOnClickListener(v -> { Log.d(TAG, "系统检测结果:"); - if (mCheckInfoListDialog != null){ + if (mCheckInfoListDialog != null) { mCheckInfoListDialog.dismiss(); } mCheckInfoListDialog = new CheckInfoListDialog(mContext, CheckItemInfo.CheckInfoStyle.CHECK_INFO_STYLE_SOFT, mCheckResultData); @@ -163,6 +169,27 @@ public class CheckAdapter extends RecyclerView.Adapter } } + private void errorMsgShow(@NonNull RecyclerView.ViewHolder holder, int position) { + switch (position) { + case 0: + ((CheckTitleViewHolder) holder).mTextView.setText(errorMsg); + break; + case 1: + ((CheckListViewHolder) holder).viewTitle.setText("硬件检测:"); + ((CheckListViewHolder) holder).autoRiskState.setText(errorMsg); + ((CheckListViewHolder) holder).autoRiskState.setTextColor( + (mContext.getResources().getColor(R.color.check_icon_error_color))); + break; + case 2: + ((CheckListViewHolder) holder).viewTitle.setText("系统检测:"); + ((CheckListViewHolder) holder).autoRiskState.setText(errorMsg); + ((CheckListViewHolder) holder).autoRiskState.setTextColor( + (mContext.getResources().getColor(R.color.check_icon_error_color))); + break; + default: + } + } + @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/CheckInfoAdapter.java b/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/view/CheckInfoAdapter.java index 158bcaba3d..48dd8a96fe 100644 --- a/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/view/CheckInfoAdapter.java +++ b/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/view/CheckInfoAdapter.java @@ -29,8 +29,8 @@ public class CheckInfoAdapter extends RecyclerView.Adapter { //item类型 public static final int ITEM_TYPE_CONTENT = 0;//内容 public static final int ITEM_TYPE_BOTTOM = 1;//footer类型 - //底部View个数 - private int mBottomCount = 1; + //适配UI的空白表格 + private int mBottomCount = 0; public CheckInfoAdapter(Context context, String style, List checkResultData) { mContext = context; @@ -97,6 +97,11 @@ public class CheckInfoAdapter extends RecyclerView.Adapter { @Override public int getItemCount() { + if (isEven(showData.size())) { + mBottomCount = 0; + } else { + mBottomCount = 1; + } return showData.size() * 2 + mBottomCount; } diff --git a/core/function-impl/mogo-core-function-check/src/main/res/layout/check_info_adapter.xml b/core/function-impl/mogo-core-function-check/src/main/res/layout/check_info_adapter.xml index ef25c53440..e69ee94dc5 100644 --- a/core/function-impl/mogo-core-function-check/src/main/res/layout/check_info_adapter.xml +++ b/core/function-impl/mogo-core-function-check/src/main/res/layout/check_info_adapter.xml @@ -21,8 +21,7 @@ android:layout_width="@dimen/dp_40" android:layout_height="@dimen/dp_40" android:layout_marginRight="@dimen/dp_24" - android:layout_gravity="center" - android:src="@drawable/check_right" /> + android:layout_gravity="center" /> diff --git a/core/function-impl/mogo-core-function-check/src/main/res/layout/check_list.xml b/core/function-impl/mogo-core-function-check/src/main/res/layout/check_list.xml index dfea2f4c27..1f27d8e35e 100644 --- a/core/function-impl/mogo-core-function-check/src/main/res/layout/check_list.xml +++ b/core/function-impl/mogo-core-function-check/src/main/res/layout/check_list.xml @@ -64,7 +64,7 @@ android:layout_marginTop="@dimen/dp_20" android:gravity="center" android:text="连接异常" - android:textColor="@color/check_little_btn_green" + android:textColor="@color/check_icon_error_color" android:textSize="@dimen/dp_36" app:layout_constraintTop_toTopOf="@+id/icon_auto_title" /> diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/service/MogoMainService.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/service/MogoMainService.java index 0e41660838..56bec93b55 100644 --- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/service/MogoMainService.java +++ b/modules/mogo-module-main/src/main/java/com/mogo/module/main/service/MogoMainService.java @@ -55,7 +55,7 @@ class MogoMainService extends Service implements IMogoLocationListener { delayCheckUtil.waitingForCheck(); // 车辆检测 VehicleMonitoring monitoring = new VehicleMonitoring(this); - //monitoring.vehicleCheck(); + monitoring.vehicleCheck(); } @Nullable