From 0ab2d64977605ebb07a27c66e07d8ccee2fe0eaa Mon Sep 17 00:00:00 2001
From: lizhanwei <Dana_Lee1016@126.com>
Date: 星期五, 10 一月 2020 10:36:15 +0800
Subject: [PATCH] 在远程回调里删除UI相关toast;增加一个gps信息展示页面;增加对评判消息json数组的解析,并插入数据库

---
 app/src/main/java/safeluck/drive/evaluation/fragment/BaseSettingFragment.java  |    1 
 app/src/main/java/safeluck/drive/evaluation/app.java                           |   28 +++++++-------
 app/src/main/java/safeluck/drive/evaluation/adapter/SimpleFragmentAdapter.java |    6 ++
 app/src/main/java/safeluck/drive/evaluation/fragment/GpsInfoFragment.java      |   61 ++++++++++++++++++++++++++++++
 4 files changed, 81 insertions(+), 15 deletions(-)

diff --git a/app/src/main/java/safeluck/drive/evaluation/adapter/SimpleFragmentAdapter.java b/app/src/main/java/safeluck/drive/evaluation/adapter/SimpleFragmentAdapter.java
index 3de4266..746513c 100644
--- a/app/src/main/java/safeluck/drive/evaluation/adapter/SimpleFragmentAdapter.java
+++ b/app/src/main/java/safeluck/drive/evaluation/adapter/SimpleFragmentAdapter.java
@@ -9,6 +9,7 @@
 
 import me.yokeyword.fragmentation.SupportFragment;
 import safeluck.drive.evaluation.fragment.BaseDatasFragment;
+import safeluck.drive.evaluation.fragment.GpsInfoFragment;
 import safeluck.drive.evaluation.fragment.RTKConfigFragment;
 import safeluck.drive.evaluation.fragment.JiaXiaoFragment;
 
@@ -20,7 +21,7 @@
  * All Rights Saved! Chongqing AnYun Tech co. LTD
  */
 public class SimpleFragmentAdapter  extends FragmentPagerAdapter {
-    private String[] mTitles = new String[]{"鍩虹鏁版嵁","RTK閰嶇疆","椹炬牎淇℃伅"};
+    private String[] mTitles = new String[]{"鍩虹鏁版嵁","RTK閰嶇疆","椹炬牎淇℃伅","GPS淇℃伅"};
     public SimpleFragmentAdapter(FragmentManager fm) {
         super(fm);
     }
@@ -41,6 +42,9 @@
                 supportFragment = JiaXiaoFragment.newInstance();
                 //椹炬牎淇℃伅
                 break;
+            case 3:
+                supportFragment = GpsInfoFragment.newInstance();
+                break;
                 default:break;
         }
         return supportFragment;
diff --git a/app/src/main/java/safeluck/drive/evaluation/app.java b/app/src/main/java/safeluck/drive/evaluation/app.java
index 6465d57..3e7a830 100644
--- a/app/src/main/java/safeluck/drive/evaluation/app.java
+++ b/app/src/main/java/safeluck/drive/evaluation/app.java
@@ -1,6 +1,7 @@
 package safeluck.drive.evaluation;
 
 import android.app.Application;
+import android.text.TextUtils;
 import android.widget.Toast;
 
 
@@ -16,6 +17,9 @@
 import com.anyun.exam.lib.crash.CrashHandler;
 import com.facebook.stetho.Stetho;
 import com.google.gson.Gson;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
 
 
 import org.json.JSONException;
@@ -67,17 +71,7 @@
             Stetho.initializeWithDefaults(this);
 
 
-            //RTK閰嶇疆淇℃伅
-//            rtkConfig = new RTKConfig();
-//            rtkConfig.setCity(12);
-//            rtkConfig.setImei("460123874561");
-//            rtkConfig.setInterval(1);
-//            rtkConfig.setIp("47.93.80.84");
-//            rtkConfig.setModel("123");
-//            rtkConfig.setPhone("2019101500000001");
-//            rtkConfig.setPort(12125);
-//            rtkConfig.setProvince(23);
-//            rtkConfig.setSn("2019101500000001");
+ 
             //鏁版嵁搴撴搷浣�
             MyLog.i(TAG, "onCreate111");
             failedProjRepository = new FailedProjRepository(this);
