main
huangwei 9 months ago
parent f5be8d917c
commit 22531334bb
  1. 2
      app/src/main/java/com/project/survey/App.java
  2. 43
      app/src/main/java/com/project/survey/model/CodeBean.java
  3. 2
      app/src/main/java/com/project/survey/ui/pointmeasure/measure/CodeLibraryActivity.java
  4. 178
      app/src/main/java/com/project/survey/ui/pointmeasure/measure/CodeModelLibraryActivity.java
  5. 20
      app/src/main/java/com/project/survey/ui/pointmeasure/measure/CodeStylePointLineActivity.java
  6. 177
      app/src/main/java/com/project/survey/ui/pointmeasure/measure/CodeStyleSurfaceActivity.java
  7. 13
      app/src/main/java/com/project/survey/ui/pointmeasure/measure/PickerColorActivity.java
  8. 158
      app/src/main/java/com/project/survey/ui/pointmeasure/measure/adapter/CodeStyleAdapter.java
  9. 99
      app/src/main/res/layout/activity_code_model_library.xml
  10. 76
      app/src/main/res/layout/activity_code_style_point_line.xml
  11. 191
      app/src/main/res/layout/activity_code_style_surface.xml
  12. 32
      app/src/main/res/layout/layout_code_style_item.xml
  13. 12
      app/src/main/res/values/strings.xml

