网格绘制,待修改,缺少云端数据赋值
This commit is contained in:
@@ -16,7 +16,7 @@ import org.w3c.dom.Text;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 点击自动驾驶icon显示指标详情结果
|
||||
* @description 点击自动驾驶icon显示各个检测指标结果
|
||||
* @since: 9/23/21
|
||||
*/
|
||||
public class CheckInfoAdapter extends RecyclerView.Adapter {
|
||||
@@ -40,6 +40,13 @@ 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("模块名称");
|
||||
}else if (position == 1 || position == 3){
|
||||
((CheckInfoViewHolder)holder).checkIcon.setVisibility(View.GONE);
|
||||
((CheckInfoViewHolder)holder).mTextView.setText("运行状态");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import androidx.recyclerview.widget.StaggeredGridLayoutManager;
|
||||
* @description 描述
|
||||
* @since: 9/22/21
|
||||
*/
|
||||
public class CheckInfoGridItemDivider extends RecyclerView.ItemDecoration {
|
||||
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;
|
||||
@@ -107,6 +107,18 @@ 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.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++) {
|
||||
@@ -123,6 +135,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,8 +181,7 @@ public class CheckInfoGridItemDivider extends RecyclerView.ItemDecoration {
|
||||
// 如果是最后一行,则不需要绘制底部
|
||||
if (pos >= childCount)
|
||||
return true;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
// 如果是最后一行,则不需要绘制底部
|
||||
if ((pos + 1) % spanCount == 0) {
|
||||
return true;
|
||||
|
||||
@@ -35,14 +35,18 @@ public class CheckInfoListDialog extends BaseFloatDialog {
|
||||
public void initView() {
|
||||
setContentView(R.layout.check_info_list);
|
||||
mRecyclerView = findViewById(R.id.check_list_recycler);
|
||||
// GridLayoutManager layoutManager = new GridLayoutManager(mContext, 4);
|
||||
// mRecyclerView.setLayoutManager(layoutManager);
|
||||
//表示竖直显示.默认VERTICAL
|
||||
// layoutManager.setOrientation(GridLayoutManager.HORIZONTAL);
|
||||
// CheckInfoGridItemDivider gridLayoutDivider = new CheckInfoGridItemDivider(2, Color.parseColor("#CCCCCC"));
|
||||
// mRecyclerView.addItemDecoration(gridLayoutDivider);
|
||||
//网格布局
|
||||
GridLayoutManager layoutManager = new GridLayoutManager(mContext, 4);
|
||||
mRecyclerView.setLayoutManager(layoutManager);
|
||||
layoutManager.setOrientation(GridLayoutManager.VERTICAL);
|
||||
//网格绘制
|
||||
try {
|
||||
CheckInfoGridItemDivider gridLayoutDivider = new CheckInfoGridItemDivider(2, Color.parseColor("#CCCCCC"));
|
||||
mRecyclerView.addItemDecoration(gridLayoutDivider);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
mRecyclerView.setAdapter(new CheckInfoAdapter(mContext));
|
||||
|
||||
//关闭按钮
|
||||
findViewById(R.id.cancel_info_list_button).setOnClickListener(v -> {
|
||||
cancel();
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
android:src="@drawable/check_right" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/info_result_tx"
|
||||
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"
|
||||
|
||||
@@ -17,9 +17,10 @@
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/check_info_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_89"
|
||||
android:layout_marginTop="@dimen/dp_69"
|
||||
android:gravity="center"
|
||||
android:text="自检结果"
|
||||
android:textColor="#fff"
|
||||
@@ -29,13 +30,15 @@
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/check_list_recycler"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/check_list_recycler"
|
||||
android:layout_marginLeft="@dimen/dp_143"
|
||||
android:layout_marginTop="@dimen/dp_143"
|
||||
android:layout_marginTop="@dimen/dp_184"
|
||||
android:layout_marginRight="@dimen/dp_143"
|
||||
android:layout_marginBottom="@dimen/dp_143"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Reference in New Issue
Block a user