From 9d7068078bf3472019d97eb29d42a6fa7c7a6431 Mon Sep 17 00:00:00 2001 From: liujing Date: Sat, 25 Sep 2021 16:12:52 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=93=E6=9E=9C=E9=9B=86=E5=91=88=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../function/check/net/CheckResultData.java | 2 +- .../function/check/view/CheckInfoAdapter.java | 36 +++++------------ .../check/view/CheckInfoListDialog.java | 39 ++++++++++++++++++- .../main/res/layout/check_info_adapter.xml | 2 +- 4 files changed, 49 insertions(+), 30 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 0eb691f2df..8ff75e0433 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 @@ -239,7 +239,7 @@ public class CheckResultData extends BaseData { public static class CheckListItem { private String name; private String stateValue; - private List items; + private List items; public String getName() { return name; 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 489b7aab63..6a2a907497 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 @@ -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 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 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 { 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 74fcf58122..892faa1f91 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.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 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 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(); } 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 c67735a22a..0cc4eecef8 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 @@ -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"