From 7c3b8b6084bab565c3af60026a11636cdf65a051 Mon Sep 17 00:00:00 2001
From: endian11 <Dana_Lee1016@126.com>
Date: 星期四, 17 九月 2020 11:41:11 +0800
Subject: [PATCH] 完善开始训练(道路)选择线路、发送消息等;开始采集后输入线路名称,检查有无重名;重名提示;
---
app/src/main/assets/routeline.json | 51 ++++++++++
app/src/main/java/safeluck/drive/evaluation/DB/route/RouteBean.java | 15 ++
app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java | 185 +++++++++++++++++++++++-------------
app/src/main/java/safeluck/drive/evaluation/customview/SelectMutliDialog.java | 29 ++---
app/src/main/java/safeluck/drive/evaluation/customview/MyInputDialog.kt | 2
5 files changed, 196 insertions(+), 86 deletions(-)
diff --git a/app/src/main/assets/routeline.json b/app/src/main/assets/routeline.json
new file mode 100644
index 0000000..2022663
--- /dev/null
+++ b/app/src/main/assets/routeline.json
@@ -0,0 +1,51 @@
+[
+ {
+ "name":"绾胯矾涓�",
+ "crossing_active":[
+ {
+ "road":2,
+ "idx":0,
+ "active":1
+ },
+ {
+ "road":2,
+ "idx":1,
+ "active":1
+ }
+ ],
+ "trigger_line":[
+ {
+ "x_y":[
+ 333.365,
+ 696.3354
+ ],
+ "road":2,
+ "type":2
+ },
+ {
+ "x_y":[
+ 333.365,
+ 696.3354
+ ],
+ "road":5,
+ "type":4
+ },
+ {
+ "x_y":[
+ 333.365,
+ 696.3354
+ ],
+ "road":3,
+ "type":3
+ },
+ {
+ "x_y":[
+ 333.365,
+ 696.3354
+ ],
+ "road":6,
+ "type":1
+ }
+ ]
+ }
+]
\ No newline at end of file
diff --git a/app/src/main/java/safeluck/drive/evaluation/DB/route/RouteBean.java b/app/src/main/java/safeluck/drive/evaluation/DB/route/RouteBean.java
index 4fd42c5..a1a0854 100644
--- a/app/src/main/java/safeluck/drive/evaluation/DB/route/RouteBean.java
+++ b/app/src/main/java/safeluck/drive/evaluation/DB/route/RouteBean.java
@@ -1,5 +1,8 @@
package safeluck.drive.evaluation.DB.route;
+import android.os.Parcel;
+import android.os.Parcelable;
+
import androidx.room.Entity;
import androidx.room.PrimaryKey;
@@ -10,7 +13,7 @@
* All Rights Saved! Chongqing AnYun Tech co. LTD
*/
@Entity
-public class RouteBean {
+public class RouteBean implements Parcelable {
@PrimaryKey(autoGenerate = true)
private int id;
private String routeName;
@@ -30,4 +33,14 @@
public void setRouteName(String routeName) {
this.routeName = routeName;
}
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+
+ }
}
diff --git a/app/src/main/java/safeluck/drive/evaluation/customview/MyInputDialog.kt b/app/src/main/java/safeluck/drive/evaluation/customview/MyInputDialog.kt
index ae84c75..8e176b5 100644
--- a/app/src/main/java/safeluck/drive/evaluation/customview/MyInputDialog.kt
+++ b/app/src/main/java/safeluck/drive/evaluation/customview/MyInputDialog.kt
@@ -20,7 +20,7 @@
import safeluck.drive.evaluation.R
/**
- *
+ *甯︽湁杈撳叆妗嗙殑dialog
* @ProjectName: DriveJudge
* @Package: safeluck.drive.evaluation.customview
* @ClassName: MyDialog
diff --git a/app/src/main/java/safeluck/drive/evaluation/customview/SelectMutliDialog.java b/app/src/main/java/safeluck/drive/evaluation/customview/SelectMutliDialog.java
index d78d502..c93f1b7 100644
--- a/app/src/main/java/safeluck/drive/evaluation/customview/SelectMutliDialog.java
+++ b/app/src/main/java/safeluck/drive/evaluation/customview/SelectMutliDialog.java
@@ -5,6 +5,7 @@
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.os.Bundle;
+import android.os.Parcelable;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater;
@@ -58,7 +59,7 @@
public static final int SELECT_NONE = -1;
private int result = SELECT_NONE;
- private ArrayList<String> stringArrayList;
+ private List<RouteBean> routeBeanList;
private RecyclerView mRecy;
private RouteSelectAdapter mAdapter;
@@ -82,8 +83,8 @@
}
View view = inflater.inflate(R.layout.layout_select_dlg_multi,container,false);
Bundle bundle = getArguments();
- if (bundle != null){
- stringArrayList = bundle.getStringArrayList("content");
+ if (bundle != null) {
+ routeBeanList = bundle.getParcelableArrayList("content");
}
initView(view);
return view;
@@ -101,6 +102,7 @@
@Override
public void onItemClick(int position, View view) {
Toast.makeText(getActivity(), position+"", Toast.LENGTH_SHORT).show();
+ result = routeBeanList.get(position).getId();
if (onSelectedListener != null){
onSelectedListener.makeYourChoice(result);
}
@@ -112,15 +114,8 @@
@Override
public void run() {
// Init Datas
- ArrayList<String> menues = new ArrayList<>(Arrays.asList(getResources().getStringArray(R.array.array_large_item_menu)));
- List<RouteBean> items = new ArrayList<>();
- for (int i = 0; i < menues.size(); i++) {
- RouteBean item = new RouteBean();
- item.setRouteName(menues.get(i));
- item.setId(i);
- items.add(item);
- }
- mAdapter.setDatas(items);
+
+ mAdapter.setDatas(routeBeanList);
}
});
// button = view.findViewById(R.id.btn_sure_);
@@ -164,16 +159,14 @@
- public static SelectMutliDialog newInstance(String... args){
+ public static SelectMutliDialog newInstance( List<RouteBean> args){
SelectMutliDialog sle = new SelectMutliDialog();
- if (args != null && args.length>=2){
- List<String> strs = Arrays.asList(args);
- ArrayList<String> list = new ArrayList<>(strs);
+
Bundle bundle = new Bundle();
- bundle.putStringArrayList("content",list);
+ bundle.putParcelableArrayList("content", (ArrayList<? extends Parcelable>) args);
sle.setArguments(bundle);
- }
+
return sle;
diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java
index 700c286..d2b8b6d 100644
--- a/app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java
+++ b/app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java
@@ -40,6 +40,7 @@
import com.google.gson.Gson;
+import org.jetbrains.annotations.NotNull;
import org.json.JSONException;
import org.json.JSONObject;
@@ -632,73 +633,55 @@
}else if (res == SelectDialogThree.THIRD){
sendJK0202(4);
}else{
- Toast.makeText(_mActivity, "绾胯矾閲囬泦", Toast.LENGTH_SHORT).show();
- ExamPlatformData.getInstance().setTrainingMode(ExamPlatformData.TRAINING_MODE);
- exam_type = 5;
- examStatusViewModel.updateStartExam(exam_type);
- items.setVisibility(View.GONE);
- items_score.setVisibility(View.GONE);
- route_collect.setVisibility(View.VISIBLE);
+ MyInputDialog myDialog = MyInputDialog.Companion.newInstance("鎮ㄥ皢閫�鍑虹郴缁�,璇风‘璁ゆ暟鎹凡淇濆瓨");
+
+
+
+ myDialog.show(getFragmentManager(),"MyInputDialog");
+
+ myDialog.setOnClick(new MyInputDialog.MyOnClickListener() {
+ @Override
+ public void onSure(@NotNull String string) {
+ //杈撳叆绾胯矾鍚嶇О涔嬪悗 鐐瑰嚮纭畾鎵嶈兘璁や负鏄紑濮嬮噰闆�
+ boolean flag = false;//鏍囪鏄惁鏈夐噸鍚嶇殑绾胯矾锛屽鏋滄湁鍒欎负true
+ for (RouteBean bean:mRouteBeans){
+ if (string.equalsIgnoreCase(bean.getRouteName())){
+ //鏈夐噸鍚嶇殑绾胯矾锛屾彁绀虹敤鎴峰苟涓嶅紑鍚嚎璺噰闆�
+ Toast.makeText(_mActivity, "璇ョ嚎璺悕绉板凡琚娇鐢紝璇锋洿鎹�", Toast.LENGTH_SHORT).show();
+ flag = true;
+ break;
+ }
+ }
+ if (!flag){
+ RouteBean routeBean = new RouteBean();
+ routeBean.setRouteName(string);
+ routeLineViewModel.insertRouteBean(routeBean);
+ Toast.makeText(_mActivity, "绾胯矾閲囬泦", Toast.LENGTH_SHORT).show();
+ ExamPlatformData.getInstance().setTrainingMode(ExamPlatformData.TRAINING_MODE);
+ exam_type = 5;
+ examStatusViewModel.updateStartExam(exam_type);
+ items.setVisibility(View.GONE);
+ items_score.setVisibility(View.GONE);
+ route_collect.setVisibility(View.VISIBLE);
+ }
+
+ }
+
+ @Override
+ public void onCancle() {
+
+ }
+ });
+
}
}
});
selectDialog.show(getFragmentManager(),"selectdialog");
}else{
if (exam_type == ROUTE_COLLECT){
- List<RouteCollect.CrossingActiveBean> crossingActiveBeans = new ArrayList<>();
- List<RouteCollect.TriggerLineBean> triggerLineBeans = new ArrayList<>();
- List<Double> xy = new ArrayList<>();
- RemoteRouteCollect remoteRouteCollect = new RemoteRouteCollect();
- RouteCollect routeCollect = new RouteCollect();
- List<RouteCollect> routeCollects = new ArrayList<>();
+
Toast.makeText(_mActivity, "缁撴潫閲囬泦", Toast.LENGTH_SHORT).show();
- CThreadPoolExecutor.runInBackground(new Runnable() {
- @Override
- public void run() {
- for (RouteBean routeBean:mRouteBeans){
- int id = routeBean.getId();
- routeCollect.setName(routeBean.getRouteName());
- List<RouteTriggerLine> routeTriggerLines = WorkRoomDataBase.getWorkRoomDataBase(getContext().getApplicationContext()).getRouteTriggerLineDao().getAllRouteTriggerLine(id);
- List<RouteCross> routeCrosses = WorkRoomDataBase.getWorkRoomDataBase(getContext().getApplicationContext()).getRouteCrooDao().getAllRouteCross(id);
- for (RouteTriggerLine line:routeTriggerLines){
- RouteCollect.TriggerLineBean triggerLineBean = new RouteCollect.TriggerLineBean();
- int road = line.getRoad();
- int type = line.getType();
-
- double x = line.getX();
- double y = line.getY();
- xy.clear();
- xy.add(x);
- xy.add(y);
- triggerLineBean.setRoad(road);
- triggerLineBean.setType(type);
- triggerLineBean.setX_y(xy);
- triggerLineBeans.add(triggerLineBean);
-
-
- }
- routeCollect.setTrigger_line(triggerLineBeans);
-
- for (RouteCross routeCross:routeCrosses){
- int idx = routeCross.getIdx();
- int road = routeCross.getRoad();
- int active = routeCross.getActive();
- RouteCollect.CrossingActiveBean crossingActiveBean = new RouteCollect.CrossingActiveBean();
- crossingActiveBean.setActive(active);
- crossingActiveBean.setIdx(idx);
- crossingActiveBean.setRoad(road);
- crossingActiveBeans.add(crossingActiveBean);
- }
- routeCollect.setCrossing_active(crossingActiveBeans);
- routeCollects.add(routeCollect);
-
- }
- remoteRouteCollect.setScheme(routeCollects);
- String str = new Gson().toJson(remoteRouteCollect);
- Log.i(TAG,"json====="+str);
- }
- });
ExamPlatformData.getInstance().setTrainingMode(ExamPlatformData.MODE_NONE);
exam_type = 0;
examStatusViewModel.updateStartExam(exam_type);
@@ -723,11 +706,7 @@
// startArcGisMapFragment(url);
// StatusDialog.with(_mActivity).setCancelable(true).setPrompt("鍔犺浇涓紝璇风◢鍚�...").setType(StatusDialog.Type.PROGRESS).show();
- SelectMutliDialog myDialog = SelectMutliDialog.newInstance("鎮ㄥ皢閫�鍑虹郴缁�,璇风‘璁ゆ暟鎹凡淇濆瓨");
-
-
- myDialog.show(getFragmentManager(),"mydialog");
break;
case R.id.iv_head:
MyLog.i(TAG,"瀛﹀憳绛惧埌");
@@ -799,18 +778,27 @@
}
private void sendJK0202(int type) {
+
+ if (type==3|| type==4){
+
+ sendRouteLine();
+ }
+
//闅愯棌閲囬泦椤圭洰
items_score.setVisibility(View.VISIBLE);
items.setVisibility(View.VISIBLE);
route_collect.setVisibility(View.GONE);
- final JKMessage0202 jkMessage0202 = new JKMessage0202();
+
exam_type = type;
ExamPlatformData.getInstance().setTrainingMode(ExamPlatformData.TRAINING_MODE);
ExamPlatformData.getInstance().setExamType(exam_type);
examStatusViewModel.updateStartExam(exam_type);
- sendExamJson(1,exam_type);
ExamPlatformData.getInstance().getTTS().speak("寮�濮嬭缁�");
+ }
+ private void sendMessage() {
+ sendExamJson(1,exam_type);
+ final JKMessage0202 jkMessage0202 = new JKMessage0202();
Date date = new Date();
wokViewModel.updateBeginTime(date.getTime());
jkMessage0202.timeBCD = date;
@@ -818,7 +806,7 @@
jkMessage0202.stu_id = ExamPlatformData.getInstance().getID();
jkMessage0202.coach_id = ExamPlatformData.getInstance().getCoachID();
jkMessage0202.exam_id = ExamPlatformData.getInstance().getExam_id();
- if (type > ExamPlatformData.EXAM_TYPE_ChangKAO){
+ if (exam_type > ExamPlatformData.EXAM_TYPE_ChangKAO){
jkMessage0202.curr_exam = 1;// 璺熺Щ鍔ㄧ珯鏈嶅姟瀹氫箟鐨勫満鑰冩槸2 锛屽钩鍙版槸0 锛� 绉诲姩绔欒矾鑰冩槸3 锛屽钩鍙版槸1
}else{
@@ -829,6 +817,71 @@
MessageProcessor.getInstance().sendMessage(jkMessage0202);
}
+ private void sendRouteLine() {
+
+ SelectMutliDialog selectMutliDialog = SelectMutliDialog.newInstance(mRouteBeans);
+ selectMutliDialog.show(getFragmentManager(),"multidialog");
+ selectMutliDialog.setSelectedListener(new SelectMutliDialog.OnSelectedListener() {
+ @Override
+ public void makeYourChoice(int res) {
+
+ List<RouteCollect.CrossingActiveBean> crossingActiveBeans = new ArrayList<>();
+ List<RouteCollect.TriggerLineBean> triggerLineBeans = new ArrayList<>();
+ List<Double> xy = new ArrayList<>();
+ RemoteRouteCollect remoteRouteCollect = new RemoteRouteCollect();
+ RouteCollect routeCollect = new RouteCollect();
+ List<RouteCollect> routeCollects = new ArrayList<>();
+ int id = res;
+ CThreadPoolExecutor.runInBackground(new Runnable() {
+ @Override
+ public void run() {
+
+ routeCollect.setName(mRouteBeans.get(id).getRouteName());
+ List<RouteTriggerLine> routeTriggerLines = WorkRoomDataBase.getWorkRoomDataBase(getContext().getApplicationContext()).getRouteTriggerLineDao().getAllRouteTriggerLine(id);
+ List<RouteCross> routeCrosses = WorkRoomDataBase.getWorkRoomDataBase(getContext().getApplicationContext()).getRouteCrooDao().getAllRouteCross(id);
+ for (RouteTriggerLine line:routeTriggerLines){
+ RouteCollect.TriggerLineBean triggerLineBean = new RouteCollect.TriggerLineBean();
+ int road = line.getRoad();
+ int type = line.getType();
+
+ double x = line.getX();
+ double y = line.getY();
+ xy.clear();
+ xy.add(x);
+ xy.add(y);
+ triggerLineBean.setRoad(road);
+ triggerLineBean.setType(type);
+ triggerLineBean.setX_y(xy);
+ triggerLineBeans.add(triggerLineBean);
+
+
+ }
+ routeCollect.setTrigger_line(triggerLineBeans);
+
+ for (RouteCross routeCross:routeCrosses){
+ int idx = routeCross.getIdx();
+ int road = routeCross.getRoad();
+ int active = routeCross.getActive();
+ RouteCollect.CrossingActiveBean crossingActiveBean = new RouteCollect.CrossingActiveBean();
+ crossingActiveBean.setActive(active);
+ crossingActiveBean.setIdx(idx);
+ crossingActiveBean.setRoad(road);
+ crossingActiveBeans.add(crossingActiveBean);
+ }
+ routeCollect.setCrossing_active(crossingActiveBeans);
+ routeCollects.add(routeCollect);
+
+ remoteRouteCollect.setScheme(routeCollects);
+ String str = new Gson().toJson(remoteRouteCollect);
+ Log.i(TAG,"json====="+str);
+ //todo 鍙戦�佺嚎璺�
+ sendMessage();
+ }
+ });
+ }
+ });
+ }
+
private void sendExamJson(int i,int type) {
try {
--
Gitblit v1.8.0