结果集呈现

This commit is contained in:
liujing
2021-09-25 16:12:52 +08:00
parent c5a3c9073b
commit 9d7068078b
4 changed files with 49 additions and 30 deletions

View File

@@ -239,7 +239,7 @@ public class CheckResultData extends BaseData {
public static class CheckListItem {
private String name;
private String stateValue;
private List items;
private List<CheckResultData.CheckListItem> items;
public String getName() {
return name;

View File

@@ -12,7 +12,6 @@ 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;
@@ -27,14 +26,13 @@ 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<>();
private List<CheckResultData.CheckListItem> showData;
public CheckInfoAdapter(Context context, String style, CheckResultData checkResultData) {
public CheckInfoAdapter(Context context, String style, List checkResultData) {
mContext = context;
mStyle = style;
mCheckResultData = checkResultData;
showData = checkResultData;
mLayoutInflater = LayoutInflater.from(context);
}
@@ -58,14 +56,15 @@ public class CheckInfoAdapter extends RecyclerView.Adapter {
((CheckInfoViewHolder) holder).mTextView.setText("运行状态");
} else {
try {
if ((position - 4) < result.size()) {
CheckResultData.CheckListItem item = (CheckResultData.CheckListItem) result.get(position - 4);
if ((position - 4) < showData.size()) {
int index = position - 4;
CheckResultData.CheckListItem positionItem = showData.get(index);
if (isEven(position) == true) {//偶数隐藏图片显示检测指标
((CheckInfoViewHolder) holder).checkIcon.setVisibility(View.GONE);
((CheckInfoViewHolder) holder).mTextView.setText(item.getName());
((CheckInfoViewHolder) holder).mTextView.setText(positionItem.getName());
} else {//奇数显示图片和检测指标结果
((CheckInfoViewHolder) holder).checkIcon.setVisibility(View.VISIBLE);
String state = (String) item.getStateValue();
String state = (String) positionItem.getStateValue();
if (state.equals("1")) {
((CheckInfoViewHolder) holder).mTextView.setText("正常");
((CheckInfoViewHolder) holder).checkIcon.setImageResource(R.drawable.check_right);
@@ -95,24 +94,7 @@ public class CheckInfoAdapter extends RecyclerView.Adapter {
@Override
public int getItemCount() {
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;
return showData.size() + 4;
}
public class CheckInfoViewHolder extends RecyclerView.ViewHolder {

View File

@@ -2,6 +2,7 @@ package com.mogo.eagle.core.function.check.view;
import android.content.Context;
import android.graphics.Color;
import android.util.Log;
import android.widget.TextView;
import androidx.annotation.NonNull;
@@ -13,6 +14,9 @@ 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;
import java.util.ArrayList;
import java.util.List;
/**
* @author liujing
* @description 检测指标详情弹框
@@ -20,12 +24,14 @@ import com.mogo.module.common.dialog.BaseFloatDialog;
*/
public class CheckInfoListDialog extends BaseFloatDialog {
private static final String TAG = "CheckInfoListDialog";
private RecyclerView mRecyclerView;
private Context mContext;
private TextView titleView;
private int span;
private String mStyle;
private CheckResultData mCheckResultData;
private List<CheckResultData.CheckListItem> result = new ArrayList<>();
public CheckInfoListDialog(@NonNull Context context, String style, CheckResultData checkResultData) {
@@ -60,13 +66,44 @@ public class CheckInfoListDialog extends BaseFloatDialog {
} catch (Exception e) {
e.printStackTrace();
}
mRecyclerView.setAdapter(new CheckInfoAdapter(mContext, mStyle, mCheckResultData));
List resultData = showInfoResult();
mRecyclerView.setAdapter(new CheckInfoAdapter(mContext, mStyle, resultData));
//关闭按钮
findViewById(R.id.cancel_info_list_button).setOnClickListener(v -> {
cancel();
});
}
public List showInfoResult() {
if (result.size() > 0) {
result.clear();
}
try {
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) {
if (item.getStateValue() != null) {
result.addAll(checkListResult);
}
if (item.getItems() != null) {
result.addAll(item.getItems());
}
}
} catch (Exception e) {
e.printStackTrace();
}
Log.d(TAG, "检测指标结果值===" + result.toString());
} catch (Exception e) {
}
return result;
}
public void cancel() {
super.dismiss();
}

View File

@@ -24,7 +24,7 @@
android:id="@+id/info_result_tx"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="正常"
android:text="检测中"
android:gravity="center"
android:textAlignment="center"
android:textColor="#fff"