[add] 自检结果详细指标弹框添加 差网格布局和云端数据赋值
This commit is contained in:
@@ -45,7 +45,7 @@ import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 车辆监控页面
|
||||
* @description 车辆监控页面首页
|
||||
* @since: 7/27/21
|
||||
*/
|
||||
public class CheckActivity extends AppCompatActivity {
|
||||
@@ -180,7 +180,7 @@ public class CheckActivity extends AppCompatActivity {
|
||||
ObjectAnimator animatorX = ObjectAnimator.ofFloat(scanLineImage, "translationX", scanBottomCarImage.getWidth(), 0);
|
||||
ObjectAnimator animatorAl = ObjectAnimator.ofFloat(scanLineImage, "alpha", 0, 1);
|
||||
setAnimation.playTogether(animatorX, animatorAl);
|
||||
setAnimation.setDuration(800);
|
||||
setAnimation.setDuration(200);
|
||||
setAnimation.start();
|
||||
setAnimation.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
|
||||
@@ -19,7 +19,7 @@ import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 检测界面单元格
|
||||
* @description 检测首页单元格
|
||||
* @since: 7/27/21
|
||||
*/
|
||||
public class CheckAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
@@ -84,9 +84,6 @@ public class CheckAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
private TextView autoRiskState;
|
||||
private ImageView iconAuto;
|
||||
|
||||
private TextView iconyingTitle;
|
||||
private TextView yingRiskState;
|
||||
|
||||
public CheckListViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
viewTitle = itemView.findViewById(R.id.list_item_title);
|
||||
@@ -97,42 +94,6 @@ public class CheckAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 硬件检测
|
||||
*/
|
||||
class CheckImage extends RecyclerView.ViewHolder {
|
||||
private ImageView pad;
|
||||
private ImageView jiaoJiGuangTop;
|
||||
private TextView jiaoJiGuangTopText;
|
||||
private ImageView jiaoJiGuangBottom;
|
||||
private TextView jiaoJiGuangBottomText;
|
||||
private ImageView zhuJiGuang;
|
||||
private ImageView rtk;
|
||||
private ImageView cameraTop;
|
||||
private ImageView cameraMiddle;
|
||||
private ImageView cameraBottom;
|
||||
private ImageView cameraBehind;
|
||||
private ImageView luyouqi;
|
||||
private ImageView obu;
|
||||
|
||||
public CheckImage(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
pad = itemView.findViewById(R.id.pad);
|
||||
jiaoJiGuangTop = itemView.findViewById(R.id.jiaoJiGuangTop);
|
||||
jiaoJiGuangTopText = itemView.findViewById(R.id.jiaoJiGuangTop_txt);
|
||||
jiaoJiGuangBottom = itemView.findViewById(R.id.jiaoJiGuangBottom);
|
||||
jiaoJiGuangBottomText = itemView.findViewById(R.id.jiaoJiGuangBottom_txt);
|
||||
zhuJiGuang = itemView.findViewById(R.id.zhujiguang);
|
||||
rtk = itemView.findViewById(R.id.rtk);
|
||||
cameraTop = itemView.findViewById(R.id.top);
|
||||
cameraMiddle = itemView.findViewById(R.id.middle);
|
||||
cameraBottom = itemView.findViewById(R.id.bottom);
|
||||
cameraBehind = itemView.findViewById(R.id.camera_begind);
|
||||
luyouqi = itemView.findViewById(R.id.luyouqi);
|
||||
obu = itemView.findViewById(R.id.obu);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
try {
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.mogo.module.common.dialog.BaseFloatDialog;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 车辆监控弹框提示
|
||||
* @description 车辆监控弹框提示(长时间未检测或者后台任务检测出现问题的弹框)
|
||||
* @since: 7/30/21
|
||||
*/
|
||||
public class CheckDialog extends BaseFloatDialog {
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.mogo.eagle.core.function.check.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.mogo.eagle.core.function.check.R;
|
||||
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 点击自动驾驶icon显示指标详情结果
|
||||
* @since: 9/23/21
|
||||
*/
|
||||
public class CheckInfoAdapter extends RecyclerView.Adapter {
|
||||
LayoutInflater mLayoutInflater;
|
||||
private Context mContext;
|
||||
|
||||
public CheckInfoAdapter(Context context) {
|
||||
mContext = context;
|
||||
mLayoutInflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View v = mLayoutInflater.inflate(R.layout.check_info_adapter, parent,
|
||||
false);
|
||||
CheckInfoAdapter.CheckInfoViewHolder holder = new CheckInfoAdapter.CheckInfoViewHolder(v);
|
||||
return holder;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
public class CheckInfoViewHolder extends RecyclerView.ViewHolder {
|
||||
private ImageView checkIcon;
|
||||
private TextView mTextView;
|
||||
public CheckInfoViewHolder(View v) {
|
||||
super(v);
|
||||
checkIcon = v.findViewById(R.id.info_check_icon);
|
||||
mTextView = v.findViewById(R.id.info_result_tx);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
package com.mogo.eagle.core.function.check.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 描述
|
||||
* @since: 9/22/21
|
||||
*/
|
||||
public class CheckInfoGridItemDivider extends RecyclerView.ItemDecoration {
|
||||
private String TAG = getClass().getSimpleName();
|
||||
private static final int[] ATTRS = new int[]{android.R.attr.listDivider};
|
||||
private Drawable divider;
|
||||
|
||||
public CheckInfoGridItemDivider(Context context) {
|
||||
final TypedArray a = context.obtainStyledAttributes(ATTRS);
|
||||
divider = a.getDrawable(0);
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
public CheckInfoGridItemDivider(Drawable drawable) {
|
||||
divider = drawable;
|
||||
}
|
||||
|
||||
public CheckInfoGridItemDivider(int height, int color) {
|
||||
GradientDrawable shapeDrawable = new GradientDrawable();
|
||||
shapeDrawable.setColor(color);
|
||||
shapeDrawable.setShape(GradientDrawable.RECTANGLE);
|
||||
shapeDrawable.setSize(height, height);
|
||||
divider = shapeDrawable;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
|
||||
|
||||
drawHorizontal(c, parent);
|
||||
drawVertical(c, parent);
|
||||
|
||||
}
|
||||
|
||||
private int getSpanCount(RecyclerView parent) {
|
||||
// 列数
|
||||
int spanCount = -1;
|
||||
RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
|
||||
if (layoutManager instanceof GridLayoutManager) {
|
||||
|
||||
spanCount = ((GridLayoutManager) layoutManager).getSpanCount();
|
||||
} else if (layoutManager instanceof StaggeredGridLayoutManager) {
|
||||
spanCount = ((StaggeredGridLayoutManager) layoutManager)
|
||||
.getSpanCount();
|
||||
}
|
||||
return spanCount;
|
||||
}
|
||||
|
||||
public void drawHorizontal(Canvas c, RecyclerView parent) {
|
||||
int childCount = parent.getChildCount(); //获取可见item的数量
|
||||
int spanCount = getSpanCount(parent);
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
final View child = parent.getChildAt(i);
|
||||
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
|
||||
.getLayoutParams();
|
||||
final int left = child.getLeft() - params.leftMargin;
|
||||
final int right = child.getRight() + params.rightMargin
|
||||
+ divider.getIntrinsicWidth();
|
||||
final int top = child.getBottom() + params.bottomMargin;
|
||||
final int bottom = top + divider.getIntrinsicHeight();
|
||||
divider.setBounds(left, top, right, bottom);
|
||||
divider.draw(c);
|
||||
if (i < spanCount) { //画第一行顶部的分割线
|
||||
drawHorizontalForFirstRow(c, child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void drawHorizontalForFirstRow(Canvas c, View child) {
|
||||
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
|
||||
.getLayoutParams();
|
||||
int left = child.getLeft() - params.leftMargin - divider.getIntrinsicWidth();
|
||||
int top = child.getTop() - params.topMargin - divider.getIntrinsicHeight();
|
||||
int right = child.getRight() + params.rightMargin + divider.getIntrinsicWidth();
|
||||
int bottom = top + divider.getIntrinsicHeight();
|
||||
divider.setBounds(left, top, right, bottom);
|
||||
divider.draw(c);
|
||||
}
|
||||
|
||||
private void drawVerticalForFirstColum(Canvas c, View child) {
|
||||
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
|
||||
.getLayoutParams();
|
||||
int left = child.getLeft() - params.leftMargin - divider.getIntrinsicWidth();
|
||||
int top = child.getTop() - params.topMargin;
|
||||
int right = child.getLeft() - params.leftMargin;
|
||||
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++) {
|
||||
final View child = parent.getChildAt(i);
|
||||
|
||||
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
|
||||
.getLayoutParams();
|
||||
final int top = child.getTop() - params.topMargin;
|
||||
final int bottom = child.getBottom() + params.bottomMargin;
|
||||
final int left = child.getRight() + params.rightMargin;
|
||||
final int right = left + divider.getIntrinsicWidth();
|
||||
divider.setBounds(left, top, right, bottom);
|
||||
divider.draw(c);
|
||||
if (isFirstColum(parent, i, getSpanCount(parent))) { //画第一列左边分割线
|
||||
drawVerticalForFirstColum(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();
|
||||
if (layoutManager instanceof GridLayoutManager) { //网格布局
|
||||
if ((pos + 1) % spanCount == 1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//是否为第一行
|
||||
private boolean isFirstRaw(int pos, int spanCount) {
|
||||
if (pos < spanCount) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getItemOffsets(Rect outRect, int itemPosition,
|
||||
RecyclerView parent) {
|
||||
int spanCount = getSpanCount(parent); //列数
|
||||
|
||||
if (itemPosition == 0) { //第一行第一个,四边都画
|
||||
outRect.set(divider.getIntrinsicWidth(), divider.getIntrinsicHeight(),
|
||||
divider.getIntrinsicWidth(), divider.getIntrinsicHeight());
|
||||
} else if (isFirstRaw(itemPosition, spanCount)) { //第一行,画上下右三边
|
||||
outRect.set(0, divider.getIntrinsicHeight(), divider.getIntrinsicWidth(), divider.getIntrinsicHeight());
|
||||
} else if (isFirstColum(parent, itemPosition, spanCount)) { //第一列,画左右下三边
|
||||
outRect.set(divider.getIntrinsicWidth(), 0, divider.getIntrinsicWidth(), divider.getIntrinsicHeight());
|
||||
} else { //其他,画右下两边
|
||||
outRect.set(0, 0, divider.getIntrinsicWidth(), divider.getIntrinsicHeight());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.eagle.core.function.check.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
@@ -33,12 +34,16 @@ public class CheckInfoListDialog extends BaseFloatDialog {
|
||||
|
||||
public void initView() {
|
||||
setContentView(R.layout.check_info_list);
|
||||
mRecyclerView = findViewById(R.id.module_services_id_recycler_view);
|
||||
GridLayoutManager layoutManager = new GridLayoutManager(mContext, 4);
|
||||
mRecyclerView = findViewById(R.id.check_list_recycler);
|
||||
// GridLayoutManager layoutManager = new GridLayoutManager(mContext, 4);
|
||||
// mRecyclerView.setLayoutManager(layoutManager);
|
||||
//表示竖直显示.默认VERTICAL
|
||||
layoutManager.setOrientation(GridLayoutManager.HORIZONTAL);
|
||||
mRecyclerView.addItemDecoration(new CheckInfoListGridItemDec());
|
||||
mRecyclerView.setLayoutManager(layoutManager);
|
||||
// layoutManager.setOrientation(GridLayoutManager.HORIZONTAL);
|
||||
// CheckInfoGridItemDivider gridLayoutDivider = new CheckInfoGridItemDivider(2, Color.parseColor("#CCCCCC"));
|
||||
// mRecyclerView.addItemDecoration(gridLayoutDivider);
|
||||
mRecyclerView.setAdapter(new CheckInfoAdapter(mContext));
|
||||
|
||||
//关闭按钮
|
||||
findViewById(R.id.cancel_info_list_button).setOnClickListener(v -> {
|
||||
cancel();
|
||||
});
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
package com.mogo.eagle.core.function.check.view;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 描述
|
||||
* @since: 9/22/21
|
||||
*/
|
||||
class CheckInfoListGridItemDec extends RecyclerView.ItemDecoration {
|
||||
//分割线的宽度
|
||||
private static final int DIVIDER_SIZE = 5;
|
||||
|
||||
private final Paint mPaint = new Paint();
|
||||
|
||||
public CheckInfoListGridItemDec() {
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
mPaint.setColor(Color.RED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
|
||||
super.onDraw(c, parent, state);
|
||||
RecyclerView.LayoutManager manager = parent.getLayoutManager();
|
||||
if (manager instanceof GridLayoutManager) {
|
||||
//表格的边框主要是由分割线和下分割线
|
||||
for (int i = 0; i < parent.getChildCount(); ++i) {
|
||||
//获取子元素
|
||||
View child = parent.getChildAt(i);
|
||||
//我们首先来制作子元素右分割线,或者说纵向分割线
|
||||
setUpVerticalDivider(child, c);
|
||||
//制作横向分割线
|
||||
setUpHorizontalDivider(child, c);
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("LayoutManager使用错误");
|
||||
}
|
||||
}
|
||||
|
||||
private void setUpVerticalDivider(View child, Canvas canvas) {
|
||||
float left = child.getRight();
|
||||
float top = child.getTop();
|
||||
float right = left + DIVIDER_SIZE;
|
||||
float bottom = child.getBottom() + DIVIDER_SIZE;
|
||||
canvas.drawRect(left, top, right, bottom, mPaint);
|
||||
}
|
||||
|
||||
private void setUpHorizontalDivider(View child, Canvas canvas) {
|
||||
float left = child.getLeft();
|
||||
float top = child.getBottom();
|
||||
float right = child.getRight();
|
||||
float bottom = top + DIVIDER_SIZE;
|
||||
canvas.drawRect(left, top, right, bottom, mPaint);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
|
||||
super.getItemOffsets(outRect, view, parent, state);
|
||||
outRect.set(0, 0, DIVIDER_SIZE, DIVIDER_SIZE);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#767FCD"/>
|
||||
<stroke android:width="3px"/>
|
||||
</shape>
|
||||
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="@dimen/dp_405"
|
||||
android:layout_height="@dimen/dp_127">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/info_check_icon"
|
||||
android:layout_width="@dimen/dp_40"
|
||||
android:layout_height="@dimen/dp_40"
|
||||
android:layout_marginLeft="@dimen/dp_40"
|
||||
android:src="@drawable/check_right" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/info_result_tx"
|
||||
android:text="正常"
|
||||
android:textColor="#fff"
|
||||
android:textSize="@dimen/dp_38"
|
||||
app:layout_constraintLeft_toRightOf="@+id/info_check_icon" />
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -6,5 +6,6 @@
|
||||
@android:drawable/progress_indeterminate_horizontal
|
||||
</item>
|
||||
<item name="android:progressDrawable">@drawable/check_progress</item>
|
||||
<item name="android:listDivider">@drawable/check_driver</item>
|
||||
</style>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user