首页页面赋值,差二级页面赋值和UI优化
This commit is contained in:
@@ -42,8 +42,9 @@ public class CheckResultData extends BaseData {
|
||||
private Vehicle vehicle;
|
||||
private List<SoftItem> soft;
|
||||
private List<DevicesItem> 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 +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<CheckResultData>(RequestOptions.create(context)) {
|
||||
.subscribe(new SubscribeImpl<BaseData>(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
|
||||
|
||||
@@ -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<RecyclerView.ViewHolder>
|
||||
|
||||
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<RecyclerView.ViewHolder>
|
||||
|
||||
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<RecyclerView.ViewHolder>
|
||||
|
||||
@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<RecyclerView.ViewHolder>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 硬件检测指标
|
||||
*
|
||||
* @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;
|
||||
|
||||
@@ -16,7 +16,7 @@ import androidx.recyclerview.widget.StaggeredGridLayoutManager;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 描述
|
||||
* @description 网格布局网格绘制类
|
||||
* @since: 9/22/21
|
||||
*/
|
||||
public class CheckInfoGridItemDivider extends RecyclerView.ItemDecoration {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
android:layout_marginBottom="@dimen/dp_15">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/error_tip_image"
|
||||
android:id="@+id/check_tip_image"
|
||||
android:layout_width="@dimen/dp_140"
|
||||
android:layout_height="@dimen/dp_140"
|
||||
android:layout_marginStart="@dimen/dp_856"
|
||||
@@ -18,7 +18,7 @@
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/error_title"
|
||||
android:id="@+id/check_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/dp_65"
|
||||
@@ -26,6 +26,6 @@
|
||||
android:text="自动驾驶车辆存在风险"
|
||||
android:textColor="@color/module_commons_wm_dialog_text_textColor"
|
||||
android:textSize="@dimen/dp_64"
|
||||
app:layout_constraintLeft_toRightOf="@+id/error_tip_image"
|
||||
app:layout_constraintTop_toTopOf="@+id/error_tip_image" />
|
||||
app:layout_constraintLeft_toRightOf="@+id/check_tip_image"
|
||||
app:layout_constraintTop_toTopOf="@+id/check_tip_image" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -8,5 +8,6 @@
|
||||
<color name="check_little_btn_solid_green">#997AFF87</color>
|
||||
<color name="check_little_btn_green">#7AFF87</color>
|
||||
<color name="check_list_item_back">#242B59</color>
|
||||
<color name="check_icon_error_color">#EE3132</color>
|
||||
|
||||
</resources>
|
||||
Reference in New Issue
Block a user