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;
@@ -32,8 +42,37 @@
    private static final int PERMISSIONS_REQUEST_CODE = 1001;
    private String TAG = MainActivity.class.getCanonicalName();
    private PermissionManager mPermissionsManager ;
    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: ");
    }