[add] 930-UI push弹框 交警详情

This commit is contained in:
liujing
2021-10-26 15:42:58 +08:00
parent 19df7023ef
commit bd707078da
16 changed files with 574 additions and 32 deletions

View File

@@ -0,0 +1,55 @@
package com.mogo.eagle.core.function.hmi.ui.notice;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.mogo.eagle.core.function.hmi.R;
/**
* @author liujing
* @description 描述
* @since: 10/26/21
*/
class NoticeTrafficAdapter extends RecyclerView.Adapter {
LayoutInflater mLayoutInflater;
public NoticeTrafficAdapter(@NonNull Context context) {
mLayoutInflater = LayoutInflater.from(context);
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = mLayoutInflater.inflate(R.layout.notice_traffice_info_list_adapter, parent,
false);
TrafficInfoHolder holder = new TrafficInfoHolder(v);
return holder;
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
}
@Override
public int getItemCount() {
return 18;
}
public class TrafficInfoHolder extends RecyclerView.ViewHolder {
private TextView keyText;
private TextView valueText;
public TrafficInfoHolder(@NonNull View itemView) {
super(itemView);
keyText = itemView.findViewById(R.id.key_text_view);
valueText = itemView.findViewById(R.id.value_text_view);
}
}
}

View File

@@ -0,0 +1,50 @@
package com.mogo.eagle.core.function.hmi.ui.notice;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.mogo.eagle.core.function.hmi.R;
import com.mogo.module.common.dialog.BaseFloatDialog;
import java.util.List;
/**
* @author liujing
* @description 描述
* @since: 10/26/21
*/
public class NoticeTrafficDialog extends BaseFloatDialog {
private Context mContext;
private RecyclerView mRecyclerView;
public NoticeTrafficDialog(@NonNull Context context) {
super(context);
mContext = context;
initView();
}
public NoticeTrafficDialog(@NonNull Context context, int themeResId) {
super(context, themeResId);
}
public void initView() {
mRecyclerView = findViewById(R.id.traffic_info_recyclerView);
//网格布局
GridLayoutManager layoutManager = new GridLayoutManager(mContext, 4);
mRecyclerView.setLayoutManager(layoutManager);
layoutManager.setOrientation(GridLayoutManager.VERTICAL);
//网格绘制
try {
NoticeTrafficInfoGridItemDivider gridLayoutDivider = new NoticeTrafficInfoGridItemDivider(1,
(mContext.getResources().getColor(R.color.notice_dialog_back)));
mRecyclerView.addItemDecoration(gridLayoutDivider);
} catch (Exception e) {
e.printStackTrace();
}
NoticeTrafficAdapter adapter = new NoticeTrafficAdapter(mContext);
mRecyclerView.setAdapter(adapter);
}
}

View File

@@ -0,0 +1,165 @@
package com.mogo.eagle.core.function.hmi.ui.notice;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
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 NoticeTrafficInfoGridItemDivider extends RecyclerView.ItemDecoration {
private String TAG = getClass().getSimpleName();
private static final int[] ATTRS = new int[]{android.R.attr.listDivider};
private Drawable divider;
public NoticeTrafficInfoGridItemDivider(Context context) {
final TypedArray a = context.obtainStyledAttributes(ATTRS);
divider = a.getDrawable(0);
a.recycle();
}
public NoticeTrafficInfoGridItemDivider(Drawable drawable) {
divider = drawable;
}
public NoticeTrafficInfoGridItemDivider(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 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());
}
}
}

View File

