From 09508ef72818f5f557fc8bed96313ebc99319e32 Mon Sep 17 00:00:00 2001 From: liujing Date: Wed, 29 Sep 2021 20:06:09 +0800 Subject: [PATCH] =?UTF-8?q?[add]=20HeaderView=E4=B8=8D=E9=9A=8Flist?= =?UTF-8?q?=E6=BB=91=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../function/check/view/CheckInfoAdapter.java | 61 +++++++------------ .../check/view/CheckInfoListDialog.java | 3 +- .../check/view/CheckInfoRecyclerView.java | 2 +- .../main/res/layout/check_info_adapter.xml | 10 --- .../src/main/res/layout/check_info_list.xml | 16 ++++- .../main/res/layout/check_info_title_item.xml | 61 +++++++++++++++++++ .../src/main/res/values/dimens.xml | 2 +- 7 files changed, 101 insertions(+), 54 deletions(-) create mode 100644 core/function-impl/mogo-core-function-check/src/main/res/layout/check_info_title_item.xml 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 03138ae53d..5d4a1971fd 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 @@ -48,45 +48,29 @@ public class CheckInfoAdapter extends RecyclerView.Adapter { @Override public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { - if (position == 0 || position == 2) { - ((CheckInfoViewHolder) holder).checkIcon.setVisibility(View.GONE); - ((CheckInfoViewHolder) holder).mTextView.setText("模块名称"); - TextPaint tp = ((CheckInfoViewHolder) holder).mTextView.getPaint(); - tp.setFakeBoldText(true); - ((CheckInfoViewHolder) holder).backImage.setVisibility(View.VISIBLE); - - } else if (position == 1 || position == 3) { - ((CheckInfoViewHolder) holder).checkIcon.setVisibility(View.GONE); - ((CheckInfoViewHolder) holder).mTextView.setText("运行状态"); - TextPaint tp = ((CheckInfoViewHolder) holder).mTextView.getPaint(); - tp.setFakeBoldText(true); - ((CheckInfoViewHolder) holder).backImage.setVisibility(View.VISIBLE); - } else { - ((CheckInfoViewHolder) holder).backImage.setVisibility(View.INVISIBLE); - try { - if ((position - 4) < showData.size() * 2) { - int index = (position - 4) / 2; - CheckResultData.CheckListItem positionItem = showData.get(index); - if (isEven(position) == true) {//偶数隐藏图片显示检测指标 - ((CheckInfoViewHolder) holder).checkIcon.setVisibility(View.GONE); - ((CheckInfoViewHolder) holder).mTextView.setText(positionItem.getName()); - } else {//奇数显示图片和检测指标结果 - ((CheckInfoViewHolder) holder).checkIcon.setVisibility(View.VISIBLE); - String state = (String) positionItem.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); - } + try { + if (position < showData.size() * 2) { + int index = position / 2; + CheckResultData.CheckListItem positionItem = showData.get(index); + if (isEven(position) == true) {//偶数隐藏图片显示检测指标 + ((CheckInfoViewHolder) holder).checkIcon.setVisibility(View.GONE); + ((CheckInfoViewHolder) holder).mTextView.setText(positionItem.getName()); + } else {//奇数显示图片和检测指标结果 + ((CheckInfoViewHolder) holder).checkIcon.setVisibility(View.VISIBLE); + String state = (String) positionItem.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(); } + } catch (Exception e) { + e.printStackTrace(); } } @@ -102,19 +86,18 @@ public class CheckInfoAdapter extends RecyclerView.Adapter { @Override public int getItemCount() { - return showData.size() * 2 + 4; + return showData.size() * 2; } public class CheckInfoViewHolder extends RecyclerView.ViewHolder { private ImageView checkIcon; private TextView mTextView; - private View backImage; public CheckInfoViewHolder(View v) { super(v); checkIcon = v.findViewById(R.id.info_check_icon); mTextView = v.findViewById(R.id.info_result_tx); - backImage = v.findViewById(R.id.backImage); } } + } 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 db349b0673..5da4a5d2f5 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 @@ -69,7 +69,8 @@ public class CheckInfoListDialog extends BaseFloatDialog { e.printStackTrace(); } List resultData = showInfoResult(); - mRecyclerView.setAdapter(new CheckInfoAdapter(mContext, mStyle, resultData)); + CheckInfoAdapter adapter = new CheckInfoAdapter(mContext, mStyle, resultData); + mRecyclerView.setAdapter(adapter); //关闭按钮 findViewById(R.id.cancel_info_list_button).setOnClickListener(v -> { dismiss(); diff --git a/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/view/CheckInfoRecyclerView.java b/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/view/CheckInfoRecyclerView.java index c00ff7859d..53b44b14bc 100644 --- a/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/view/CheckInfoRecyclerView.java +++ b/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/view/CheckInfoRecyclerView.java @@ -11,7 +11,7 @@ import com.mogo.eagle.core.function.check.R; /** * @author liujing - * @description 描述 + * @description 列表自适应高+限高 * @since: 9/29/21 */ public class CheckInfoRecyclerView extends RecyclerView { 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 28c98605cf..39c5a5a9fe 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 @@ -5,16 +5,6 @@ android:layout_height="@dimen/dp_127" android:layout_gravity="left"> - - + + + app:layout_constraintTop_toBottomOf="@+id/check_title_item" /> \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-check/src/main/res/layout/check_info_title_item.xml b/core/function-impl/mogo-core-function-check/src/main/res/layout/check_info_title_item.xml new file mode 100644 index 0000000000..2923d4a513 --- /dev/null +++ b/core/function-impl/mogo-core-function-check/src/main/res/layout/check_info_title_item.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-check/src/main/res/values/dimens.xml b/core/function-impl/mogo-core-function-check/src/main/res/values/dimens.xml index be32d366f2..883f2e5611 100644 --- a/core/function-impl/mogo-core-function-check/src/main/res/values/dimens.xml +++ b/core/function-impl/mogo-core-function-check/src/main/res/values/dimens.xml @@ -1,5 +1,5 @@ 1900px - 876px + 770px