1.收到需要推送rtk配置信息后,在activity里面发送;2.rtk配置信息表 注册装填改为0未注册;3.在联网考试和单车训练界面主动触发推送rtk配置信息
6个文件已修改
111 ■■■■■ 已修改文件
app/src/main/assets/rtk_config.json 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/Constant.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/MainActivity.java 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/app.java 35 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/fragment/NetWorkTrainFragment.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/assets/rtk_config.json
@@ -9,7 +9,7 @@
    "imei":"460123874561",
    "phone":"2019101500000001",
    "password":"123456789",
    "registered":1,
    "registered":0,
    "interval":1
  }
app/src/main/java/safeluck/drive/evaluation/Constant.java
@@ -45,11 +45,13 @@
    public static final int JUDGE_INFO = 0x000c;
    public static final String RTK_CONFIG_JSON = "rtk_config.json";
    public static final String BIND_DRIVING_TOPIC = "driving";
    public static final String BIND_DRIVING_TOPIC = "driving_topic";
    public static final long TEST_STU_ID = 1001;
    //I类评判表
    public static final int SUBJECT_I = 1;
    public static final String MAP = "map.json";
    public static final String VEHICLE = "vehiclemodel.json";
    public static final String BIND_RTKCONFIG_TOPIC = "rtkconfig_topic";
}
app/src/main/java/safeluck/drive/evaluation/MainActivity.java
@@ -19,8 +19,18 @@
import me.yokeyword.fragmentation.SupportActivity;
import safeluck.drive.evaluation.DB.Student;
import safeluck.drive.evaluation.DB.WokViewModel;
import safeluck.drive.evaluation.DB.rtktb.RTKConfig;
import safeluck.drive.evaluation.DB.rtktb.RTKConfigViewModel;
import safeluck.drive.evaluation.cEventCenter.CEventCenter;
import safeluck.drive.evaluation.cEventCenter.ICEventListener;
import safeluck.drive.evaluation.fragment.HomeFragment;
import com.anyun.exam.lib.AYSdk;
import com.anyun.exam.lib.MyLog;
import com.google.gson.Gson;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.List;
@@ -33,7 +43,36 @@
    private String TAG = MainActivity.class.getCanonicalName();
    private PermissionManager mPermissionsManager ;
    private RTKConfig mRTKConfig;//RTK配置信息
    private Gson gson = new Gson();
    String[] PERMISSIONS = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.CAMERA};
    private ICEventListener icEventListener = new ICEventListener() {
        @Override
        public void onCEvent(String topic, int msgCode, int resultCode, Object obj) {
            if (msgCode == Constant.FETCH_RTK_PLATFORM_INFO){
                if (mRTKConfig != null){
                    String rtkjson = gson.toJson(mRTKConfig);
                    //去除id字段
                    JSONObject jsonObject = null;
                    try {
                        jsonObject = new JSONObject(rtkjson);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                    jsonObject.remove("_id");
                    rtkjson = null;
                    rtkjson = jsonObject.toString();
                    MyLog.i(TAG, "RTK配置信息:" + rtkjson);
                    AYSdk.getInstance().sendCmd(Constant.PUSH_RTK_PLATFORM_INFO, rtkjson);
                }else{
                    MyLog.d(TAG,"RTKConfig未取到数据");
                }
            }
        }
    };
    @Override
    protected void onCreate(Bundle savedInstanceState) {
@@ -53,7 +92,14 @@
            }
        });
        RTKConfigViewModel rtkConfigViewModel= ViewModelProviders.of(this).get(RTKConfigViewModel.class);
        rtkConfigViewModel.getRTKConfig().observe(this, new Observer<RTKConfig>() {
            @Override
            public void onChanged(RTKConfig rtkConfig) {
                MyLog.i(TAG, "RTKConfig Changed: "+rtkConfig.toString());
                mRTKConfig = rtkConfig;
            }
        });
        mPermissionsManager = new PermissionManager(this) {
@@ -100,11 +146,15 @@
        if (findFragment(HomeFragment.class) == null){
            loadRootFragment(R.id.fl_container,HomeFragment.newInstance());
        }
        CEventCenter.onBindEvent(true,icEventListener,Constant.BIND_RTKCONFIG_TOPIC);
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        CEventCenter.onBindEvent(false,icEventListener,Constant.BIND_RTKCONFIG_TOPIC);
        Log.i(TAG, "onDestroy: ");
    }
