赋值,差:滑动卡顿;W/System.err: 待解决
This commit is contained in:
@@ -126,6 +126,11 @@ public class CheckItemInfo implements Serializable {
|
||||
int ITEM_TYPE_CHECK_LIST = 1;
|
||||
int ITEM_TYPE_CHECK_IMAGE = 2;
|
||||
}
|
||||
|
||||
public interface CheckInfoStyle {
|
||||
String CHECK_INFO_STYLE_DEVICES = "devices";
|
||||
String CHECK_INFO_STYLE_SOFT = "soft";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -40,8 +40,8 @@ public class CheckResultData extends BaseData {
|
||||
|
||||
public static class Data {
|
||||
private Vehicle vehicle;
|
||||
private List<SoftItem> soft;
|
||||
private List<DevicesItem> devices;
|
||||
private List<CheckListItem> soft;
|
||||
private List<CheckListItem> devices;
|
||||
private Integer deviceState = 1;//硬件状态
|
||||
private Integer softState = 0;//系统(软件)状态
|
||||
|
||||
@@ -53,19 +53,19 @@ public class CheckResultData extends BaseData {
|
||||
this.vehicle = vehicle;
|
||||
}
|
||||
|
||||
public List<SoftItem> getSoft() {
|
||||
public List<CheckListItem> getSoft() {
|
||||
return soft;
|
||||
}
|
||||
|
||||
public void setSoft(List<SoftItem> soft) {
|
||||
public void setSoft(List<CheckListItem> soft) {
|
||||
this.soft = soft;
|
||||
}
|
||||
|
||||
public List<DevicesItem> getDevices() {
|
||||
public List<CheckListItem> getDevices() {
|
||||
return devices;
|
||||
}
|
||||
|
||||
public void setDevices(List<DevicesItem> devices) {
|
||||
public void setDevices(List<CheckListItem> devices) {
|
||||
this.devices = devices;
|
||||
}
|
||||
|
||||
@@ -236,10 +236,10 @@ public class CheckResultData extends BaseData {
|
||||
}
|
||||
}
|
||||
|
||||
public static class SoftItem {
|
||||
public static class CheckListItem {
|
||||
private String name;
|
||||
private String stateValue;
|
||||
private List<ItemClass> items;
|
||||
private List items;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
@@ -257,11 +257,11 @@ public class CheckResultData extends BaseData {
|
||||
this.stateValue = stateValue;
|
||||
}
|
||||
|
||||
public List<ItemClass> getItems() {
|
||||
public List getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public void setItems(List<ItemClass> items) {
|
||||
public void setItems(List items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
@@ -275,83 +275,4 @@ public class CheckResultData extends BaseData {
|
||||
}
|
||||
}
|
||||
|
||||
public static class DevicesItem {
|
||||
private String name;
|
||||
private String stateValue;
|
||||
private ArrayList<ItemClass> items;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Object getStateValue() {
|
||||
return stateValue;
|
||||
}
|
||||
|
||||
public void setStateValue(String stateValue) {
|
||||
this.stateValue = stateValue;
|
||||
}
|
||||
|
||||
public ArrayList<ItemClass> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public void setItems(ArrayList<ItemClass> items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "devices{" +
|
||||
"name='" + name + '\'' +
|
||||
", stateValue=" + stateValue +
|
||||
", items=" + items +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class ItemClass {
|
||||
private String name;
|
||||
private String stateValue;
|
||||
private ArrayList items;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Object getStateValue() {
|
||||
return stateValue;
|
||||
}
|
||||
|
||||
public void setStateValue(String stateValue) {
|
||||
this.stateValue = stateValue;
|
||||
}
|
||||
|
||||
public ArrayList getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public void setItems(ArrayList items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "softItem{" +
|
||||
"name='" + name + '\'' +
|
||||
", stateValue=" + stateValue +
|
||||
", items=" + items +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ 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.CheckApiServiceFactory;
|
||||
import com.mogo.eagle.core.function.check.net.CheckResultData;
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
|
||||
import com.mogo.module.common.view.ImageViewClipBounds;
|
||||
import com.mogo.module.common.view.SpacesItemDecoration;
|
||||
import com.mogo.module.service.receiver.MogoReceiver;
|
||||
@@ -99,7 +100,7 @@ public class CheckActivity extends AppCompatActivity {
|
||||
finish();
|
||||
});
|
||||
animation();
|
||||
checkMonitor();
|
||||
loadDetail();
|
||||
mRecyclerView = findViewById(R.id.check_list);
|
||||
CheckLinearLayout linearLayoutManager =
|
||||
new CheckLinearLayout(this, CheckLinearLayout.VERTICAL, false);
|
||||
@@ -131,15 +132,21 @@ public class CheckActivity extends AppCompatActivity {
|
||||
public void onSuccess(CheckResultData o) {
|
||||
super.onSuccess(o);
|
||||
Log.d(TAG, "车辆自检结果是:" + o.toString());
|
||||
if (o != null){
|
||||
mCheckAdapter.mCheckResultData = o;
|
||||
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);
|
||||
}
|
||||
ThreadUtils.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (o != null && mCheckAdapter != null) {
|
||||
mCheckAdapter.mCheckResultData = o;
|
||||
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
|
||||
|
||||
@@ -125,7 +125,7 @@ public class CheckAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
if (mCheckInfoListDialog != null){
|
||||
mCheckInfoListDialog.dismiss();
|
||||
}
|
||||
mCheckInfoListDialog = new CheckInfoListDialog(mContext, "硬件自检结果", mCheckResultData);
|
||||
mCheckInfoListDialog = new CheckInfoListDialog(mContext, CheckItemInfo.CheckInfoStyle.CHECK_INFO_STYLE_DEVICES, mCheckResultData);
|
||||
mCheckInfoListDialog.show();
|
||||
|
||||
});
|
||||
@@ -142,7 +142,10 @@ public class CheckAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
}
|
||||
((CheckListViewHolder) holder).iconAuto.setOnClickListener(v -> {
|
||||
Log.d(TAG, "系统检测结果:");
|
||||
mCheckInfoListDialog = new CheckInfoListDialog(mContext, "系统自检结果", mCheckResultData);
|
||||
if (mCheckInfoListDialog != null){
|
||||
mCheckInfoListDialog.dismiss();
|
||||
}
|
||||
mCheckInfoListDialog = new CheckInfoListDialog(mContext, CheckItemInfo.CheckInfoStyle.CHECK_INFO_STYLE_SOFT, mCheckResultData);
|
||||
mCheckInfoListDialog.show();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.eagle.core.function.check.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -11,9 +12,11 @@ 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 org.w3c.dom.Text;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
@@ -21,12 +24,16 @@ import org.w3c.dom.Text;
|
||||
* @since: 9/23/21
|
||||
*/
|
||||
public class CheckInfoAdapter extends RecyclerView.Adapter {
|
||||
private static final String TAG = "CheckInfoAdapter";
|
||||
LayoutInflater mLayoutInflater;
|
||||
private Context mContext;
|
||||
private CheckResultData mCheckResultData;
|
||||
private String mStyle;
|
||||
private List result = new ArrayList<>();
|
||||
|
||||
public CheckInfoAdapter(Context context, CheckResultData checkResultData) {
|
||||
public CheckInfoAdapter(Context context, String style, CheckResultData checkResultData) {
|
||||
mContext = context;
|
||||
mStyle = style;
|
||||
mCheckResultData = checkResultData;
|
||||
mLayoutInflater = LayoutInflater.from(context);
|
||||
}
|
||||
@@ -50,14 +57,62 @@ public class CheckInfoAdapter extends RecyclerView.Adapter {
|
||||
((CheckInfoViewHolder) holder).checkIcon.setVisibility(View.GONE);
|
||||
((CheckInfoViewHolder) holder).mTextView.setText("运行状态");
|
||||
} else {
|
||||
|
||||
try {
|
||||
if ((position - 4) < result.size()) {
|
||||
CheckResultData.CheckListItem item = (CheckResultData.CheckListItem) result.get(position - 4);
|
||||
if (isEven(position) == true) {//偶数隐藏图片显示检测指标
|
||||
((CheckInfoViewHolder) holder).checkIcon.setVisibility(View.GONE);
|
||||
((CheckInfoViewHolder) holder).mTextView.setText(item.getName());
|
||||
} else {//奇数显示图片和检测指标结果
|
||||
((CheckInfoViewHolder) holder).checkIcon.setVisibility(View.VISIBLE);
|
||||
String state = (String) item.getStateValue();
|
||||
if (state.equals("1")) {
|
||||
((CheckInfoViewHolder) holder).mTextView.setText("正常");
|
||||
((CheckInfoViewHolder) holder).checkIcon.setImageResource(R.drawable.check_right);
|
||||
} else if ((state.equals("0"))) {
|
||||
((CheckInfoViewHolder) holder).mTextView.setText("异常");
|
||||
((CheckInfoViewHolder) holder).checkIcon.setImageResource(R.drawable.check_wrong);
|
||||
} else {
|
||||
((CheckInfoViewHolder) holder).mTextView.setText(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean isEven(int position) {
|
||||
if (position % 2 == 0) {
|
||||
System.out.println("偶数");
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 10;
|
||||
List<CheckResultData.CheckListItem> checkListResult = new ArrayList();
|
||||
try {
|
||||
if (mStyle.equals(CheckItemInfo.CheckInfoStyle.CHECK_INFO_STYLE_DEVICES)) {
|
||||
checkListResult = mCheckResultData.getData().getDevices();
|
||||
} else {
|
||||
checkListResult = mCheckResultData.getData().getSoft();
|
||||
}
|
||||
for (CheckResultData.CheckListItem item : checkListResult) {
|
||||
result.addAll(checkListResult);
|
||||
if (item.getItems() != null) {
|
||||
result.addAll(item.getItems());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Log.d(TAG, "getItemCount 检测指标结果值===" + result.toString());
|
||||
return result.size() + 4;
|
||||
}
|
||||
|
||||
public class CheckInfoViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
@@ -9,12 +9,13 @@ import androidx.recyclerview.widget.GridLayoutManager;
|
||||
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 com.mogo.module.common.dialog.BaseFloatDialog;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 描述
|
||||
* @description 检测指标详情弹框
|
||||
* @since: 9/22/21
|
||||
*/
|
||||
public class CheckInfoListDialog extends BaseFloatDialog {
|
||||
@@ -23,14 +24,14 @@ public class CheckInfoListDialog extends BaseFloatDialog {
|
||||
private Context mContext;
|
||||
private TextView titleView;
|
||||
private int span;
|
||||
private String mTitle;
|
||||
private String mStyle;
|
||||
private CheckResultData mCheckResultData;
|
||||
|
||||
|
||||
public CheckInfoListDialog(@NonNull Context context, String title,CheckResultData checkResultData) {
|
||||
public CheckInfoListDialog(@NonNull Context context, String style, CheckResultData checkResultData) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
mTitle = title;
|
||||
mStyle = style;
|
||||
mCheckResultData = checkResultData;
|
||||
initView();
|
||||
}
|
||||
@@ -43,7 +44,11 @@ public class CheckInfoListDialog extends BaseFloatDialog {
|
||||
setContentView(R.layout.check_info_list);
|
||||
mRecyclerView = findViewById(R.id.check_list_recycler);
|
||||
titleView = findViewById(R.id.check_info_title);
|
||||
titleView.setText(mTitle);
|
||||
if (mStyle.equals(CheckItemInfo.CheckInfoStyle.CHECK_INFO_STYLE_DEVICES)) {
|
||||
titleView.setText("硬件自检结果");
|
||||
} else {
|
||||
titleView.setText("系统自检结果");
|
||||
}
|
||||
//网格布局
|
||||
GridLayoutManager layoutManager = new GridLayoutManager(mContext, 4);
|
||||
mRecyclerView.setLayoutManager(layoutManager);
|
||||
@@ -55,7 +60,7 @@ public class CheckInfoListDialog extends BaseFloatDialog {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
mRecyclerView.setAdapter(new CheckInfoAdapter(mContext, mCheckResultData));
|
||||
mRecyclerView.setAdapter(new CheckInfoAdapter(mContext, mStyle, mCheckResultData));
|
||||
//关闭按钮
|
||||
findViewById(R.id.cancel_info_list_button).setOnClickListener(v -> {
|
||||
cancel();
|
||||
|
||||
@@ -25,8 +25,11 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="正常"
|
||||
android:gravity="center"
|
||||
android:textAlignment="center"
|
||||
android:textColor="#fff"
|
||||
android:textSize="@dimen/dp_38"
|
||||
android:layout_marginLeft="@dimen/dp_27"
|
||||
app:layout_constraintLeft_toRightOf="@+id/info_check_icon" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user