| | |
| | | |
| | | 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 safeluck.drive.evaluation.DB.exam_status.ExamStatus; |
| | | import safeluck.drive.evaluation.bean.ExamPlatformData; |
| | | import safeluck.drive.evaluation.bean.ScoreBean; |
| | | import safeluck.drive.evaluation.bean.SimulateNightBean; |
| | | import safeluck.drive.evaluation.cEventCenter.CEventCenter; |
| | | import safeluck.drive.evaluation.cEventCenter.ICEventListener; |
| | | import safeluck.drive.evaluation.customview.ArrowView; |
| | | import safeluck.drive.evaluation.customview.HouseView; |
| | | import safeluck.drive.evaluation.customview.MyDialogFragment; |
| | | import safeluck.drive.evaluation.im.MessageProcessor; |
| | | import safeluck.drive.evaluation.platformMessage.JKMessage0201; |
| | | import safeluck.drive.evaluation.platformMessage.JKMessage0202; |
| | |
| | | public class NetWorkTrainFragment extends SupportFragment implements View.OnClickListener { |
| | | |
| | | private static final String TAG = NetWorkTrainFragment.class.getSimpleName(); |
| | | |
| | | private int exam_type = 2;//2 场地;3 道路,模拟夜考;4 道路,实际夜考; |
| | | private ListView mListView; |
| | | private Button btn_start_exam; |
| | | private TextView tv_stop;//呼叫请求(结束考试) |
| | | private Gson gson = new Gson(); |
| | | private ScoreAdapter mScoreAdapter; |
| | | private ArrowView av_zhijiao, av_curve, av_park, av_podao; |
| | | private HouseView houseView; |
| | |
| | | if (examStatus.get(0).getStartExam() == Constant.HAS_BEEN_START_EXAM){ |
| | | btn_start_exam.setEnabled(false); |
| | | tv_stop.setEnabled(true); |
| | | sendExamJson(Constant.HAS_BEEN_START_EXAM); |
| | | sendExamJson(Constant.HAS_BEEN_START_EXAM,exam_type); |
| | | }else{ |
| | | btn_start_exam.setEnabled(true); |
| | | tv_stop.setEnabled(false); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | MyDialogFragment myDialogFragment; |
| | | SimulateNightBean simulateNightBean = null; |
| | | @Override |
| | | public void onClick(View v) { |
| | | switch (v.getId()) { |
| | | case R.id.btn_start: |
| | | examStatusViewModel.updateStartExam(Constant.HAS_BEEN_START_EXAM); |
| | | failedProjViewModel.deleteAll(); |
| | | sendExamJson(1); |
| | | |
| | | if (myDialogFragment == null){ |
| | | myDialogFragment = new MyDialogFragment(); |
| | | } |
| | | myDialogFragment.show(getFragmentManager(),"dialog"); |
| | | myDialogFragment.setCallback(new MyDialogFragment.Callback() { |
| | | @Override |
| | | public void changKao() { |
| | | exam_type = 2; |
| | | sendExamJson(1,exam_type); |
| | | ExamPlatformData.getInstance().getTTS().speak("开始考试"); |
| | | } |
| | | |
| | | @Override |
| | | public void luKao() { |
| | | exam_type = 3; |
| | | sendExamJson(1,exam_type); |
| | | if (simulateNightBean == null){ |
| | | simulateNightBean = new SimulateNightBean(); |
| | | } |
| | | simulateNightBean.setExam(0); |
| | | List<SimulateNightBean.QuestionBean> list = ExamPlatformData.getInstance().getSimulate_light_tips(); |
| | | simulateNightBean.setQuestion(list.subList(list.size()-2,list.size()-1)); |
| | | AYSdk.getInstance().sendCmd(0x8012,gson.toJson(simulateNightBean)); |
| | | |
| | | } |
| | | }); |
| | | |
| | | iv_head.getDrawable().setLevel(1); |
| | | //清空sns |
| | | sns.clear(); |
| | | //TODO 发送JKMessage0202 给平台,开始考试 |
| | | JKMessage0202 jkMessage0202 = new JKMessage0202(); |
| | | jkMessage0202.phone = ExamPlatformData.getInstance().getPhone(); |
| | | jkMessage0202.timeBCD = new Date(); |
| | | jkMessage0202.curr_exam = 0; |
| | | jkMessage0202.ID = ExamPlatformData.getInstance().getID(); |
| | | jkMessage0202.exam_id = ExamPlatformData.getInstance().getExam_id(); |
| | | MessageProcessor.getInstance().sendMessage(jkMessage0202); |
| | | ExamPlatformData.getInstance().getTTS().speak("开始考试"); |
| | | // JKMessage0202 jkMessage0202 = new JKMessage0202(); |
| | | // jkMessage0202.phone = ExamPlatformData.getInstance().getPhone(); |
| | | // jkMessage0202.timeBCD = new Date(); |
| | | // jkMessage0202.curr_exam = 0; |
| | | // jkMessage0202.ID = ExamPlatformData.getInstance().getID(); |
| | | // jkMessage0202.exam_id = ExamPlatformData.getInstance().getExam_id(); |
| | | // MessageProcessor.getInstance().sendMessage(jkMessage0202); |
| | | |
| | | break; |
| | | case R.id.tv_stop: |
| | | Toast.makeText(_mActivity, "结束考试", Toast.LENGTH_SHORT).show(); |
| | |
| | | } |
| | | } |
| | | |
| | | private void sendExamJson(int i) { |
| | | private void sendExamJson(int i,int type) { |
| | | try { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("exam", i); |
| | | jsonObject.put("type", type); |
| | | String examJson = jsonObject.toString(); |
| | | Log.i(TAG, "onClick: " + examJson); |
| | | AYSdk.getInstance().sendCmd(Constant.EXAM_STATUS, examJson); |
| | |
| | | OneTimeWorkRequest examStatusInitWork = OneTimeWorkRequest.from(ExamStatusInitWorker.class); |
| | | WorkManager.getInstance(_mActivity).enqueue(examStatusInitWork); |
| | | ExamPlatformData.getInstance().getTTS().speak("结束考试"); |
| | | sendExamJson(0); |
| | | sendExamJson(0,exam_type); |
| | | //TODO 发送JKMessage0204给平台 结束考试 |
| | | JKMessage0204 jkMessage0204 = new JKMessage0204(); |
| | | jkMessage0204.phone = ExamPlatformData.getInstance().getPhone(); |