@@ -0,0 +1,42 @@
package com.mogo.eagle.core.function.hmi.ui.notice;
import android.content.Context;
import android.util.AttributeSet;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import com.mogo.eagle.core.function.hmi.R;
/**
* @author liujing
* @description 交通事故任务详情
* @since: 10/26/21
*/
public class NoticeTrafficInfoView extends RecyclerView {
private int maxHeight = (int) getContext().getResources().getDimension(R.dimen.notice_traffic_info_width);
private int maxWeight = (int) getContext().getResources().getDimension(R.dimen.notice_traffic_info_height);
public NoticeTrafficInfoView(@NonNull Context context) {
super(context);
}
public NoticeTrafficInfoView(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public NoticeTrafficInfoView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onMeasure(int widthSpec, int heightSpec) {
super.onMeasure(widthSpec, heightSpec);
int limitHeight = getMeasuredHeight();
if (getMeasuredHeight() > maxHeight) {
limitHeight = maxHeight;
}
setMeasuredDimension(maxWeight, limitHeight);
}
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?><!--<selector xmlns:android="http://schemas.android.com/apk/res/android">-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="135"
android:endColor="#80000000"
android:startColor="#80000000"
android:type="linear" />
<corners android:radius="@dimen/dp_30" />
</shape>

View File

@@ -30,7 +30,28 @@
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<!--图/视频-->
<ImageView
android:id="@+id/back_image"
android:layout_width="@dimen/notice_traffic_acc_image_width"
android:layout_height="@dimen/notice_traffic_acc_image_height"
android:layout_marginLeft="@dimen/dp_200"
android:layout_marginTop="@dimen/dp_50"
android:layout_marginRight="@dimen/dp_200"
android:src="@drawable/notice_unsuccess_image"
app:layout_constraintBottom_toTopOf="@+id/module_push_dialog_bottom_title"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/notice_traffic_dialog_title" />
<!--事故来源等事故详情-->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/traffic_info_recyclerView"
android:layout_width="@dimen/notice_traffic_info_width"
android:layout_height="@dimen/notice_traffic_info_height"
android:layout_marginTop="@dimen/dp_38"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/back_image" />
<!--分割线-->
<ImageView
android:id="@+id/traffic_top_line"
@@ -53,9 +74,10 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="接受"
android:text="接 受"
android:textColor="@color/notice_text_blue"
android:textSize="@dimen/dp_50"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="@+id/traffic_middle_line"
@@ -64,9 +86,10 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="拒绝"
android:textColor="@color/notice_text_blue"
android:text="拒 绝"
android:textColor="#FFF"
android:textSize="@dimen/dp_50"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="@+id/traffic_middle_line"
app:layout_constraintRight_toRightOf="parent"

View File

@@ -0,0 +1,88 @@
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="@dimen/dp_1066"
android:layout_height="@dimen/dp_230"
android:layout_marginTop="@dimen/dp_20"
android:background="@drawable/notice_push_item_background">
<ImageView
android:id="@+id/module_push_image"
android:layout_width="@dimen/dp_230"
android:layout_height="@dimen/dp_230"
android:scaleType="fitXY"
android:src="@drawable/notice_banner_default"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="@+id/module_push_app_icon_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_30"
android:layout_marginRight="@dimen/dp_220"
android:gravity="center_vertical"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@+id/module_push_image"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/module_push_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center_vertical|left"
android:maxWidth="@dimen/dp_184"
android:maxLength="25"
android:singleLine="true"
android:textColor="@android:color/white"
android:textSize="@dimen/dp_46"
app:layout_constrainedWidth="true"
tools:text="官方公告" />
<TextView
android:id="@+id/module_push_content"
android:layout_width="@dimen/dp_588"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_22"
android:ellipsize="end"
android:gravity="top|left"
android:maxLines="2"
android:paddingRight="@dimen/dp_10"
android:text="这是测试数据,当前测试数据是为了查看换行的显示效果,如果最多3行呢,怎么显示的呢"
android:textColor="@android:color/white"
android:textSize="@dimen/dp_36" />
</LinearLayout>
<View
android:id="@+id/module_push_line"
android:layout_width="@dimen/dp_2"
android:layout_height="@dimen/dp_120"
android:layout_marginRight="@dimen/dp_208"
android:background="#FFF"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@+id/module_push_app_icon_title"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/notice_traffic_push_check"
android:layout_width="@dimen/dp_100"
android:layout_height="match_parent"
android:layout_marginRight="@dimen/dp_67"
android:clickable="true"
android:focusable="true"
android:gravity="center"
android:text="查看"
android:textColor="@color/notice_banner_blue"
android:textSize="@dimen/dp_42"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="@+id/module_push_line"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,37 @@
<?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_580"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/key_text_view"
android:layout_width="@dimen/dp_180"
android:layout_height="@dimen/dp_50"
android:gravity="left|center"
android:text="事故来源:"
android:textColor="#FFF"
android:textSize="@dimen/dp_36" />
<TextView
android:id="@+id/value_text_view"
android:layout_width="@dimen/dp_180"
android:layout_height="wrap_content"
android:gravity="left|center"
android:maxLines="2"
android:text="平台发布平台发布平台发布平台发布"
android:textColor="#FFF"
android:textSize="@dimen/dp_36"
android:textStyle="bold" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -2,6 +2,8 @@
<resources>
<color name="notice_blue">#2B6EFF</color>
<color name="notice_text_blue">#1F9BFE</color>
<color name="notice_banner_blue">#5A8EFD</color>
<color name="notice_check_dialog_bg_color">#E63B4577</color>
<color name="notice_traffic_line">#D5D5D4</color>
<color name="notice_dialog_back">#3B4577</color>
</resources>

View File

@@ -4,14 +4,27 @@
<dimen name="module_push_dialog_check_accessory_height">1200px</dimen>
<dimen name="module_push_dialog_check_acc_image_width">1400px</dimen>
<dimen name="module_push_dialog_check_acc_image__height">788px</dimen>
<dimen name="notice_traffic_acc_image_width">900px</dimen>
<dimen name="notice_traffic_acc_image_height">506px</dimen>
<dimen name="notice_traffic_back__width">1300px</dimen>
<dimen name="notice_traffic_back__height">1210px</dimen>
<dimen name="notice_traffic_info_width">1160px</dimen>
<dimen name="notice_traffic_info_height">290px</dimen>
<dimen name="notice_dialog_check_bg_corner">32px</dimen>
<dimen name="dp_30">30px</dimen>
<dimen name="dp_36">36px</dimen>
<dimen name="dp_38">38px</dimen>
<dimen name="dp_42">42px</dimen>
<dimen name="dp_50">50px</dimen>
<dimen name="dp_52">52px</dimen>
<dimen name="dp_54">54px</dimen>
<dimen name="dp_56">56px</dimen>
<dimen name="dp_150">150px</dimen>
<dimen name="dp_180">180px</dimen>
<dimen name="dp_220">220px</dimen>
<dimen name="dp_580">580px</dimen>
<dimen name="dp_588">588px</dimen>
<dimen name="dp_1066">1066px</dimen>
</resources>

View File

@@ -2,6 +2,8 @@
<resources>
<color name="notice_blue">#2B6EFF</color>
<color name="notice_text_blue">#1F9BFE</color>
<color name="notice_banner_blue">#5A8EFD</color>
<color name="notice_check_dialog_bg_color">#E63B4577</color>
<color name="notice_traffic_line">#D5D5D4</color>
<color name="notice_dialog_back">#3B4577</color>
</resources>

View File

@@ -4,14 +4,28 @@
<dimen name="module_push_dialog_check_accessory_height">1200px</dimen>
<dimen name="module_push_dialog_check_acc_image_width">1400px</dimen>
<dimen name="module_push_dialog_check_acc_image__height">788px</dimen>
<dimen name="notice_traffic_acc_image_width">900px</dimen>
<dimen name="notice_traffic_acc_image_height">506px</dimen>
<dimen name="notice_traffic_back__width">1300px</dimen>
<dimen name="notice_traffic_back__height">1210px</dimen>
<dimen name="notice_traffic_info_width">1160px</dimen>
<dimen name="notice_traffic_info_height">290px</dimen>
<dimen name="notice_dialog_check_bg_corner">32px</dimen>
<dimen name="dp_30">30px</dimen>
<dimen name="dp_36">36px</dimen>
<dimen name="dp_38">38px</dimen>
<dimen name="dp_42">42px</dimen>
<dimen name="dp_50">50px</dimen>
<dimen name="dp_52">52px</dimen>
<dimen name="dp_54">54px</dimen>
<dimen name="dp_56">56px</dimen>
<dimen name="dp_150">150px</dimen>
<dimen name="dp_180">180px</dimen>
<dimen name="dp_220">220px</dimen>
<dimen name="dp_580">580px</dimen>
<dimen name="dp_588">588px</dimen>
<dimen name="dp_1066">1066px</dimen>
</resources>