| | |
| | | import android.view.ViewGroup; |
| | | import android.widget.Button; |
| | | import android.widget.ListView; |
| | | import android.widget.TextView; |
| | | import android.widget.Toast; |
| | | |
| | | |
| | |
| | | import androidx.annotation.Nullable; |
| | | import androidx.lifecycle.Observer; |
| | | import androidx.lifecycle.ViewModelProviders; |
| | | import androidx.work.OneTimeWorkRequest; |
| | | import androidx.work.WorkManager; |
| | | |
| | | import com.anyun.exam.lib.AYSdk; |
| | | import com.anyun.exam.lib.MyLog; |
| | | |
| | | import org.json.JSONException; |
| | | import org.json.JSONObject; |
| | |
| | | |
| | | import me.yokeyword.fragmentation.SupportFragment; |
| | | import safeluck.drive.evaluation.Constant; |
| | | import safeluck.drive.evaluation.DB.exam_status.ExamStatusInitWorker; |
| | | import safeluck.drive.evaluation.DB.exam_status.ExamStatusViewModel; |
| | | import safeluck.drive.evaluation.DB.failitems.FailedProjViewModel; |
| | | import safeluck.drive.evaluation.DB.failitems.FailedProj_select; |
| | |
| | | private static final String TAG = NetWorkTrainFragment.class.getSimpleName(); |
| | | private ListView mListView; |
| | | private Button btn_start_exam; |
| | | private TextView tv_stop;//呼叫请求(结束考试) |
| | | private ScoreAdapter mScoreAdapter; |
| | | private ArrowView av_zhijiao, av_curve, av_park, av_podao; |
| | | private HouseView houseView; |
| | |
| | | @Override |
| | | public boolean handleMessage(Message msg) { |
| | | if (msg.what == ADD_DATA){ |
| | | av_curve.setColor(whatPaintColor(examStatusList.get(3))); |
| | | av_zhijiao.setColor(whatPaintColor(examStatusList.get(4))); |
| | | houseView.setColor(whatPaintColor(examStatusList.get(0))); |
| | | av_podao.setColor(whatPaintColor(examStatusList.get(1))); |
| | | av_park.setColor(whatPaintColor(examStatusList.get(2))); |
| | | houseView.setColor(whatPaintColor(examStatusList.get(0))); |
| | | av_curve.setColor(whatPaintColor(examStatusList.get(3))); |
| | | av_zhijiao.setColor(whatPaintColor(examStatusList.get(4))); |
| | | } |
| | | return false; |
| | | } |
| | |
| | | @Override |
| | | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
| | | View view = inflater.inflate(R.layout.layout_train_fragment, container, false); |
| | | item_conents.add("侧方停车"); |
| | | initView(view); |
| | | |
| | | FailedProjViewModel 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) { |
| | | item_id = 0; |
| | | mArrayList.clear(); |
| | | item_conents.clear(); |
| | | for (FailedProj_select f : |
| | | failedProj_selects) { |
| | | item_id += f.getScore_deducting(); |
| | | 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()); |
| | | mScoreAdapter.addDatas(mArrayList); |
| | | if (failedProj_selects != null && failedProj_selects.size()>0){ |
| | | |
| | | item_id = 0; |
| | | mArrayList.clear(); |
| | | item_conents.clear(); |
| | | for (FailedProj_select f : |
| | | failedProj_selects) { |
| | | item_id += f.getScore_deducting(); |
| | | 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()); |
| | | mScoreAdapter.addDatas(mArrayList); |
| | | } |
| | | |
| | | MyLog.i(TAG,"监测到有失败项目加入,通知UI更新颜色"); |
| | | 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, "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.HAS_BEEN_START_EXAM){ |
| | | btn_start_exam.setEnabled(false); |
| | | tv_stop.setEnabled(true); |
| | | }else{ |
| | | btn_start_exam.setEnabled(true); |
| | | tv_stop.setEnabled(false); |
| | | } |
| | | } |
| | | Log.i(TAG, "onChanged: "); |
| | | examStatusList.clear(); |
| | | examStatusList.addAll(examStatus); |
| | | mHandler.obtainMessage(ADD_DATA).sendToTarget(); |
| | | |
| | | |
| | | } |
| | | }); |
| | | |
| | | |
| | | return view; |
| | | } |
| | |
| | | |
| | | private void initView(View view) { |
| | | |
| | | av_curve = view.findViewById(R.id.av2); |
| | | av_park = view.findViewById(R.id.av3); |
| | | av_podao = view.findViewById(R.id.av4); |
| | | av_zhijiao = view.findViewById(R.id.av1); |
| | | 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); |
| | | //粉红色正在进行该项目的考试 |
| | | // examStatusList.add(new ExamStatus(1, 0)); |
| | | // examStatusList.add(new ExamStatus(2, 1)); |
| | | // examStatusList.add(new ExamStatus(3, 0)); |
| | | // examStatusList.add(new ExamStatus(4, 2)); |
| | | // examStatusList.add(new ExamStatus(5, 1)); |
| | | |
| | | |
| | | // mHandler.obtainMessage(ADD_DATA).sendToTarget(); |
| | | // av_curve.setColor(whatPaintColor(examStatusList.get(3))); |
| | | // av_zhijiao.setColor(whatPaintColor(examStatusList.get(4))); |
| | | // av_podao.setColor(whatPaintColor(examStatusList.get(1))); |
| | | // av_park.setColor(whatPaintColor(examStatusList.get(2))); |
| | | // houseView.setColor(whatPaintColor(examStatusList.get(0))); |
| | | |
| | | view.findViewById(R.id.btn_return).setOnClickListener(this); |
| | | mListView = view.findViewById(R.id.lv); |
| | | mListView.setFocusable(false); |
| | | view.findViewById(R.id.view_map).setOnClickListener(this); |
| | |
| | | mListView.setAdapter(mScoreAdapter); |
| | | btn_start_exam = view.findViewById(R.id.btn_start); |
| | | btn_start_exam.setOnClickListener(this); |
| | | view.findViewById(R.id.tv_stop).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)); |
| | | |
| | | } |
| | |
| | | public void onClick(View v) { |
| | | switch (v.getId()) { |
| | | case R.id.btn_start: |
| | | examStatusViewModel.updateStartExam(Constant.HAS_BEEN_START_EXAM); |
| | | try { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("exam", 1); |
| | |
| | | break; |
| | | case R.id.tv_stop: |
| | | Toast.makeText(_mActivity, "结束考试", Toast.LENGTH_SHORT).show(); |
| | | OneTimeWorkRequest examStatusInitWork = OneTimeWorkRequest.from(ExamStatusInitWorker.class); |
| | | WorkManager.getInstance(_mActivity).enqueue(examStatusInitWork); |
| | | try { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("exam", 0); |
| | |
| | | } |
| | | start(mapFragment); |
| | | break; |
| | | case R.id.btn_return: |
| | | _mActivity.onBackPressed(); |
| | | break; |
| | | } |
| | | } |
| | | |