app/src/main/java/safeluck/drive/evaluation/app.java
@@ -31,6 +31,8 @@
import safeluck.drive.evaluation.DB.failitems.FailedProjRepository;
import safeluck.drive.evaluation.DB.rtktb.RTKConfig;
import safeluck.drive.evaluation.DB.rtktb.RTKWorkRepository;
import safeluck.drive.evaluation.cEventCenter.CEvent;
import safeluck.drive.evaluation.cEventCenter.CEventCenter;
import safeluck.drive.evaluation.util.FileUtil;
import safeluck.drive.evaluation.util.SystemUtil;
@@ -101,8 +103,7 @@
                break;
            case Constant.RTK_PLATFORM_REGISTER_STATUS:
                failedProjRepository.insert(new FailedProj(Constant.SUBJECT_I, cmd + random.nextInt(26), Constant.TEST_STU_ID));
                //RTK平台注册状态,需要保存数据库
                rtkConfig = rtkWorkRepository.getRTKConfigNoLive();
                try {
@@ -118,11 +119,10 @@
                break;
            case Constant.RTK_PLATFORM_REGISTER_RESULT:
                //RTK平台登录结果
                try {
                    JSONObject jsonObject = new JSONObject(json);
                    int rtklogincode = jsonObject.getInt("login_code");
                    rtkConfig.setRegistered(rtklogincode);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
@@ -130,32 +130,7 @@
                break;
            case Constant.FETCH_RTK_PLATFORM_INFO:
                rtkConfig = rtkWorkRepository.getRTKConfigNoLive();
                if (gson == null) {
                    gson = new Gson();
                }
                if (rtkConfig==null){
                    rtkConfig = rtkWorkRepository.getRTKConfigNoLive();
                }
                if (rtkConfig != null){
                    String rtkjson = gson.toJson(rtkConfig);
                    MyLog.i(TAG, "RTK配置信息:" + rtkjson);
                    //去除id字段
                    JSONObject jsonObject = null;
                    try {
                        jsonObject = new JSONObject(rtkjson);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                    jsonObject.remove("_id");
                    rtkjson = null;
                    rtkjson = jsonObject.toString();
                    MyLog.i(TAG, "RTK配置信息:" + rtkjson);
                    AYSdk.getInstance().sendCmd(Constant.PUSH_RTK_PLATFORM_INFO, rtkjson);
                }
                CEventCenter.dispatchEvent(Constant.BIND_RTKCONFIG_TOPIC,cmd,0,"");
                break;
            case Constant.JUDGE_INFO:
app/src/main/java/safeluck/drive/evaluation/fragment/NetWorkTrainFragment.java
@@ -17,6 +17,7 @@
import androidx.lifecycle.ViewModelProviders;
import com.anyun.exam.lib.AYSdk;
import com.anyun.exam.lib.MyLog;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
@@ -35,6 +36,7 @@
import safeluck.drive.evaluation.R;
import safeluck.drive.evaluation.adapter.ScoreAdapter;
import safeluck.drive.evaluation.bean.ScoreBean;
import safeluck.drive.evaluation.cEventCenter.CEventCenter;
/**
 * 联网训练UI
@@ -85,6 +87,7 @@
    }
    private void initView(View view) {
        sendRTKConfig2RemoteService();
        mListView = view.findViewById(R.id.lv);
        mListView.setFocusable(false);
        view.findViewById(R.id.view_map).setOnClickListener(this);
@@ -96,7 +99,10 @@
        mListView.addHeaderView(LayoutInflater.from(_mActivity).inflate(R.layout.layout_score_item,null));
    }
    private void sendRTKConfig2RemoteService() {
        MyLog.d(TAG,"主动推送RTKConfig");
        CEventCenter.dispatchEvent(Constant.BIND_RTKCONFIG_TOPIC,Constant.PUSH_RTK_PLATFORM_INFO,0,"");
    }
    @Override
    public void onClick(View v) {
        switch (v.getId()){
app/src/main/java/safeluck/drive/evaluation/fragment/TrainFragment.java
@@ -16,6 +16,8 @@
import android.widget.ListView;
import android.widget.Toast;
import com.anyun.exam.lib.MyLog;
import java.util.ArrayList;
import java.util.EventListener;
import java.util.List;
@@ -99,7 +101,7 @@
        return view;
    }
    private void initView(View view) {
        sendRTKConfig2RemoteService();
        mListView = view.findViewById(R.id.lv);
        mListView.setFocusable(false);//listview不获取焦点,不然的话scrollview会顶到底部
        view.findViewById(R.id.view_map).setOnClickListener(this);
@@ -112,6 +114,12 @@
        mListView.addHeaderView(LayoutInflater.from(_mActivity).inflate(R.layout.layout_score_item,null));
    }
    private void sendRTKConfig2RemoteService() {
        MyLog.d(TAG,"主动推送RTKConfig");
        CEventCenter.dispatchEvent(Constant.BIND_RTKCONFIG_TOPIC,Constant.PUSH_RTK_PLATFORM_INFO,0,"");
    }
    @Override