From 325cbd4255d035b7bd72fbc51e88096eaaa03e60 Mon Sep 17 00:00:00 2001
From: lizhanwei <Dana_Lee1016@126.com>
Date: 星期一, 13 一月 2020 17:25:52 +0800
Subject: [PATCH] NDK_start时传递 map和车辆;联网考试项目正在进行考试为粉红色、考试通过为绿色、考试项目失败为红色

---
 app/src/main/java/safeluck/drive/evaluation/Constant.java                      |    2 
 app/src/main/java/safeluck/drive/evaluation/app.java                           |    6 +
 app/src/main/res/values/attrs.xml                                              |    2 
 app/src/main/java/safeluck/drive/evaluation/bean/ExamStatus.java               |   35 +++++++++++
 app/src/main/java/safeluck/drive/evaluation/customview/ArrowView.java          |    6 ++
 app/src/main/java/safeluck/drive/evaluation/customview/HouseView.java          |    5 +
 app/src/main/java/safeluck/drive/evaluation/fragment/NetWorkTrainFragment.java |  107 ++++++++++++++++++++++++++++++-----
 app/src/main/res/values/colors.xml                                             |    3 +
 8 files changed, 149 insertions(+), 17 deletions(-)

diff --git a/app/src/main/java/safeluck/drive/evaluation/Constant.java b/app/src/main/java/safeluck/drive/evaluation/Constant.java
index 84e427a..7e792d4 100644
--- a/app/src/main/java/safeluck/drive/evaluation/Constant.java
+++ b/app/src/main/java/safeluck/drive/evaluation/Constant.java
@@ -60,4 +60,6 @@
     public static final String RTK_LOGIN_CODE_COLUMN = "RTK_LOGIN_CODE_COLUMN";
     public static final String RTK_CONN_STATUS_COLUMN = "RTK_CONN_STATUS_COLUMN";
     public static final String WORK_PLATFORM_STATUS_COLUMN = "WORK_PLATFORM_STATUS_COLUMN";
+
+    public static final int ENTER_OR_EXIT_ITEM = 0x000D;
 }
diff --git a/app/src/main/java/safeluck/drive/evaluation/app.java b/app/src/main/java/safeluck/drive/evaluation/app.java
index 4da6324..64bcfbf 100644
--- a/app/src/main/java/safeluck/drive/evaluation/app.java
+++ b/app/src/main/java/safeluck/drive/evaluation/app.java
@@ -119,7 +119,8 @@
         MyLog.d(TAG, String.format("鏀跺埌鍛戒护[%d],Json鍐呭涓�%s", cmd, json));
         switch (cmd) {
             case Constant.NDK_START:
-
+                sendVechileInfo();
+                sendMapInfo();
                 break;
             case Constant.RTK_PLATFORM_REGISTER_STATUS:
                 CEventCenter.dispatchEvent(Constant.BIND_CONNECT_RTK_TOPIC,cmd,0,json);
@@ -195,6 +196,9 @@
                 OneTimeWorkRequest gpsinfoWorkRequest = new OneTimeWorkRequest.Builder(GpsInfoWorker.class).setInputData(gpsData).build();
                 WorkManager.getInstance(getApplicationContext()).enqueue(gpsinfoWorkRequest);
                 break;
+            case Constant.ENTER_OR_EXIT_ITEM:
+
+                break;
 
         }
 
