| | |
| | | package safeluck.drive.evaluation.fragment; |
| | | |
| | | import android.content.Context; |
| | | import android.os.Bundle; |
| | | |
| | | import android.os.Handler; |
| | |
| | | import safeluck.drive.evaluation.adapter.ScoreAdapter; |
| | | import safeluck.drive.evaluation.DB.exam_status.ExamStatus; |
| | | import safeluck.drive.evaluation.bean.ScoreBean; |
| | | import safeluck.drive.evaluation.cEventCenter.CEventCenter; |
| | | import safeluck.drive.evaluation.cEventCenter.ICEventListener; |
| | | import safeluck.drive.evaluation.customview.ArrowView; |
| | | import safeluck.drive.evaluation.customview.HouseView; |
| | | |
| | |
| | | private int item_id;//扣分分数总和 |
| | | private ExamStatusViewModel examStatusViewModel; |
| | | private static final int ADD_DATA = 1; |
| | | private TextView tv_speed,tv_total_score; |
| | | private double speed=0.0; |
| | | |
| | | private int currTotalScore = 100; |
| | | private List<ScoreBean> mArrayList = new ArrayList<>(); |
| | | private static final int SPEED_DATA = 2; |
| | | |
| | | public static SupportFragment newInstance() { |
| | | return new NetWorkTrainFragment(); |
| | |
| | | @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; |
| | | } |
| | |
| | | item_conents.add(f.getItem_content()); |
| | | mScoreAdapter.addDatas(mArrayList); |
| | | } |
| | | |
| | | currTotalScore -=item_id; |
| | | if (currTotalScore < Constant.PASSING_SCORE){ |
| | | MyLog.i(TAG,"低于80,不合格"); |
| | | } |
| | | MyLog.i(TAG,"监测到有失败项目加入,通知UI更新颜色"); |
| | | mHandler.obtainMessage(ADD_DATA).sendToTarget(); |
| | | } |
| | |
| | | av_zhijiao = view.findViewById(R.id.av4); |
| | | houseView = view.findViewById(R.id.hv); |
| | | |
| | | 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); |
| | |
| | | } |
| | | } |
| | | |
| | | private ICEventListener icEventListener = new ICEventListener() { |
| | | @Override |
| | | public void onCEvent(String topic, int msgCode, int resultCode, Object obj) { |
| | | speed = (double)obj; |
| | | mHandler.obtainMessage(SPEED_DATA).sendToTarget(); |
| | | } |
| | | }; |
| | | @Override |
| | | public void onAttach(Context context) { |
| | | super.onAttach(context); |
| | | CEventCenter.onBindEvent(true,icEventListener,Constant.BIND_SPEED_TOPIC); |
| | | } |
| | | |
| | | @Override |
| | | public void onDetach() { |
| | | super.onDetach(); |
| | | CEventCenter.onBindEvent(false,icEventListener,Constant.BIND_SPEED_TOPIC); |
| | | } |
| | | } |