@ -10,6 +10,7 @@ import com.bingce.data.database.DBQueryConstant;
import com.bingce.data.database.KeyValueDb; import com.bingce.data.database.KeyValueDb;
import com.bingce.data.database.ProjectCoordinateDatabase; import com.bingce.data.database.ProjectCoordinateDatabase;
import com.bingce.data.database.ProjectDb; import com.bingce.data.database.ProjectDb;
import com.bingce.data.database.RoadJobLineDatabase;
import com.bingce.data.database.SurveyRecordDatabase; import com.bingce.data.database.SurveyRecordDatabase;
import com.bingce.data.database.SyncRecordDatabase; import com.bingce.data.database.SyncRecordDatabase;
import com.bingce.data.surveyor.designdata.project.ProjectConstants; import com.bingce.data.surveyor.designdata.project.ProjectConstants;
@ -84,6 +85,7 @@ public class App extends Application {
ProjectCoordinateDatabase.openDb(this, null); ProjectCoordinateDatabase.openDb(this, null);
SurveyRecordDatabase.openDb(this, null); SurveyRecordDatabase.openDb(this, null);
SyncRecordDatabase.openDb(this, null); SyncRecordDatabase.openDb(this, null);
RoadJobLineDatabase.openDb(this, null);
} }
public boolean isThemeDark() { public boolean isThemeDark() {

@ -0,0 +1,43 @@
package com.project.survey.model;
import androidx.annotation.Keep;
@Keep
public class CodeBean {
private String codeName;
private String Group;
private String Code;
private String style;
public String getCodeName() {
return codeName;
}
public void setCodeName(String codeName) {
this.codeName = codeName;
}
public String getGroup() {
return Group;
}
public void setGroup(String group) {
this.Group = group;
}
public String getCode() {
return Code;
}
public void setCode(String code) {
this.Code = code;
}
public String getStyle() {
return style;
}
public void setStyle(String style) {
this.style = style;
}
}

@ -30,10 +30,12 @@ import com.bingce.data.surveyor.surveydata.code.CodeRecord;
import com.bingce.surveyor.util.ConstUtils; import com.bingce.surveyor.util.ConstUtils;
import com.bingce.surveyor.util.dialog.CustomDialog; import com.bingce.surveyor.util.dialog.CustomDialog;
import com.bingce.utils.ThreadPoolUtil; import com.bingce.utils.ThreadPoolUtil;
import com.google.gson.Gson;
import com.project.survey.App; import com.project.survey.App;
import com.project.survey.R; import com.project.survey.R;
import com.project.survey.databinding.ActivityCodeLibraryBinding; import com.project.survey.databinding.ActivityCodeLibraryBinding;
import com.project.survey.ui.base.BaseSurveyNewActivity; import com.project.survey.ui.base.BaseSurveyNewActivity;
import com.project.survey.ui.instrument.setupstation.LauncherEvent;
import com.project.survey.ui.pointmeasure.measure.adapter.CodeLibraryAdapter; import com.project.survey.ui.pointmeasure.measure.adapter.CodeLibraryAdapter;
import java.util.List; import java.util.List;

@ -0,0 +1,178 @@
package com.project.survey.ui.pointmeasure.measure;
import static com.project.survey.ui.pointmeasure.measure.util.CodeConsUtils.SHAPE_TYPE_LINE;
import static com.project.survey.ui.pointmeasure.measure.util.CodeConsUtils.SHAPE_TYPE_POINT;
import static com.project.survey.ui.pointmeasure.measure.util.CodeConsUtils.SHAPE_TYPE_SURFACE;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import androidx.activity.result.ActivityResultLauncher;
import androidx.lifecycle.Observer;
import com.bingce.data.database.CodeDb;
import com.bingce.data.database.DBQueryConstant;
import com.bingce.data.surveyor.surveydata.code.CodeConstants;
import com.bingce.data.surveyor.surveydata.code.CodeRecord;
import com.bingce.utils.IdUtils;
import com.bingce.utils.ThreadPoolUtil;
import com.project.survey.R;
import com.project.survey.databinding.ActivityCodeModelLibraryBinding;
import com.project.survey.model.CodeBean;
import com.project.survey.ui.base.BaseSurveyNewActivity;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import blankj.utilcode.util.ToastUtils;
public class CodeModelLibraryActivity extends BaseSurveyNewActivity {
private ActivityCodeModelLibraryBinding binding;
private Map mapDb;
private List<CodeBean> codeBeans;
@Override
public View getContentView() {
binding = ActivityCodeModelLibraryBinding.inflate(getLayoutInflater());
return binding.getRoot();
}
@Override
protected void initView() {
setTitle(getString(R.string.code_model_library));
CodeDb.getInstance()
.rawQueryListLiveData(DBQueryConstant.findListByJob(CodeConstants.DB_NAME, ""))
.observe(this, new Observer<List<CodeRecord>>() {
@Override
public void onChanged(List<CodeRecord> codeList) {
mapDb = new HashMap();
for (int i = codeList.size() - 1; i >= 0; i--) {
mapDb.put(codeList.get(i).codeName, codeList.get(i).code);
}
}
});
}
@Override
protected void initData() {
binding.codeMoldLibBtnConfirm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
codeBeans = dom2xml(getAssets().open("CASS.xml"));
ThreadPoolUtil.execute(new Runnable() {
@Override
public void run() {
for (int i = codeBeans.size() - 1; i >= 0; i--) {
if (!mapDb.containsKey(codeBeans.get(i).getCodeName()) || !mapDb.containsValue(codeBeans.get(i).getCode())) {
CodeRecord codeRecord = new CodeRecord();
codeRecord.id = IdUtils.getUUID();
switch (codeBeans.get(i).getGroup()) {
case "point":
codeRecord.codeGroupType = 0;
break;
case "line":
codeRecord.codeGroupType = 1;
break;
case "surface":
codeRecord.codeGroupType = 2;
break;
}
codeRecord.codeName = codeBeans.get(i).getCodeName();
codeRecord.code = codeBeans.get(i).getCode();
codeRecord.colorShape = getResources().getColor(R.color.theme_green);
codeRecord.codeSizeShape = 0;
switch (codeRecord.codeGroupType) {
case SHAPE_TYPE_POINT:
codeRecord.codeFeatureShape = 0;
codeRecord.codeColorContour = getResources().getColor(R.color.theme_green);//点线时候轮廓线默认为colorShape
break;
case SHAPE_TYPE_LINE:
codeRecord.codeFeatureShape = 0;
codeRecord.codeColorContour = getResources().getColor(R.color.theme_green);//点线时候轮廓线默认为colorShape
break;
case SHAPE_TYPE_SURFACE:
codeRecord.codeFeatureShape = 0;
codeRecord.codeColorContour = getResources().getColor(R.color.theme_green);//面的时候使用
break;
}
CodeDb.getInstance().save(codeRecord);
}
}
runOnUiThread(new Runnable() {
@Override
public void run() {
ToastUtils.showShort(getString(R.string.import_successful) + "!");
finish();
}
});
}
});
} catch (Exception e) {
ToastUtils.showShort(e.getMessage().toString());
e.printStackTrace();
}
}
});
}
public List<CodeBean> dom2xml(InputStream is) throws Exception {
//一系列的初始化
List<CodeBean> list = new ArrayList<>();
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
//获得Document对象
Document document = builder.parse(is);
//获得code的List
NodeList codeList = document.getElementsByTagName("CodeItem");
//遍历code标签
for (int i = 0; i < codeList.getLength(); i++) {
//获得code标签
Node node_code = codeList.item(i);
//获得code标签里面的标签
NodeList codeNodes = node_code.getChildNodes();
//新建code对象
CodeBean codeBean = new CodeBean();
//遍历code标签里面的标签
for (int j = 0; j < codeNodes.getLength(); j++) {
//获得标签
Node codeNode = codeNodes.item(j);
//判断是标签
if ("Name".equals(codeNode.getNodeName())) {
String name = codeNode.getTextContent();
codeBean.setCodeName(name);
} else if ("Code".equals(codeNode.getNodeName())) {
String code = codeNode.getTextContent();
codeBean.setCode(code);
} else if ("Group".equals(codeNode.getNodeName())) {
String group = codeNode.getTextContent();
codeBean.setGroup(group);
} else if ("Style".equals(codeNode.getNodeName())) {
String style = codeNode.getTextContent();
codeBean.setStyle(style);
}
}
//加到List中
list.add(codeBean);
}
return list;
}
public static void start(ActivityResultLauncher<Intent> launcher, Context context) {
launcher.launch(new Intent(context, CodeModelLibraryActivity.class));
}
}