diff --git a/app/src/main/java/safeluck/drive/evaluation/bean/ExamStatus.java b/app/src/main/java/safeluck/drive/evaluation/bean/ExamStatus.java
new file mode 100644
index 0000000..dda0fa4
--- /dev/null
+++ b/app/src/main/java/safeluck/drive/evaluation/bean/ExamStatus.java
@@ -0,0 +1,35 @@
+package safeluck.drive.evaluation.bean;
+
+public class ExamStatus {
+//    1 - 鍊掑簱
+//2 - 鍧¤捣
+//3 - 渚ф柟鍋滆溅
+//4 - 鏇茬嚎琛岄┒
+//5 - 鐩磋杞集
+    private int map_id;
+
+    //0 閫�鍑猴紙鑰冭瘯瀹屾瘯锛�
+    //1 杩涘叆锛堟鍦ㄨ繘琛岃�冭瘯锛�  2-寰呰��
+    private int enter;
+
+    public ExamStatus(int map_id, int enter) {
+        this.map_id = map_id;
+        this.enter = enter;
+    }
+
+    public int getMap_id() {
+        return map_id;
+    }
+
+    public void setMap_id(int map_id) {
+        this.map_id = map_id;
+    }
+
+    public int getEnter() {
+        return enter;
+    }
+
+    public void setEnter(int enter) {
+        this.enter = enter;
+    }
+}
diff --git a/app/src/main/java/safeluck/drive/evaluation/customview/ArrowView.java b/app/src/main/java/safeluck/drive/evaluation/customview/ArrowView.java
index 85e3cd7..b2d69f5 100644
--- a/app/src/main/java/safeluck/drive/evaluation/customview/ArrowView.java
+++ b/app/src/main/java/safeluck/drive/evaluation/customview/ArrowView.java
@@ -11,6 +11,7 @@
 import android.util.TypedValue;
 import android.view.View;
 
+import androidx.annotation.ColorRes;
 import androidx.annotation.Nullable;
 
 import safeluck.drive.evaluation.R;
@@ -44,6 +45,7 @@
         super(context, attrs, defStyleAttr);
         TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ArrowView,defStyleAttr,0);
         text = a.getString(R.styleable.ArrowView_text);
+        color = a.getColor(R.styleable.ArrowView_color,Color.parseColor("#99C3D1"));
         a.recycle();
     }
 
@@ -76,4 +78,8 @@
         }
         return keys;
     }
+
+    public void setColor( int mColor){
+        this.color = mColor;
+    }
 }
diff --git a/app/src/main/java/safeluck/drive/evaluation/customview/HouseView.java b/app/src/main/java/safeluck/drive/evaluation/customview/HouseView.java
index 6fb30bd..82dda01 100644
--- a/app/src/main/java/safeluck/drive/evaluation/customview/HouseView.java
+++ b/app/src/main/java/safeluck/drive/evaluation/customview/HouseView.java
@@ -41,6 +41,7 @@
         super(context, attrs, defStyleAttr);
         TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ArrowView,defStyleAttr,0);
         text = typedArray.getString(R.styleable.ArrowView_text);
+        color = typedArray.getColor(R.styleable.ArrowView_color,Color.parseColor("#99C3D1"));
         typedArray.recycle();
     }
 
@@ -76,4 +77,8 @@
         }
         return keys;
     }
+
+    public void setColor(int mColor){
+        this.color = mColor;
+    }
 }
diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/NetWorkTrainFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/NetWorkTrainFragment.java
index 6b2620d..f491f88 100644
--- a/app/src/main/java/safeluck/drive/evaluation/fragment/NetWorkTrainFragment.java
+++ b/app/src/main/java/safeluck/drive/evaluation/fragment/NetWorkTrainFragment.java
@@ -35,8 +35,11 @@
 import safeluck.drive.evaluation.DB.failitems.FailedProj_select;
 import safeluck.drive.evaluation.R;
 import safeluck.drive.evaluation.adapter.ScoreAdapter;
+import safeluck.drive.evaluation.bean.ExamStatus;
 import safeluck.drive.evaluation.bean.ScoreBean;
 import safeluck.drive.evaluation.cEventCenter.CEventCenter;
