| | |
| | | |
| | | import android.os.Handler; |
| | | import android.os.Message; |
| | | import android.text.TextUtils; |
| | | import android.util.Log; |
| | | import android.view.LayoutInflater; |
| | | import android.view.MotionEvent; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.widget.Button; |
| | |
| | | |
| | | 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.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Random; |
| | | |
| | | import me.yokeyword.fragmentation.SupportFragment; |
| | | import safeluck.drive.evaluation.Constant; |
| | | import safeluck.drive.evaluation.DB.Student; |
| | | import safeluck.drive.evaluation.DB.WokViewModel; |
| | | import safeluck.drive.evaluation.DB.appstatusdb.AppStatus; |
| | | import safeluck.drive.evaluation.DB.appstatusdb.AppStatusViewModel; |
| | | import safeluck.drive.evaluation.DB.exam_status.ExamStatus; |
| | |
| | | import safeluck.drive.evaluation.DB.failitems.FailedProj_select; |
| | | import safeluck.drive.evaluation.R; |
| | | import safeluck.drive.evaluation.adapter.ScoreAdapter; |
| | | 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; |
| | | import safeluck.drive.evaluation.platformMessage.JKMessage0203; |
| | | import safeluck.drive.evaluation.platformMessage.JKMessage0204; |
| | | import safeluck.drive.evaluation.util.Utils; |
| | | |
| | | /**单机训练UI |
| | | * MyApplication2 |
| | |
| | | public class TrainFragment extends SupportFragment implements View.OnClickListener { |
| | | |
| | | private static final String TAG = TrainFragment.class.getSimpleName(); |
| | | private ListView mListView ; |
| | | private Button btn_train; |
| | | private ScoreAdapter mScoreAdapter; |
| | | |
| | | private int item_id;//扣分分数总和 |
| | | 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 ExamStatusViewModel examStatusViewModel; |
| | | private static final int ADD_DATA = 1; |
| | | private static final int SPEED_DATA = 2; |
| | | private ImageView iv_rtk_status,iv_head; |
| | | |
| | | private List<ScoreBean> mArrayList = new ArrayList<>(); |
| | | private View tv_stop; |
| | | private TextView tv_speed,tv_total_score,tv_sat_num; |
| | | private int currTotalScore = 100; |
| | | private double speed=0.0; |
| | | |
| | | private Handler mHandler = new Handler(new Handler.Callback() { |
| | | @Override |
| | | public boolean handleMessage(Message msg) { |
| | | if (msg.what == ADD_DATA){ |
| | | tv_total_score.setText(getResources().getString(R.string.total_score,currTotalScore)); |
| | | houseView.setColor(whatPaintColor(examStatusList.get(0))); |
| | | av_podao.setColor(whatPaintColor(examStatusList.get(1))); |
| | | av_park.setColor(whatPaintColor(examStatusList.get(2))); |
| | | av_curve.setColor(whatPaintColor(examStatusList.get(3))); |
| | | av_zhijiao.setColor(whatPaintColor(examStatusList.get(4))); |
| | | } |
| | | if (msg.what == SPEED_DATA){ |
| | | tv_speed.setText(getResources().getString(R.string.speed,speed)); |
| | | } |
| | | return false; |
| | | } |
| | | }); |
| | | |
| | | |
| | | |
| | | public static SupportFragment newInstance(){ |
| | | return new TrainFragment(); |
| | | } |
| | | |
| | | 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; |
| | | private List<ExamStatus> examStatusList = new ArrayList<>(); |
| | | private List<String> item_conents = new ArrayList<>();//坡道定点停车和起步 |
| | | |
| | | private int item_id;//扣分分数总和 |
| | | private ExamStatusViewModel examStatusViewModel; |
| | | private static final int ADD_DATA = 1; |
| | | private TextView tv_speed,tv_total_score,tv_sat_num,tv_name,tv_id,tv_work_platform; |
| | | private double speed=0.0; |
| | | private ImageView iv_rtk_status,iv_head; |
| | | |
| | | private int currTotalScore = 100; |
| | | private List<ScoreBean> mArrayList = new ArrayList<>(); |
| | | private static final int SPEED_DATA = 2; |
| | | private FailedProjViewModel failedProjViewModel; |
| | | String icson;//返回的ic卡信息 json |
| | | private Random random = new Random(); |
| | | private List<SimulateNightBean.QuestionBean> tempQs= new ArrayList<>(); |
| | | |
| | | |
| | | |
| | | |
| | | private Handler mHandler = new Handler(new Handler.Callback() { |
| | | @Override |
| | | public boolean handleMessage(Message msg) { |
| | | if (msg.what == ADD_DATA){ |
| | | MyLog.i("handler add_data totalScore="+currTotalScore); |
| | | tv_total_score.setText(getResources().getString(R.string.total_score,currTotalScore)); |
| | | houseView.setColor(aaa(safeluck.drive.evaluation.DB.Constant.EXAM_MAP_TYPE_REVERSE));//倒车入库 type =1 |
| | | av_podao.setColor(aaa(safeluck.drive.evaluation.DB.Constant.EXAM_MAP_TYPE_RAMP)); |
| | | av_park.setColor(aaa(safeluck.drive.evaluation.DB.Constant.EXAM_MAP_TYPE_PARK)); |
| | | av_curve.setColor(aaa(safeluck.drive.evaluation.DB.Constant.EXAM_MAP_TYPE_CURVE)); |
| | | av_zhijiao.setColor(aaa(safeluck.drive.evaluation.DB.Constant.EXAM_MAP_TYPE_ANGLE)); |
| | | } |
| | | if (msg.what == SPEED_DATA){ |
| | | tv_speed.setText(getResources().getString(R.string.speed,speed)); |
| | | } |
| | | if (msg.what == Constant.IC_ID){ |
| | | try { |
| | | JSONObject jsSpeed = new JSONObject(icson); |
| | | int result = jsSpeed.getInt("result"); |
| | | String icStr = jsSpeed.getString("serialno"); |
| | | if (result == 0) { |
| | | JKMessage0201 jkMessage0201 = new JKMessage0201(); |
| | | jkMessage0201.phone = ExamPlatformData.getInstance().getPhone(); |
| | | if (exam_type==Constant.Chang_di){ |
| | | jkMessage0201.currentExam = 0; |
| | | }else{ |
| | | jkMessage0201.currentExam = 1; |
| | | } |
| | | |
| | | jkMessage0201.id = icStr; |
| | | MessageProcessor.getInstance().sendMessage(jkMessage0201); |
| | | } |
| | | |
| | | }catch (JSONException e){ |
| | | |
| | | } |
| | | |
| | | } |
| | | return false; |
| | | } |
| | | }); |
| | | |
| | | private int aaa(int type) { |
| | | if (examStatusList!=null &&examStatusList.size()>0){ |
| | | for (ExamStatus examStatus: |
| | | examStatusList) { |
| | | if (type == examStatus.getMap_item()){ |
| | | if (examStatus.getEnter() == safeluck.drive.evaluation.DB.Constant.BEGIN_ITEM){ |
| | | //进入考场 |
| | | if (examStatusList.get(0).getStartExam() == Constant.NONE_BEEN_START_EXAM){ |
| | | //结束考试了 |
| | | MyLog.i("进入考场结束考试,startexam="+examStatus.getStartExam()); |
| | | return getResources().getColor(R.color.colorAccent); |
| | | }else{ |
| | | MyLog.i("进入考场,type="+type); |
| | | return getResources().getColor(R.color.pink); |
| | | } |
| | | |
| | | |
| | | }else if (examStatus.getEnter() == safeluck.drive.evaluation.DB.Constant.FINISH_ITEM){ |
| | | |
| | | if (examStatusList.get(0).getStartExam()==Constant.NONE_BEEN_START_EXAM){ |
| | | return getResources().getColor(R.color.examing); |
| | | } |
| | | |
| | | switch (type) { |
| | | case 1://倒库 |
| | | if (item_conents.contains("倒车入库")) { |
| | | MyLog.i("该项考试失败,type="+type); |
| | | |
| | | return getResources().getColor(R.color.colorAccent); |
| | | }else{ |
| | | ExamPlatformData.getInstance().getTTS().speak("倒车入库合格"); |
| | | return getResources().getColor(R.color.train_btn_return); |
| | | } |
| | | case 2: |
| | | if (item_conents.contains("坡道定点停车和起步")) { |
| | | MyLog.i("该项考试失败,type="+type); |
| | | return getResources().getColor(R.color.colorAccent); |
| | | }else{ |
| | | ExamPlatformData.getInstance().getTTS().speak("坡道定点停车和起步合格"); |
| | | return getResources().getColor(R.color.train_btn_return); |
| | | } |
| | | case 3: |
| | | if (item_conents.contains("侧方停车")) { |
| | | MyLog.i("该项考试失败,type="+type); |
| | | return getResources().getColor(R.color.colorAccent); |
| | | }else{ |
| | | ExamPlatformData.getInstance().getTTS().speak("侧方停车合格"); |
| | | return getResources().getColor(R.color.train_btn_return); |
| | | } |
| | | case 4: |
| | | if (item_conents.contains("曲线行驶")) { |
| | | MyLog.i("该项考试失败,type="+type); |
| | | return getResources().getColor(R.color.colorAccent); |
| | | }else{ |
| | | ExamPlatformData.getInstance().getTTS().speak("曲线行驶合格"); |
| | | return getResources().getColor(R.color.train_btn_return); |
| | | } |
| | | case 5: |
| | | if (item_conents.contains("直角转弯")) { |
| | | MyLog.i("该项考试失败,type="+type); |
| | | return getResources().getColor(R.color.colorAccent); |
| | | }else{ |
| | | MyLog.i("该项考试成功,type="+type); |
| | | ExamPlatformData.getInstance().getTTS().speak("直角转弯合格"); |
| | | return getResources().getColor(R.color.train_btn_return); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | }else{ |
| | | return getResources().getColor(R.color.examing); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return getResources().getColor(R.color.examing); |
| | | } |
| | | |
| | | @Nullable |
| | | @Override |
| | | public View onCreateView(@NonNull final LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
| | | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
| | | View view = inflater.inflate(R.layout.layout_train_fragment,container,false); |
| | | initView(view); |
| | | |
| | | |
| | | |
| | | FailedProjViewModel failedProjViewModel =ViewModelProviders.of(this).get(FailedProjViewModel.class); |
| | | failedProjViewModel = ViewModelProviders.of(this).get(FailedProjViewModel.class); |
| | | failedProjViewModel.getFailedProjectsForI(Constant.TEST_STU_ID).observe(this, new Observer<List<FailedProj_select>>() { |
| | | @Override |
| | | public void onChanged(List<FailedProj_select> failedProj_selects) { |
| | | if (failedProj_selects != null && failedProj_selects.size()>0){ |
| | | |
| | | item_id = 0; |
| | | currTotalScore = 100; |
| | | mArrayList.clear(); |
| | | item_conents.clear(); |
| | | for (FailedProj_select f : |
| | |
| | | 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()); |
| | | Collections.reverse(mArrayList); |
| | | mScoreAdapter.addDatas(mArrayList); |
| | | MyLog.i("item_score="+item_id); |
| | | } |
| | | //TODO 发送JKMessage0203 给平台,这儿有点复杂,看怎么处理 |
| | | sendJKMessage0203(failedProj_selects); |
| | | MyLog.i("没扣分之前得分:"+currTotalScore); |
| | | currTotalScore -=item_id; |
| | | MyLog.i("当前得分:"+currTotalScore); |
| | | if (currTotalScore < Constant.PASSING_SCORE){ |
| | | MyLog.i(TAG,"低于80,不合格"); |
| | | MyLog.i("低于80,不合格"+currTotalScore); |
| | | ExamPlatformData.getInstance().getTTS().speak("考试不合格"); |
| | | stopExam(); |
| | | } |
| | | |
| | | MyLog.i(TAG,"监测到有失败项目加入,通知UI更新颜色"); |
| | | MyLog.i("监测到有失败项目加入,通知UI更新颜色"); |
| | | mHandler.obtainMessage(ADD_DATA).sendToTarget(); |
| | | |
| | | }else{ |
| | | MyLog.i(TAG,"失败项目数据表被清空更新UI"); |
| | | item_id = 0; |
| | | mArrayList.clear(); |
| | | item_conents.clear(); |
| | | Collections.reverse(mArrayList); |
| | | mScoreAdapter.addDatas(mArrayList); |
| | | mHandler.obtainMessage(ADD_DATA).sendToTarget(); |
| | | } |
| | |
| | | @Override |
| | | public void onChanged(List<ExamStatus> examStatus) { |
| | | |
| | | for (ExamStatus e : |
| | | examStatus) { |
| | | Log.i(TAG, "onChanged: e="+e.toString()); |
| | | } |
| | | Log.i(TAG, "onChanged: "); |
| | | |
| | | |
| | | Log.i(TAG, "ExamStatus onChanged: "); |
| | | if (examStatus!=null && examStatus.size()>0){ |
| | | MyLog.i(TAG,"考试状态更新"); |
| | | examStatusList.clear(); |
| | | examStatusList.addAll(examStatus); |
| | | mHandler.obtainMessage(ADD_DATA).sendToTarget(); |
| | | if (examStatus.get(0).getStartExam() == Constant.NONE_BEEN_START_EXAM){ |
| | | btn_train.setEnabled(false); |
| | | if (examStatus.get(0).getStartExam() != Constant.NONE_BEEN_START_EXAM){ |
| | | btn_start_exam.setEnabled(false); |
| | | tv_stop.setEnabled(true); |
| | | }else{ |
| | | btn_train.setEnabled(true); |
| | | btn_start_exam.setEnabled(true); |
| | | tv_stop.setEnabled(false); |
| | | } |
| | | exam_type = examStatus.get(0).getStartExam(); |
| | | } |
| | | |
| | | |
| | | } |
| | | }); |
| | | WokViewModel wokViewModel = ViewModelProviders.of(this).get(WokViewModel.class); |
| | | wokViewModel.getStudents().observe(this, new Observer<List<Student>>() { |
| | | @Override |
| | | public void onChanged(List<Student> students) { |
| | | for (Student student : |
| | | students) { |
| | | MyLog.i(TAG, "onChanged: " + student.toString()); |
| | | if (!TextUtils.isEmpty(student.getName())){ |
| | | |
| | | |
| | | tv_name.setText(getString(R.string.name)+student.getName()); |
| | | tv_id.setText(getString(R.string.user_id)+student.getID()); |
| | | ExamPlatformData.getInstance().setId(student.getID()); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | |
| | | AppStatusViewModel appStatusViewModel = ViewModelProviders.of(this).get(AppStatusViewModel.class); |
| | | appStatusViewModel.getAppStatus().observe(this, new Observer<AppStatus>() { |
| | |
| | | if (appStatus != null){ |
| | | Log.i(TAG, "onChanged: "+appStatus.toString()); |
| | | iv_rtk_status.getDrawable().setLevel(appStatus.getRtk_connect_status()); |
| | | tv_work_platform.setText(getString(R.string.platform_status,ExamPlatformData.getInstance().getExamplatformStatusStr(appStatus.getWork_platform()))); |
| | | tv_sat_num.setText(String.valueOf(appStatus.getDefault_observe1()).length()==1?"0"+appStatus.getDefault_observe1():String.valueOf(appStatus.getDefault_observe1())); |
| | | } |
| | | } |
| | |
| | | |
| | | return view; |
| | | } |
| | | private void initView(View view) { |
| | | private List<Integer> sns =new ArrayList<>(); |
| | | private void sendJKMessage0203(List<FailedProj_select> failedProj_selects) { |
| | | JKMessage0203 jkMessage0203 = new JKMessage0203(); |
| | | jkMessage0203.phone = ExamPlatformData.getInstance().getPhone(); |
| | | jkMessage0203.ID = ExamPlatformData.getInstance().getID(); |
| | | jkMessage0203.exam_id = ExamPlatformData.getInstance().getExam_id(); |
| | | |
| | | av_curve = view.findViewById(R.id.av3); |
| | | av_park = view.findViewById(R.id.av2); |
| | | av_podao = view.findViewById(R.id.av1); |
| | | av_zhijiao = view.findViewById(R.id.av4); |
| | | houseView = view.findViewById(R.id.hv); |
| | | for (int i = 0; i < failedProj_selects.size(); i++) { |
| | | if (hasSnEqulas(failedProj_selects.get(i).getSn())){ |
| | | MyLog.i("sn相同"+failedProj_selects.get(i).getSn()); |
| | | }else{ |
| | | ExamPlatformData.getInstance().getTTS().speak(failedProj_selects.get(i).getDeducting_reason()+( |
| | | failedProj_selects.get(i).getScore_deducting()==100?"不合格":"扣"+ |
| | | failedProj_selects.get(i).getScore_deducting()+"分")); |
| | | MyLog.i("没有相同的sn,发送"+failedProj_selects.get(i).getSn()); |
| | | sns.add(failedProj_selects.get(i).getSn()); |
| | | String utc = failedProj_selects.get(i).getUtc(); |
| | | if (!TextUtils.isEmpty(utc)&&utc.length()>12){ |
| | | utc =utc.substring(0,12); |
| | | } |
| | | jkMessage0203.timeBCD = utc ; |
| | | |
| | | tv_speed = view.findViewById(R.id.tv_speed); |
| | | iv_rtk_status = view.findViewById(R.id.iv_rtk_connect); |
| | | iv_head = view.findViewById(R.id.iv_head); |
| | | tv_sat_num = view.findViewById(R.id.tv_sat_num); |
| | | jkMessage0203.fail_item_id = failedProj_selects.get(i).getEmp_id(); |
| | | jkMessage0203.fail_score = failedProj_selects.get(i).getScore_deducting(); |
| | | jkMessage0203.fail_reason = failedProj_selects.get(i).getDeducting_reason(); |
| | | } |
| | | |
| | | tv_total_score = view.findViewById(R.id.tv_total_score); |
| | | tv_speed.setText(getResources().getString(R.string.speed,speed)); |
| | | view.findViewById(R.id.btn_return).setOnClickListener(this); |
| | | mListView = view.findViewById(R.id.lv); |
| | | tv_stop = view.findViewById(R.id.tv_stop); |
| | | tv_stop.setOnClickListener(this); |
| | | mListView.setFocusable(false);//listview不获取焦点,不然的话scrollview会顶到底部 |
| | | view.findViewById(R.id.view_map).setOnClickListener(this); |
| | | btn_train = view.findViewById(R.id.btn_start); |
| | | btn_train.setOnClickListener(this); |
| | | btn_train.setText("开始训练"); |
| | | mScoreAdapter = new ScoreAdapter(_mActivity); |
| | | mListView.setAdapter(mScoreAdapter); |
| | | |
| | | mListView.addHeaderView(LayoutInflater.from(_mActivity).inflate(R.layout.layout_score_item,null)); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | MessageProcessor.getInstance().sendMessage(jkMessage0203); |
| | | } |
| | | |
| | | private boolean hasSnEqulas(int failedProjSn){ |
| | | if (sns.size() > 0){ |
| | | for (int j = 0; j < sns.size(); j++) { |
| | | MyLog.i("已存在的sn"+sns.get(j)); |
| | | if (sns.get(j) == failedProjSn){ |
| | | MyLog.i("sn相同,不发"+sns.get(j)); |
| | | return true; |
| | | }else{ |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | } |
| | | return false; |
| | | |
| | | } |
| | | |
| | | private int whatPaintColor(ExamStatus examStat) { |
| | | int map_id = examStat.getMap_id(); |
| | | int status = examStat.getEnter(); |
| | | Log.i(TAG, "whatPaintColor: map_id="+map_id+" status="+status); |
| | | MyLog.i(TAG, "whatPaintColor: map_id="+map_id+" status="+status); |
| | | switch (status) { |
| | | case 0://考试完成 |
| | | switch (map_id) { |
| | |
| | | |
| | | } |
| | | case 1://进入考场项目 |
| | | MyLog.i("pink 进入某个考场项目"); |
| | | 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) { |
| | | |
| | | view.findViewById(R.id.iv_head).setOnClickListener(this); |
| | | av_curve = view.findViewById(R.id.av3); |
| | | av_park = view.findViewById(R.id.av2); |
| | | av_podao = view.findViewById(R.id.av1); |
| | | av_zhijiao = view.findViewById(R.id.av4); |
| | | houseView = view.findViewById(R.id.hv); |
| | | tv_name = view.findViewById(R.id.tv_name); |
| | | tv_id = view.findViewById(R.id.tv_ID); |
| | | tv_work_platform = view.findViewById(R.id.platform); |
| | | |
| | | iv_rtk_status = view.findViewById(R.id.iv_rtk_connect); |
| | | iv_head = view.findViewById(R.id.iv_head); |
| | | tv_sat_num = view.findViewById(R.id.tv_sat_num); |
| | | tv_speed = view.findViewById(R.id.tv_speed); |
| | | tv_total_score = view.findViewById(R.id.tv_total_score); |
| | | tv_speed.setText(getResources().getString(R.string.speed,speed)); |
| | | |
| | | view.findViewById(R.id.btn_return).setOnClickListener(this); |
| | | mListView = view.findViewById(R.id.lv); |
| | | mListView.setFocusable(false); |
| | | mListView.setOnTouchListener(new View.OnTouchListener() { |
| | | @Override |
| | | public boolean onTouch(View v, MotionEvent ev) { |
| | | switch (ev.getAction()) { |
| | | case MotionEvent.ACTION_DOWN: |
| | | case MotionEvent.ACTION_MOVE: |
| | | mListView.getParent().requestDisallowInterceptTouchEvent(true); |
| | | break; |
| | | case MotionEvent.ACTION_UP: |
| | | case MotionEvent.ACTION_CANCEL: |
| | | mListView.getParent().requestDisallowInterceptTouchEvent(false); |
| | | break; |
| | | } |
| | | return false; |
| | | } |
| | | }); |
| | | |
| | | view.findViewById(R.id.view_map).setOnClickListener(this); |
| | | mScoreAdapter = new ScoreAdapter(_mActivity); |
| | | mListView.setAdapter(mScoreAdapter); |
| | | btn_start_exam = view.findViewById(R.id.btn_start); |
| | | btn_start_exam.setOnClickListener(this); |
| | | tv_stop = view.findViewById(R.id.tv_stop); |
| | | tv_stop.setOnClickListener(this); |
| | | mListView.addHeaderView(LayoutInflater.from(_mActivity).inflate(R.layout.layout_score_item, null)); |
| | | |
| | | } |
| | | |
| | | |
| | | MyDialogFragment myDialogFragment; |
| | | SimulateNightBean simulateNightBean = null; |
| | | @Override |
| | | public void onClick(View v) { |
| | | switch (v.getId()){ |
| | | case R.id.view_map: |
| | | TcpFragment passwordFragment = findFragment(TcpFragment.class); |
| | | if (passwordFragment == null) { |
| | | passwordFragment = (TcpFragment) TcpFragment.newInstance(); |
| | | start(passwordFragment); |
| | | } else { |
| | | start(passwordFragment); |
| | | } |
| | | break; |
| | | case R.id.btn_start: |
| | | examStatusViewModel.updateStartExam(Constant.NONE_BEEN_START_EXAM); |
| | | OneTimeWorkRequest examStatusInitWork = OneTimeWorkRequest.from(ExamStatusInitWorker.class); |
| | | WorkManager.getInstance(_mActivity).enqueue(examStatusInitWork); |
| | | item_id = 0; |
| | | currTotalScore = 100; |
| | | //TODO 发送JKMessage0202 给平台,开始考试 |
| | | final JKMessage0202 jkMessage0202 = new JKMessage0202(); |
| | | jkMessage0202.phone = ExamPlatformData.getInstance().getPhone(); |
| | | jkMessage0202.timeBCD = new Date(); |
| | | jkMessage0202.ID = ExamPlatformData.getInstance().getID(); |
| | | |
| | | jkMessage0202.exam_id = ExamPlatformData.getInstance().getExam_id(); |
| | | failedProjViewModel.deleteAll(); |
| | | |
| | | if (myDialogFragment == null){ |
| | | myDialogFragment = new MyDialogFragment(); |
| | | } |
| | | myDialogFragment.show(getFragmentManager(),"dialog"); |
| | | myDialogFragment.setCallback(new MyDialogFragment.Callback() { |
| | | @Override |
| | | public void changKao() { |
| | | exam_type = 2; |
| | | examStatusViewModel.updateStartExam(exam_type); |
| | | sendExamJson(1,exam_type); |
| | | ExamPlatformData.getInstance().getTTS().speak("开始考试"); |
| | | jkMessage0202.curr_exam = 0; |
| | | |
| | | MessageProcessor.getInstance().sendMessage(jkMessage0202); |
| | | } |
| | | |
| | | @Override |
| | | public void luKao() { |
| | | exam_type = 3; |
| | | examStatusViewModel.updateStartExam(exam_type); |
| | | sendExamJson(1,exam_type); |
| | | if (simulateNightBean == null){ |
| | | simulateNightBean = new SimulateNightBean(); |
| | | } |
| | | simulateNightBean.setExam(0); |
| | | |
| | | final 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)); |
| | | jkMessage0202.curr_exam = 1; |
| | | |
| | | MessageProcessor.getInstance().sendMessage(jkMessage0202); |
| | | |
| | | tempQs.add(list.get(0)); |
| | | int [] a = Utils.getRandomInts(4,12); |
| | | for (int i = 0; i < a.length; i++) { |
| | | tempQs.add(list.get(a[i])); |
| | | } |
| | | |
| | | simulateNightBean.setQuestion(tempQs); |
| | | mHandler.postDelayed(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | AYSdk.getInstance().sendCmd(0x8012,gson.toJson(simulateNightBean)); |
| | | tempQs.clear(); |
| | | } |
| | | },10*1000); |
| | | |
| | | } |
| | | }); |
| | | |
| | | iv_head.getDrawable().setLevel(1); |
| | | //清空sns |
| | | sns.clear(); |
| | | |
| | | |
| | | |
| | | break; |
| | | case R.id.tv_stop: |
| | | Toast.makeText(_mActivity, "结束考试", Toast.LENGTH_SHORT).show(); |
| | | stopExam(); |
| | | |
| | | break; |
| | | case R.id.view_map: |
| | | MapFragment mapFragment = findFragment(MapFragment.class); |
| | | MyLog.i(TAG,"查看地图"); |
| | | if (mapFragment == null) { |
| | | mapFragment = (MapFragment) MapFragment.newInstance(); |
| | | } |
| | | start(mapFragment); |
| | | break; |
| | | case R.id.btn_return: |
| | | _mActivity.onBackPressed(); |
| | | break; |
| | | case R.id.iv_head: |
| | | MyLog.i(TAG,"签到,获取身份证物理卡号"); |
| | | AYSdk.getInstance().sendCmd(Constant.READ_PHYSICAL_ID,""); |
| | | //TODO 获得物理卡号 发送JKMessage0201给平台,获取姓名、身份证、head_url |
| | | |
| | | break; |
| | | } |
| | | } |
| | | |
| | | private void sendExamJson(int i,int type) { |
| | | try { |
| | | |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("exam", 1); |
| | | jsonObject.put("exam", i); |
| | | jsonObject.put("type", type); |
| | | String examJson = jsonObject.toString(); |
| | | Log.i(TAG, "onClick: " + examJson); |
| | | AYSdk.getInstance().sendCmd(Constant.EXAM_STATUS, examJson); |
| | | } catch (JSONException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | break; |
| | | case R.id.tv_stop: |
| | | Toast.makeText(_mActivity, "结束考试", Toast.LENGTH_SHORT).show(); |
| | | stopExam(); |
| | | break; |
| | | case R.id.btn_return: |
| | | _mActivity.onBackPressed(); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | private void stopExam() { |
| | | MyLog.i(TAG,"结束考试"); |
| | | item_id = 0; |
| | | currTotalScore = 100; |
| | | |
| | | |
| | | tv_total_score.setText(String.valueOf(currTotalScore)); |
| | | iv_head.getDrawable().setLevel(0); |
| | | OneTimeWorkRequest examStatusInitWork = OneTimeWorkRequest.from(ExamStatusInitWorker.class); |
| | | WorkManager.getInstance(_mActivity).enqueue(examStatusInitWork); |
| | | try { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("exam", 0); |
| | | String examJson = jsonObject.toString(); |
| | | Log.i(TAG, "onClick: " + examJson); |
| | | AYSdk.getInstance().sendCmd(Constant.EXAM_STATUS, examJson); |
| | | } catch (JSONException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | ExamPlatformData.getInstance().getTTS().speak("结束考试"); |
| | | examStatusViewModel.updateStartExam(Constant.NONE_BEEN_START_EXAM); |
| | | sendExamJson(0,0);//结束考试 exstart=0 |
| | | //TODO 发送JKMessage0204给平台 结束考试 |
| | | JKMessage0204 jkMessage0204 = new JKMessage0204(); |
| | | jkMessage0204.phone = ExamPlatformData.getInstance().getPhone(); |
| | | jkMessage0204.timeBCD = new Date(); |
| | | jkMessage0204.score = 10; |
| | | jkMessage0204.stop = JKMessage0204.SUCC_STOP; |
| | | jkMessage0204.ID = ExamPlatformData.getInstance().getID(); |
| | | jkMessage0204.exam_id = ExamPlatformData.getInstance().getExam_id(); |
| | | MessageProcessor.getInstance().sendMessage(jkMessage0204); |
| | | } |
| | | |
| | | private ICEventListener icEventListener = new ICEventListener() { |
| | | @Override |
| | | public void onCEvent(String topic, int msgCode, int resultCode, Object obj) { |
| | | if (msgCode == Constant.IC_ID){ |
| | | icson = (String)obj; |
| | | mHandler.obtainMessage(msgCode).sendToTarget(); |
| | | }else{ |
| | | speed = (double)obj; |
| | | mHandler.obtainMessage(SPEED_DATA).sendToTarget(); |
| | | } |
| | | |
| | | } |
| | | }; |
| | | @Override |
| | | public void onAttach(Context context) { |