@@ -104,7 +98,7 @@
         MyLog.d(TAG, String.format("鏀跺埌鍛戒护[%d],Json鍐呭涓�%s", cmd, json));
         switch (cmd) {
             case Constant.NDK_START:
-                Toast.makeText(this, "NDK start", Toast.LENGTH_SHORT).show();
+
                 break;
             case Constant.RTK_PLATFORM_REGISTER_STATUS:
 
@@ -124,7 +118,6 @@
                 break;
             case Constant.RTK_PLATFORM_REGISTER_RESULT:
 
-                failedProjRepository.insert(new FailedProj(Constant.SUBJECT_I, cmd + random.nextInt(26), Constant.TEST_STU_ID));
 
                 try {
                     JSONObject jsonObject = new JSONObject(json);
@@ -166,8 +159,15 @@
                 break;
             case Constant.JUDGE_INFO:
 
+                if(!TextUtils.isEmpty(json)){
+                    JsonArray jsonArray = JsonParser.parseString(json).getAsJsonArray();
+                    for (int i = 0; i < jsonArray.size(); i++) {
+                        JsonObject jsonObject = jsonArray.get(i).getAsJsonObject();
+                        int emp_id = jsonObject.get("wrong_id").getAsInt();
 
-                failedProjRepository.insert(new FailedProj(Constant.SUBJECT_I, cmd, Constant.TEST_STU_ID));
+                        failedProjRepository.insert(new FailedProj(Constant.SUBJECT_I, emp_id, Constant.TEST_STU_ID));
+                    }
+                }
 
                 break;
             case Constant.EXAM_STATUS_REPLY:
diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/BaseSettingFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/BaseSettingFragment.java
index 8ce6107..c235d12 100644
--- a/app/src/main/java/safeluck/drive/evaluation/fragment/BaseSettingFragment.java
+++ b/app/src/main/java/safeluck/drive/evaluation/fragment/BaseSettingFragment.java
@@ -59,6 +59,7 @@
         tabLayout.addTab(tabLayout.newTab());
         tabLayout.addTab(tabLayout.newTab());
         tabLayout.addTab(tabLayout.newTab());
+        tabLayout.addTab(tabLayout.newTab());
         tb = view.findViewById(R.id.toolbar);
         tb.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
         tb.setNavigationOnClickListener(new View.OnClickListener() {
diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/GpsInfoFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/GpsInfoFragment.java
new file mode 100644
index 0000000..93ea834
--- /dev/null
+++ b/app/src/main/java/safeluck/drive/evaluation/fragment/GpsInfoFragment.java
@@ -0,0 +1,61 @@
+package safeluck.drive.evaluation.fragment;
+
+import android.os.Bundle;
+import android.util.Log;
+import android.util.TypedValue;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.EditText;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.lifecycle.Observer;
+import androidx.lifecycle.ViewModelProviders;
+
+import me.yokeyword.fragmentation.SupportFragment;
+import safeluck.drive.evaluation.DB.rtktb.RTKConfig;
+import safeluck.drive.evaluation.DB.rtktb.RTKConfigViewModel;
+import safeluck.drive.evaluation.R;
+import safeluck.drive.evaluation.util.Utils;
+
+/**FTP閰嶇疆UI
+ * MyApplication2
+ * Created by lzw on 2019/3/20. 11:22:39
+ * 閭锛�632393724@qq.com
+ * All Rights Saved! Chongqing AnYun Tech co. LTD
+ */
+public class GpsInfoFragment extends SupportFragment{
+
+    private static final String TAG = "RTKConfigFragment";
+
+    private EditText et_ip,et_port,et_city_id,et_city_province,et_phone;
+    private RTKConfigViewModel rtkConfigViewModel;
+    private RTKConfig mRtkConfig;
+
+    public static SupportFragment newInstance(){
+        return new GpsInfoFragment();
+    }
+
+    @Nullable
+    @Override
+    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+
+
+
+        return initView();
+    }
+
+    private View initView() {
+        TextView textView = new TextView(_mActivity);
+        ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
+        textView.setText("鏀跺埌鍛戒护[3],Json鍐呭涓簕\"connected\":0,\"ip\":\"47.93.80.84\",\"port\":12125}");
+        textView.setTextSize(Utils.dp2Px(20));
+        textView.setLayoutParams(layoutParams);
+        textView.setGravity(Gravity.CENTER_VERTICAL);
+        return textView;
+    }
+
+}

--
Gitblit v1.8.0