@ -2,6 +2,22 @@ package com.project.survey.ui.pointmeasure.measure;
import static com.project.survey.ui.pointmeasure.measure.util.CodeConsUtils.SHAPE_CENTER_CIRCLE;
import static com.project.survey.ui.pointmeasure.measure.util.CodeConsUtils.SHAPE_CIRCLE_EMPTY;
import static com.project.survey.ui.pointmeasure.measure.util.CodeConsUtils.SHAPE_CIRCLE_FULL;
import static com.project.survey.ui.pointmeasure.measure.util.CodeConsUtils.SHAPE_RHOMBUS_EMPTY;
import static com.project.survey.ui.pointmeasure.measure.util.CodeConsUtils.SHAPE_RHOMBUS_FULL;
import static com.project.survey.ui.pointmeasure.measure.util.CodeConsUtils.SHAPE_ROUNDED_FIVE_STAR;
import static com.project.survey.ui.pointmeasure.measure.util.CodeConsUtils.SHAPE_SQUARE_EMPTY;
import static com.project.survey.ui.pointmeasure.measure.util.CodeConsUtils.SHAPE_SQUARE_FULL;
import static com.project.survey.ui.pointmeasure.measure.util.CodeConsUtils.SHAPE_STRAIGHT_FIVE_STAR;
import static com.project.survey.ui.pointmeasure.measure.util.CodeConsUtils.SHAPE_TRIANGLE_DOWN_EMPTY;
import static com.project.survey.ui.pointmeasure.measure.util.CodeConsUtils.SHAPE_TRIANGLE_DOWN_FULL;
import static com.project.survey.ui.pointmeasure.measure.util.CodeConsUtils.SHAPE_TRIANGLE_UP_EMPTY;
import static com.project.survey.ui.pointmeasure.measure.util.CodeConsUtils.SHAPE_TRIANGLE_UP_FULL;
import static com.project.survey.ui.pointmeasure.measure.util.CodeConsUtils.SHAPE_TYPE_LINE;
import static com.project.survey.ui.pointmeasure.measure.util.CodeConsUtils.SHAPE_TYPE_POINT;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.view.View; import android.view.View;
@ -14,7 +30,11 @@ import com.bingce.surveyor.util.ConstUtils;
import com.bingce.surveyor.util.dialog.CustomRecycleDialog; import com.bingce.surveyor.util.dialog.CustomRecycleDialog;
import com.bingce.utils.IntentUtil; import com.bingce.utils.IntentUtil;
import com.project.survey.R;
import com.project.survey.databinding.ActivityCodeStylePointLineBinding;
import com.project.survey.ui.base.BaseSurveyNewActivity; import com.project.survey.ui.base.BaseSurveyNewActivity;
import com.project.survey.ui.instrument.setupstation.LauncherEvent;
import com.project.survey.ui.pointmeasure.measure.adapter.CodeStyleAdapter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

