diff --git a/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/net/CheckNetWork.kt b/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/net/CheckNetWork.kt index 5d2703522e..3da2c6d33f 100644 --- a/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/net/CheckNetWork.kt +++ b/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/net/CheckNetWork.kt @@ -22,7 +22,7 @@ object CheckNetWork { //网络请求,获取自车检测结果(工控机上报云端) fun checkNetWork(context: Context, callbackFlow: ICheckResultCallBack) { val params = ParamsBuilder.of(false) - .append("sn", MoGoAiCloudClientConfig.getInstance().sn) + .append("sn", "X20202108044A6797CFE6F8E899") .build() CheckApiServiceFactory.getDataApiService(context).loadMonitorDetail(params) .subscribeOn(Schedulers.io()) 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 afad70b474..158bcaba3d 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 @@ -5,6 +5,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; +import android.widget.ScrollView; import android.widget.TextView; import androidx.annotation.NonNull; @@ -25,6 +26,11 @@ public class CheckInfoAdapter extends RecyclerView.Adapter { private Context mContext; private String mStyle; private List showData; + //item类型 + public static final int ITEM_TYPE_CONTENT = 0;//内容 + public static final int ITEM_TYPE_BOTTOM = 1;//footer类型 + //底部View个数 + private int mBottomCount = 1; public CheckInfoAdapter(Context context, String style, List checkResultData) { mContext = context; @@ -36,6 +42,12 @@ public class CheckInfoAdapter extends RecyclerView.Adapter { @NonNull @Override public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + if (viewType == ITEM_TYPE_BOTTOM) { + View v = mLayoutInflater.inflate(R.layout.check_recycler_footer, parent, + false); + CheckInfoAdapter.CheckInfoFooter holder = new CheckInfoAdapter.CheckInfoFooter(v); + return holder; + } View v = mLayoutInflater.inflate(R.layout.check_info_adapter, parent, false); CheckInfoAdapter.CheckInfoViewHolder holder = new CheckInfoAdapter.CheckInfoViewHolder(v); @@ -46,23 +58,25 @@ public class CheckInfoAdapter extends RecyclerView.Adapter { @Override public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { 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); + if (holder instanceof CheckInfoAdapter.CheckInfoViewHolder) { + 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); + } } } } @@ -83,7 +97,7 @@ public class CheckInfoAdapter extends RecyclerView.Adapter { @Override public int getItemCount() { - return showData.size() * 2; + return showData.size() * 2 + mBottomCount; } public class CheckInfoViewHolder extends RecyclerView.ViewHolder { @@ -97,8 +111,17 @@ public class CheckInfoAdapter extends RecyclerView.Adapter { } } + public class CheckInfoFooter extends RecyclerView.ViewHolder { + public CheckInfoFooter(View v) { + super(v); + } + } + @Override public int getItemViewType(int position) { - return position; + if (position > showData.size() * 2) { + return ITEM_TYPE_BOTTOM; + } + return ITEM_TYPE_CONTENT; } } diff --git a/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/view/CheckInfoGridItemDivider.java b/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/view/CheckInfoGridItemDivider.java index 8f6f13edcd..8b678c7963 100644 --- a/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/view/CheckInfoGridItemDivider.java +++ b/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/view/CheckInfoGridItemDivider.java @@ -6,6 +6,7 @@ import android.graphics.Canvas; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.graphics.drawable.GradientDrawable; +import android.util.Log; import android.view.View; import androidx.recyclerview.widget.GridLayoutManager; @@ -105,18 +106,6 @@ public class CheckInfoGridItemDivider extends RecyclerView.ItemDecoration { divider.draw(c); } - //待修改为右侧 - private void drawVerticalForLastColum(Canvas c, View child) { - final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child - .getLayoutParams(); - int left = child.getRight() - params.leftMargin - divider.getIntrinsicWidth(); - int top = child.getTop() - params.topMargin; - int right = child.getRight() - params.leftMargin + divider.getIntrinsicWidth(); - int bottom = top + child.getHeight() + divider.getIntrinsicHeight(); - divider.setBounds(left, top, right, bottom); - divider.draw(c); - } - public void drawVertical(Canvas c, RecyclerView parent) { final int childCount = parent.getChildCount(); for (int i = 0; i < childCount; i++) { @@ -133,62 +122,9 @@ public class CheckInfoGridItemDivider extends RecyclerView.ItemDecoration { if (isFirstColum(parent, i, getSpanCount(parent))) { //画第一列左边分割线 drawVerticalForFirstColum(c, child); } - if (isLastColum(parent, i, getSpanCount(parent), childCount)) {//画最后一列右侧分割线 - drawVerticalForLastColum(c, child); - } } } - private boolean isLastColum(RecyclerView parent, int pos, int spanCount, - int childCount) { - RecyclerView.LayoutManager layoutManager = parent.getLayoutManager(); - if (layoutManager instanceof GridLayoutManager) { - if ((pos + 1) % spanCount == 0)// 如果是最后一列,则不需要绘制右边 - { - return true; - } - } else if (layoutManager instanceof StaggeredGridLayoutManager) { - int orientation = ((StaggeredGridLayoutManager) layoutManager) - .getOrientation(); - if (orientation == StaggeredGridLayoutManager.VERTICAL) { - if ((pos + 1) % spanCount == 0)// 如果是最后一列,则不需要绘制右边 - { - return true; - } - } else { - childCount = childCount - childCount % spanCount; - if (pos >= childCount)// 如果是最后一列,则不需要绘制右边 - return true; - } - } - return false; - } - - private boolean isLastRaw(RecyclerView parent, int pos, int spanCount, - int childCount) { - RecyclerView.LayoutManager layoutManager = parent.getLayoutManager(); - if (layoutManager instanceof GridLayoutManager) { - childCount = childCount - childCount % spanCount; - if (pos >= childCount)// 如果是最后一行,则不需要绘制底部 - return true; - } else if (layoutManager instanceof StaggeredGridLayoutManager) { - int orientation = ((StaggeredGridLayoutManager) layoutManager) - .getOrientation(); - if (orientation == StaggeredGridLayoutManager.VERTICAL) { - childCount = childCount - childCount % spanCount; - // 如果是最后一行,则不需要绘制底部 - if (pos >= childCount) - return true; - } else { - // 如果是最后一行,则不需要绘制底部 - if ((pos + 1) % spanCount == 0) { - return true; - } - } - } - return false; - } - //是否为第一列 private boolean isFirstColum(RecyclerView parent, int pos, int spanCount) { RecyclerView.LayoutManager layoutManager = parent.getLayoutManager(); diff --git a/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/view/CheckRecyclerFooter.java b/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/view/CheckRecyclerFooter.java new file mode 100644 index 0000000000..f072f65a03 --- /dev/null +++ b/core/function-impl/mogo-core-function-check/src/main/java/com/mogo/eagle/core/function/check/view/CheckRecyclerFooter.java @@ -0,0 +1,28 @@ +package com.mogo.eagle.core.function.check.view; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.View; + +import com.mogo.eagle.core.function.check.R; + +import java.util.jar.Attributes; + +/** + * @author liujing + * @description 描述 + * @since: 10/13/21 + */ +public class CheckRecyclerFooter extends View { + + public CheckRecyclerFooter(Context context, AttributeSet attributes) { + super(context, attributes); + LayoutInflater.from(context).inflate(R.layout.check_recycler_footer, null); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + } +} diff --git a/core/function-impl/mogo-core-function-check/src/main/res/layout/check_dialog.xml b/core/function-impl/mogo-core-function-check/src/main/res/layout/check_dialog.xml index b7f215582e..af07edb8d0 100644 --- a/core/function-impl/mogo-core-function-check/src/main/res/layout/check_dialog.xml +++ b/core/function-impl/mogo-core-function-check/src/main/res/layout/check_dialog.xml @@ -33,51 +33,52 @@ android:layout_height="wrap_content" android:layout_marginStart="@dimen/dp_97" android:layout_marginTop="@dimen/dp_225" - android:visibility="invisible" + android:visibility="visible" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"> - - + + + app:layout_constraintTop_toBottomOf="@id/error_image" /> @@ -87,6 +88,7 @@ android:layout_height="wrap_content" android:layout_marginStart="@dimen/dp_133" android:layout_marginTop="@dimen/dp_200" + android:visibility="invisible" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"> @@ -102,7 +104,7 @@ android:id="@+id/check_button" android:layout_width="@dimen/dp_287" android:layout_height="@dimen/dp_100" - android:layout_marginTop="@dimen/check_button_bottom" + android:layout_marginTop="@dimen/dp_70" android:background="@drawable/check_button" android:gravity="center" android:text="立即体检" diff --git a/core/function-impl/mogo-core-function-check/src/main/res/layout/check_info_list.xml b/core/function-impl/mogo-core-function-check/src/main/res/layout/check_info_list.xml index 39be304ef4..9d53419d7c 100644 --- a/core/function-impl/mogo-core-function-check/src/main/res/layout/check_info_list.xml +++ b/core/function-impl/mogo-core-function-check/src/main/res/layout/check_info_list.xml @@ -42,6 +42,18 @@ app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toBottomOf="@+id/check_info_title"> + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-check/src/main/res/layout/check_recycler_footer.xml b/core/function-impl/mogo-core-function-check/src/main/res/layout/check_recycler_footer.xml new file mode 100644 index 0000000000..3ee8f46ef4 --- /dev/null +++ b/core/function-impl/mogo-core-function-check/src/main/res/layout/check_recycler_footer.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-check/src/main/res/values-xhdpi-2560x1440/dimens.xml b/core/function-impl/mogo-core-function-check/src/main/res/values-xhdpi-2560x1440/dimens.xml index d3a41425ff..64876ee4a1 100644 --- a/core/function-impl/mogo-core-function-check/src/main/res/values-xhdpi-2560x1440/dimens.xml +++ b/core/function-impl/mogo-core-function-check/src/main/res/values-xhdpi-2560x1440/dimens.xml @@ -2,7 +2,6 @@ 30px 38px - 70px 133px 50px 50px diff --git a/core/function-impl/mogo-core-function-check/src/main/res/values/colors.xml b/core/function-impl/mogo-core-function-check/src/main/res/values/colors.xml index 899fcf4ec0..14ad4dd1e6 100644 --- a/core/function-impl/mogo-core-function-check/src/main/res/values/colors.xml +++ b/core/function-impl/mogo-core-function-check/src/main/res/values/colors.xml @@ -11,7 +11,7 @@ #EE3132 #666DA5 #767FCD - #151738 + #1C2149 \ No newline at end of file