+import safeluck.drive.evaluation.customview.ArrowView;
+import safeluck.drive.evaluation.customview.HouseView;
 
 /**
  * 鑱旂綉璁粌UI
@@ -48,9 +51,13 @@
 public class NetWorkTrainFragment extends SupportFragment implements View.OnClickListener {
 
     private static final String TAG = NetWorkTrainFragment.class.getSimpleName();
-    private ListView mListView ;
+    private ListView mListView;
     private Button btn_start_exam;
     private ScoreAdapter mScoreAdapter;
+    private ArrowView av_zhijiao, av_curve, av_park, av_podao;
+    private HouseView houseView;
+    private List<ExamStatus> examStatusList = new ArrayList<>();
+    private List<String> item_conents = new ArrayList<>();//鍧¢亾瀹氱偣鍋滆溅鍜岃捣姝�
 
     private int item_id;//鎵e垎鍒嗘暟鎬诲拰
 
@@ -63,7 +70,7 @@
     @Nullable
     @Override
     public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
-        View view = inflater.inflate(R.layout.layout_train_fragment,container,false);
+        View view = inflater.inflate(R.layout.layout_train_fragment, container, false);
         initView(view);
 
         FailedProjViewModel failedProjViewModel = ViewModelProviders.of(this).get(FailedProjViewModel.class);
@@ -72,21 +79,89 @@
             public void onChanged(List<FailedProj_select> failedProj_selects) {
                 item_id = 0;
                 mArrayList.clear();
+                item_conents.clear();
                 for (FailedProj_select f :
                         failedProj_selects) {
                     item_id += f.getScore_deducting();
-                    Log.i(TAG, "onChanged: "+f.toString());
-                    mArrayList.add(new ScoreBean(f.getScore_deducting(),f.getItem_content(),f.getDeducting_reason()));
+                    Log.i(TAG, "onChanged: " + f.toString());
+                    mArrayList.add(new ScoreBean(f.getScore_deducting(), f.getItem_content(), f.getDeducting_reason()));
+                    item_conents.add(f.getItem_content());
                     mScoreAdapter.addDatas(mArrayList);
                 }
             }
         });
 
-
+        item_conents.add("渚ф柟鍋滆溅");
         return view;
     }
 
+    private int whatPaintColor(ExamStatus examStatus) {
+        int map_id = examStatus.getMap_id();
+        int status = examStatus.getEnter();
+        switch (status) {
+            case 0://鑰冭瘯瀹屾垚
+                switch (map_id) {
+                    case 1://鍊掑簱
+                        if (item_conents.contains("鍊掕溅鍏ュ簱")) {
+                            return getResources().getColor(R.color.colorAccent);
+                        }else{
+                            return getResources().getColor(R.color.train_btn_return);
+                        }
+                    case 2:
+                        if (item_conents.contains("鍧¢亾瀹氱偣鍋滆溅鍜岃捣姝�")) {
+                            return getResources().getColor(R.color.colorAccent);
+                        }else{
+                            return getResources().getColor(R.color.train_btn_return);
+                        }
+                    case 3:
+                        if (item_conents.contains("渚ф柟鍋滆溅")) {
+                            return getResources().getColor(R.color.colorAccent);
+                        }else{
+                            return getResources().getColor(R.color.train_btn_return);
+                        }
+                    case 4:
+                        if (item_conents.contains("鏇茬嚎琛岄┒")) {
+                            return getResources().getColor(R.color.colorAccent);
+                        }else{
+                            return getResources().getColor(R.color.train_btn_return);
+                        }
+                    case 5:
+                        if (item_conents.contains("鐩磋杞集")) {
+                            return getResources().getColor(R.color.colorAccent);
+                        }else{
+                            return getResources().getColor(R.color.train_btn_return);
+                        }
+
+                }
+            case 1://杩涘叆鑰冨満椤圭洰
+                return getResources().getColor(R.color.pink);
+            case 2://寰呰��
+                return getResources().getColor(R.color.examing);
+        }
+        return getResources().getColor(R.color.examing);
+    }
+
     private void initView(View view) {
+
+        av_curve = view.findViewById(R.id.av2);
+        av_park = view.findViewById(R.id.av3);
+        av_podao = view.findViewById(R.id.av4);
+        av_zhijiao = view.findViewById(R.id.av1);
+        houseView = view.findViewById(R.id.hv);
+//绮夌孩鑹叉鍦ㄨ繘琛岃椤圭洰鐨勮�冭瘯
+        examStatusList.add(new ExamStatus(1, 2));
+        examStatusList.add(new ExamStatus(2, 1));
+        examStatusList.add(new ExamStatus(3, 0));
+        examStatusList.add(new ExamStatus(4, 2));
+        examStatusList.add(new ExamStatus(5, 1));
+
+
+        av_curve.setColor(whatPaintColor(examStatusList.get(3)));
+        av_zhijiao.setColor(whatPaintColor(examStatusList.get(4)));
+        av_podao.setColor(whatPaintColor(examStatusList.get(1)));
+        av_park.setColor(whatPaintColor(examStatusList.get(2)));
+        houseView.setColor(whatPaintColor(examStatusList.get(0)));
+
         sendRTKConfig2RemoteService();
         mListView = view.findViewById(R.id.lv);
         mListView.setFocusable(false);
@@ -96,23 +171,25 @@
         btn_start_exam = view.findViewById(R.id.btn_start);
         btn_start_exam.setOnClickListener(this);
         view.findViewById(R.id.tv_stop).setOnClickListener(this);
-        mListView.addHeaderView(LayoutInflater.from(_mActivity).inflate(R.layout.layout_score_item,null));
+        mListView.addHeaderView(LayoutInflater.from(_mActivity).inflate(R.layout.layout_score_item, null));
 
     }
+
     private void sendRTKConfig2RemoteService() {
 //        MyLog.d(TAG,"涓诲姩鎺ㄩ�丷TKConfig");
 //        CEventCenter.dispatchEvent(Constant.BIND_RTKCONFIG_TOPIC,Constant.FETCH_RTK_PLATFORM_INFO,0,"");
     }
+
     @Override
     public void onClick(View v) {
-        switch (v.getId()){
+        switch (v.getId()) {
             case R.id.btn_start:
                 try {
                     JSONObject jsonObject = new JSONObject();
-                    jsonObject.put("exam",1);
+                    jsonObject.put("exam", 1);
                     String examJson = jsonObject.toString();
-                    Log.i(TAG, "onClick: "+examJson);
-                    AYSdk.getInstance().sendCmd(Constant.EXAM_STATUS,examJson);
+                    Log.i(TAG, "onClick: " + examJson);
+                    AYSdk.getInstance().sendCmd(Constant.EXAM_STATUS, examJson);
                 } catch (JSONException e) {
                     e.printStackTrace();
                 }
@@ -121,18 +198,18 @@
                 Toast.makeText(_mActivity, "缁撴潫鑰冭瘯", Toast.LENGTH_SHORT).show();
                 try {
                     JSONObject jsonObject = new JSONObject();
-                    jsonObject.put("exam",0);
+                    jsonObject.put("exam", 0);
                     String examJson = jsonObject.toString();
-                    Log.i(TAG, "onClick: "+examJson);
-                    AYSdk.getInstance().sendCmd(Constant.EXAM_STATUS,examJson);
+                    Log.i(TAG, "onClick: " + examJson);
+                    AYSdk.getInstance().sendCmd(Constant.EXAM_STATUS, examJson);
                 } catch (JSONException e) {
                     e.printStackTrace();
                 }
                 break;
             case R.id.view_map:
                 MapFragment mapFragment = findFragment(MapFragment.class);
-                if (mapFragment==null){
-                    mapFragment = (MapFragment)MapFragment.newInstance();
+                if (mapFragment == null) {
+                    mapFragment = (MapFragment) MapFragment.newInstance();
                 }
                 start(mapFragment);
                 break;
diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml
index a2b1087..61e42b8 100644
--- a/app/src/main/res/values/attrs.xml
+++ b/app/src/main/res/values/attrs.xml
@@ -8,10 +8,10 @@
     </declare-styleable>
     <declare-styleable name="ArrowView">
         <attr name="text" format="string" />
+        <attr name="color" format="color" />
 
     </declare-styleable>
     <declare-styleable name="HouseView">
         <attr name="item" format="string" />
-
     </declare-styleable>
 </resources>
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index f65ffa3..9882094 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -11,4 +11,7 @@
     <color name="train_bg">#4aabb2</color>
     <color name="train_btn_return">#16aa3c</color>
     <color name="profile_bg">#1988a3</color>
+    <color name="pink">#FF3399</color>
+    <color name="examing">#99C3D1</color>
+    <color name="red">#DC143C</color>
 </resources>

--
Gitblit v1.8.0