@ -0,0 +1,177 @@
package com.project.survey.ui.pointmeasure.measure;
import static com.project.survey.ui.pointmeasure.measure.util.CodeConsUtils.SHAPE_TYPE_LINE;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.GradientDrawable;
import android.view.View;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import com.bingce.surveyor.util.ConstUtils;
import com.bingce.utils.IntentUtil;
import com.project.survey.R;
import com.project.survey.databinding.ActivityCodeStyleSurfaceBinding;
import com.project.survey.ui.base.BaseSurveyNewActivity;
import com.project.survey.ui.instrument.setupstation.LauncherEvent;
import com.project.survey.util.CommonUtils;
import com.project.survey.util.DrawableUtils;
public class CodeStyleSurfaceActivity extends BaseSurveyNewActivity {
private ActivityCodeStyleSurfaceBinding binding;
private int contourColor,fillColor;
private int codeShapeSizeIndex = 0;
private int codeStyleIndexLine = 0;
private boolean isEditFillColor;
@Override
public View getContentView() {
binding = ActivityCodeStyleSurfaceBinding.inflate(getLayoutInflater());
return binding.getRoot();
}
@Override
protected void initView() {
setTitle(getString(R.string.style));
}
@Override
protected void initData() {
contourColor = IntentUtil.intExtra(getIntent(),KEY_CONTOUR_COLOR);
fillColor = IntentUtil.intExtra(getIntent(),KEY_FILL_COLOR);
codeShapeSizeIndex = IntentUtil.intExtra(getIntent(),KEY_CODE_SHAPE_SIZE_INDEX);
codeStyleIndexLine = IntentUtil.intExtra(getIntent(),KEY_CODE_STYLE_INDEX_LINE);
setCodeStyle();
binding.ivContourColorPalette.setImageDrawable(DrawableUtils.tintModifyColorDrawable(getDrawable(R.drawable.icon_code_color_palette), contourColor));
binding.ivFillColorPalette.setBackgroundColor(fillColor);
previewStyle();
binding.rlContourStyle.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CodeStylePointLineActivity.start(launcher, CodeStyleSurfaceActivity.this, SHAPE_TYPE_LINE, contourColor, codeShapeSizeIndex, 0,codeStyleIndexLine);
}
});
binding.rlContourColor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
isEditFillColor = false;
PickerColorActivity.start(launcher, CodeStyleSurfaceActivity.this, contourColor);
}
});
binding.rlFillColor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
isEditFillColor = true;
PickerColorActivity.start(launcher, CodeStyleSurfaceActivity.this, fillColor);
}
});
binding.styleCodeBtnConfirm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.putExtra(ConstUtils.intentConst.keyCodeStyleIndexLine, codeStyleIndexLine);
intent.putExtra(ConstUtils.intentConst.keyCodeShapeSize, codeShapeSizeIndex);
intent.putExtra(ConstUtils.intentConst.keyCodeShapeContourColor, contourColor);
intent.putExtra(ConstUtils.intentConst.keyCodeShapeFillColor, fillColor);
setResult(LauncherEvent.launcher_code_shape_surface,intent);
finish();
}
});
}
/**
* 样式
*/
private void setCodeStyle() {
GradientDrawable gradientDrawable = (GradientDrawable)binding.contourStyle.getBackground();
int lineWidth = 0;
switch (codeShapeSizeIndex){
case 0:
lineWidth = CommonUtils.dip2px(0.8f);
break;
case 1:
lineWidth = CommonUtils.dip2px(1.3f);
break;
case 2:
lineWidth = CommonUtils.dip2px(1.8f);
break;
}
gradientDrawable.setStroke(lineWidth, contourColor,CommonUtils.dip2px(codeStyleIndexLine + codeStyleIndexLine * 2),CommonUtils.dip2px(codeStyleIndexLine + codeStyleIndexLine * 2));
gradientDrawable.setColor(getColor(R.color.white));
}
private static String KEY_FILL_COLOR = "keyFillColor";
private static String KEY_CONTOUR_COLOR = "keyContourColor";
private static String KEY_CODE_SHAPE_SIZE_INDEX = "keyCodeShapeSizeIndex";
private static String KEY_CODE_STYLE_INDEX_LINE = "keyCodeStyleIndexLine";
public static void start(ActivityResultLauncher<Intent> launcher,Context context,int codeShapeColor,int contourColor,int codeShapeSizeIndex,int codeStyleIndexLine){
Intent intent = new Intent(context, CodeStyleSurfaceActivity.class);
intent.putExtra(KEY_FILL_COLOR,codeShapeColor);
intent.putExtra(KEY_CONTOUR_COLOR,contourColor);
intent.putExtra(KEY_CODE_SHAPE_SIZE_INDEX,codeShapeSizeIndex);
intent.putExtra(KEY_CODE_STYLE_INDEX_LINE,codeStyleIndexLine);
launcher.launch(intent);
}
public final ActivityResultLauncher<Intent> launcher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
if (result != null) {
switch (result.getResultCode()){
case LauncherEvent.launcher_add_code_color:
int color = result.getData().getIntExtra(ConstUtils.intentConst.keyAddCodeColor, -1);
if (!isEditFillColor){
contourColor = color;
setCodeStyle();
binding.ivContourColorPalette.setImageDrawable(DrawableUtils.tintModifyColorDrawable(getDrawable(R.drawable.icon_code_color_palette),color));
}else {
fillColor = color;
binding.ivFillColorPalette.setBackgroundColor(color);
}
previewStyle();
break;
case LauncherEvent.launcher_code_style:
codeStyleIndexLine = result.getData().getIntExtra(ConstUtils.intentConst.keyCodeStyleIndexLine,0);
codeShapeSizeIndex = result.getData().getIntExtra(ConstUtils.intentConst.keyCodeShapeSize,0);
setCodeStyle();
previewStyle();
break;
}
}
});
private void previewStyle(){
GradientDrawable gradientDrawable = (GradientDrawable)binding.tvPreviewStyle.getBackground();
int lineWidth = 0;
switch (codeShapeSizeIndex){
case 0:
lineWidth = CommonUtils.dip2px(0.8f);
break;
case 1:
lineWidth = CommonUtils.dip2px(1.3f);
break;
case 2:
lineWidth = CommonUtils.dip2px(1.8f);
break;
}
gradientDrawable.setStroke(lineWidth, contourColor,CommonUtils.dip2px(codeStyleIndexLine + codeStyleIndexLine * 2),CommonUtils.dip2px(codeStyleIndexLine + codeStyleIndexLine * 2));
gradientDrawable.setColor(fillColor);
}
}

