Merge branch 'dev_MogoAP_eagle-930_210926_8.0.12' into dev/dev_eagle_architecture_upgrade2

This commit is contained in:
董宏宇
2021-10-18 20:51:43 +08:00
9 changed files with 117 additions and 101 deletions

View File

@@ -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())

View File

@@ -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<CheckResultData.CheckListItem> 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;
}
}

View File

@@ -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();

View File

@@ -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);
}
}

View File

@@ -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">
<ImageView
android:id="@+id/error_image"
android:layout_width="@dimen/dp_56"
android:layout_height="@dimen/dp_56"
android:layout_marginTop="@dimen/dp_15"
android:src="@drawable/check_wrong"
app:layout_constraintTop_toTopOf="@id/error_view" />
<TextView
android:id="@+id/error_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dp_15"
android:text="自动驾驶车辆存在风险"
android:textColor="@color/module_commons_wm_dialog_text_textColor"
android:textSize="@dimen/dp_54"
android:textStyle="bold"
app:layout_constraintStart_toEndOf="@id/error_image"
app:layout_constraintStart_toStartOf="@id/error_view"
app:layout_constraintTop_toTopOf="@id/error_view" />
<ImageView
android:id="@+id/error_image"
android:layout_width="@dimen/dp_56"
android:layout_height="@dimen/dp_56"
android:layout_marginTop="@dimen/dp_25"
android:src="@drawable/check_wrong"
app:layout_constraintTop_toBottomOf="@id/error_title" />
<TextView
android:id="@+id/error_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_26"
android:layout_marginTop="@dimen/dp_23"
android:text="软件运行异常"
android:textColor="@color/check_tip_error_color"
android:textSize="@dimen/dp_38"
app:layout_constraintLeft_toRightOf="@+id/error_image"
app:layout_constraintTop_toBottomOf="@id/error_title" />
<TextView
android:id="@+id/check_detail"
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_detail"
android:gravity="center"
android:text="查看详情"
android:textColor="@color/module_commons_wm_dialog_text_textColor"
android:textSize="@dimen/check_button_text_size"
app:layout_constraintTop_toBottomOf="@id/error_txt" />
app:layout_constraintTop_toBottomOf="@id/error_image" />
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -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="立即体检"

View File

@@ -42,6 +42,18 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/check_info_title"></include>
<View
android:id="@+id/line_top"
android:layout_width="3px"
android:layout_height="@dimen/dp_127"
android:layout_marginTop="@dimen/dp_66"
android:background="@color/check_info_shape_color"
app:layout_constraintBottom_toBottomOf="@+id/check_list_recycler"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/check_info_title"
app:layout_constraintVertical_bias="0.0" />
<com.mogo.eagle.core.function.check.view.CheckInfoRecyclerView
android:id="@+id/check_list_recycler"
android:layout_width="match_parent"
@@ -54,5 +66,13 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/check_title_item" />
<View
android:layout_width="3px"
android:layout_height="0dp"
android:background="@color/check_info_shape_color"
app:layout_constraintBottom_toBottomOf="@+id/check_list_recycler"
app:layout_constraintEnd_toEndOf="@id/check_list_recycler"
app:layout_constraintStart_toStartOf="@id/check_list_recycler"
app:layout_constraintTop_toTopOf="@id/check_list_recycler" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_300"
android:background="@color/check_list_item_back">
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -2,7 +2,6 @@
<resources>
<dimen name="check_item_space_vr">30px</dimen>
<dimen name="check_button_text_size">38px</dimen>
<dimen name="check_button_bottom">70px</dimen>
<dimen name="check_button_left">133px</dimen>
<dimen name="check_image_bottom">50px</dimen>
<dimen name="check_image_right">50px</dimen>

View File

@@ -11,7 +11,7 @@
<color name="check_icon_error_color">#EE3132</color>
<color name="check_info_position_line_color">#666DA5</color>
<color name="check_info_shape_color">#767FCD</color>
<color name="check_info_title_back">#151738</color>
<color name="check_info_title_back">#1C2149</color>
</resources>