@ -33,14 +33,11 @@ public class PickerColorActivity extends BaseSurveyNewActivity {
protected void initView() { protected void initView() {
setTitle(getString(R.string.picker_color)); setTitle(getString(R.string.picker_color));
binding.pickerCodeBtnConfirm.setOnClickListener(new View.OnClickListener() { binding.pickerCodeBtnConfirm.setOnClickListener(v -> {
@Override Intent intent = new Intent();
public void onClick(View v) { intent.putExtra(ConstUtils.intentConst.keyAddCodeColor, selectColor);
Intent intent = new Intent(); setResult(LauncherEvent.launcher_add_code_color,intent);
intent.putExtra(ConstUtils.intentConst.keyAddCodeColor, selectColor); finish();
setResult(LauncherEvent.launcher_add_code_color,intent);
finish();
}
}); });
int defultColor = IntentUtil.intExtra(getIntent(), DEFULT_COLOR); int defultColor = IntentUtil.intExtra(getIntent(), DEFULT_COLOR);

@ -0,0 +1,158 @@
package com.project.survey.ui.pointmeasure.measure.adapter;
import static com.project.survey.ui.pointmeasure.measure.util.CodeConsUtils.SHAPE_TYPE_LINE;
import static com.project.survey.ui.pointmeasure.measure.util.CodeConsUtils.SHAPE_TYPE_POINT;
import android.content.Context;
import android.graphics.drawable.GradientDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.project.survey.R;
import com.project.survey.ui.pointmeasure.measure.util.CodeConsUtils;
import com.project.survey.util.CommonUtils;
import com.project.survey.util.DrawableUtils;
import java.util.List;
public class CodeStyleAdapter extends RecyclerView.Adapter<CodeStyleAdapter.SimpleHolder> {
private Context context;
private List<Integer> list;
private int codeShapeType;
private int codeShapeColor;
private int codeShapeSize;
private int selectPosition;
private OnItemClickListener mOnItemClickListener;
public CodeStyleAdapter(Context context, int selectPosition, List<Integer> list , int codeShapeType, int codeShapeColor, int codeShapeSize) {
this.context = context;
this.selectPosition = selectPosition;
this.list = list;
this.codeShapeType = codeShapeType;
this.codeShapeColor = codeShapeColor;
this.codeShapeSize = codeShapeSize;
}
@NonNull
@Override
public SimpleHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(context).inflate(R.layout.layout_code_style_item, parent, false);
return new SimpleHolder(view);
}
@Override
public void onBindViewHolder(@NonNull SimpleHolder holder, int position) {
if (codeShapeType == SHAPE_TYPE_POINT){
holder.pointView.setVisibility(View.VISIBLE);
holder.lineView.setVisibility(View.GONE);
//点列表
ViewGroup.LayoutParams params = holder.pointView.getLayoutParams();
switch (codeShapeSize){
case 0:
params.width = CommonUtils.dip2px(5);
params.height = CommonUtils.dip2px(5);
break;
case 1:
params.width = CommonUtils.dip2px(10);
params.height = CommonUtils.dip2px(10);
break;
case 2:
params.width = CommonUtils.dip2px(15);
params.height = CommonUtils.dip2px(15);
break;
}
holder.pointView.setLayoutParams(params);
if (selectPosition == position){
holder.pointView.setImageDrawable(DrawableUtils.tintModifyColorDrawable(context.getDrawable(CodeConsUtils.showPointIcon(position)),context.getColor(R.color.white)));
holder.llBg.setBackgroundColor(codeShapeColor);
}else {
holder.pointView.setImageDrawable(DrawableUtils.tintModifyColorDrawable(context.getDrawable(CodeConsUtils.showPointIcon(position)), codeShapeColor));
holder.llBg.setBackgroundColor(context.getColor(R.color.white));
}
}else if (codeShapeType == SHAPE_TYPE_LINE){
//线列表
holder.pointView.setVisibility(View.GONE);
holder.lineView.setVisibility(View.VISIBLE);
GradientDrawable gradientDrawable = (GradientDrawable)holder.lineView.getBackground();
int lineWidth = 0;
switch (codeShapeSize){
case 0:
lineWidth = CommonUtils.dip2px(0.8f);
break;
case 1:
lineWidth = CommonUtils.dip2px(1.3f);
break;
case 2:
lineWidth = CommonUtils.dip2px(1.8f);
break;
}
if (selectPosition == position){
gradientDrawable.setStroke(lineWidth,context.getColor(R.color.white),CommonUtils.dip2px(position + position * 2),CommonUtils.dip2px(position + position * 2));
holder.llBg.setBackgroundColor(codeShapeColor);
}else {
gradientDrawable.setStroke(lineWidth,codeShapeColor,CommonUtils.dip2px(position + position * 2),CommonUtils.dip2px(position + position * 2));
holder.llBg.setBackgroundColor(context.getColor(R.color.white));
}
}
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mOnItemClickListener.onItemClickListener(holder.getAdapterPosition());
}
});
}
@Override
public int getItemCount() {
return list == null ? 0:list.size();
}
public void setSelectedPosition(int selectPosition) {
this.selectPosition = selectPosition;
notifyDataSetChanged();
}
public void setShapeSize(List<Integer> list,int shapeSize) {
this.list = list;
this.codeShapeSize = shapeSize;
notifyDataSetChanged();
}
public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
this.mOnItemClickListener = onItemClickListener;
}
public interface OnItemClickListener {
void onItemClickListener(int position);
}
public class SimpleHolder extends RecyclerView.ViewHolder{
private ImageView pointView;
private View lineView;
private LinearLayout llBg;
public SimpleHolder(@NonNull View itemView) {
super(itemView);
pointView = itemView.findViewById(R.id.pointView);
lineView = itemView.findViewById(R.id.lineView);
llBg = itemView.findViewById(R.id.ll_bg);
}
}
}

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="75dp"
android:background="@color/white">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="10dp"
android:layout_toLeftOf="@+id/rl_num_check"
android:gravity="center_vertical"
android:orientation="vertical"
android:paddingLeft="15dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical">
<ImageView
android:id="@+id/iv_format_fixed"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_marginRight="4dp"
android:src="@drawable/icon_format_fixed" />
<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:ellipsize="end"
android:lines="1"
android:text="CASS"
android:textColor="@color/black"
android:textSize="14.5sp"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="系统默认"
android:textColor="@color/color_8a8a8a"
android:textSize="11sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="@+id/rl_num_check"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:gravity="center_vertical"
android:paddingRight="15dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:text="185个"
android:textColor="@color/color_575757"
android:textSize="12sp" />
<ImageView
android:id="@+id/iv_checkbox"
android:layout_width="17dp"
android:layout_height="17dp"
android:src="@mipmap/icon_checkbox_select_ovel" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<Button
android:id="@+id/code_mold_lib_btn_confirm"
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="match_parent"
android:layout_height="@dimen/bt_height"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:text="@string/confirm" />
</LinearLayout>

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/rl_size"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginLeft="15dp"
android:layout_marginTop="15dp"
android:layout_marginRight="15dp"
android:background="@drawable/rectangle_radius_all_7_white_full">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="15dp"
android:text="尺寸"
android:textColor="@color/black"
android:textSize="15sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_marginRight="15dp"
android:gravity="center_vertical">
<TextView
android:id="@+id/tv_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:text="小"
android:textColor="@color/color_8a8a8a"
android:textSize="13.5sp" />
<ImageView
android:layout_width="13sp"
android:layout_height="wrap_content"
android:src="@drawable/icon_black_line_more" />
</LinearLayout>
</RelativeLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="15dp"
android:layout_marginTop="5dp"
android:layout_marginRight="15dp"
android:layout_marginBottom="5dp"
android:layout_weight="1">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.core.widget.NestedScrollView>
<Button
android:id="@+id/style_code_btn_confirm"
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="match_parent"
android:layout_height="@dimen/bt_height"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:text="@string/confirm" />
</LinearLayout>

@ -0,0 +1,191 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="15dp"
android:text="绘制"
android:textColor="@color/color_575757"
android:textStyle="bold"
android:textSize="15sp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="10dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:background="@drawable/rectangle_radius_5_white_full">
<RelativeLayout
android:id="@+id/rl_contour_style"
android:layout_width="match_parent"
android:layout_height="50dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="15dp"
android:textSize="15sp"
android:textColor="@color/color_575757"
android:textStyle="bold"
android:text="轮廓样式"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:layout_marginRight="15dp"
android:layout_alignParentRight="true">
<View
android:id="@+id/contour_style"
android:layout_width="45dp"
android:layout_height="22dp"
android:layout_marginRight="5dp"
android:background="@drawable/rectangle_radius_3_theme_green_full" />
<ImageView
android:layout_width="13sp"
android:layout_height="wrap_content"
android:src="@drawable/icon_black_line_more"/>
</LinearLayout>
</RelativeLayout>
<include layout="@layout/layout_dividing_line_theme_gray"/>
<RelativeLayout
android:id="@+id/rl_contour_color"
android:layout_width="match_parent"
android:layout_height="50dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="15dp"
android:textSize="15sp"
android:textColor="@color/color_575757"
android:textStyle="bold"
android:text="轮廓颜色"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:layout_marginRight="15dp"
android:layout_alignParentRight="true">
<ImageView
android:id="@+id/iv_contour_color_palette"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginRight="5dp"
android:background="@drawable/icon_code_color_palette" />
<ImageView
android:layout_width="13sp"
android:layout_height="wrap_content"
android:src="@drawable/icon_black_line_more"/>
</LinearLayout>
</RelativeLayout>
<include layout="@layout/layout_dividing_line_theme_gray"/>
<RelativeLayout
android:id="@+id/rl_fill_color"
android:layout_width="match_parent"
android:layout_height="50dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="15dp"
android:textSize="15sp"
android:textColor="@color/color_575757"
android:textStyle="bold"
android:text="填充颜色"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:layout_marginRight="15dp"
android:layout_alignParentRight="true">
<ImageView
android:id="@+id/iv_fill_color_palette"
android:layout_width="45dp"
android:layout_height="22dp"
android:layout_marginRight="5dp" />
<ImageView
android:layout_width="13sp"
android:layout_height="wrap_content"
android:src="@drawable/icon_black_line_more"/>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="15dp"
android:text="预览"
android:textColor="@color/color_575757"
android:textStyle="bold"
android:textSize="15sp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="vertical"
android:layout_marginTop="10dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:gravity="center"
android:background="@drawable/rectangle_radius_5_white_full">
<TextView
android:id="@+id/tv_preview_style"
android:layout_width="100dp"
android:layout_height="35dp"
android:layout_marginRight="5dp"
android:background="@drawable/rectangle_radius_3_theme_green_full" />
</LinearLayout>
</LinearLayout>
<Button
android:id="@+id/style_code_btn_confirm"
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="match_parent"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_height="@dimen/bt_height"
android:text="@string/confirm" />
</LinearLayout>

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/ll_bg"
android:layout_width="match_parent"
android:layout_height="48dp"
android:gravity="center">
<ImageView
android:id="@+id/pointView"
android:layout_width="8dp"
android:layout_height="8dp"
android:visibility="gone"/>
<View
android:id="@+id/lineView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="100dp"
android:layout_marginRight="100dp"
android:visibility="gone"
android:background="@drawable/shape_line_dp1" />
</LinearLayout>
<include layout="@layout/layout_dividing_line_theme_gray"/>
</LinearLayout>

@ -244,6 +244,18 @@
<string name="surface"></string> <string name="surface"></string>
<string name="add_success">添加成功!</string> <string name="add_success">添加成功!</string>
<string name="picker_color">选择颜色</string> <string name="picker_color">选择颜色</string>
<string name="small_size"></string>
<string name="medium_size"></string>
<string name="big_size"></string>
<string name="thin_size"></string>
<string name="coarse_size"></string>
<string name="select_code_edit">请选择一条要编辑的编码</string>
<string name="select_code_delete">请选择一条要删除的编码</string>
<string name="delete_success">删除成功!</string>
<string name="select_code_apply">请选择一条要应用的编码</string>
<string name="want_to_empty_code_library">确定要清空编码库所有的编码吗?</string>
<string name="code_model_library">编码模板库</string>
<string name="import_successful">导入成功</string>
</resources> </resources>
Loading…
Cancel
Save