app/src/main/java/safeluck/drive/evaluation/fragment/NetWorkTrainFragment.java
@@ -35,8 +35,11 @@
import safeluck.drive.evaluation.DB.failitems.FailedProj_select;
import safeluck.drive.evaluation.R;
import safeluck.drive.evaluation.adapter.ScoreAdapter;
import safeluck.drive.evaluation.bean.ExamStatus;
import safeluck.drive.evaluation.bean.ScoreBean;
import safeluck.drive.evaluation.cEventCenter.CEventCenter;
import safeluck.drive.evaluation.customview.ArrowView;
import safeluck.drive.evaluation.customview.HouseView;
/**
 * 联网训练UI
@@ -48,9 +51,13 @@
public class NetWorkTrainFragment extends SupportFragment implements View.OnClickListener {
    private static final String TAG = NetWorkTrainFragment.class.getSimpleName();
    private ListView mListView ;
    private ListView mListView;
    private Button btn_start_exam;
    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;//扣分分数总和
@@ -63,7 +70,7 @@
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.layout_train_fragment,container,false);
        View view = inflater.inflate(R.layout.layout_train_fragment, container, false);
        initView(view);
        FailedProjViewModel failedProjViewModel = ViewModelProviders.of(this).get(FailedProjViewModel.class);
@@ -72,21 +79,89 @@
            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()));
                    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);
                }
            }
        });
        item_conents.add("侧方停车");
        return view;
    }
    private int whatPaintColor(ExamStatus examStatus) {
        int map_id = examStatus.getMap_id();
        int status = examStatus.getEnter();
        switch (status) {
            case 0://考试完成
                switch (map_id) {
                    case 1://倒库
                        if (item_conents.contains("倒车入库")) {
                            return getResources().getColor(R.color.colorAccent);
                        }else{
                            return getResources().getColor(R.color.train_btn_return);
                        }
                    case 2:
                        if (item_conents.contains("坡道定点停车和起步")) {
                            return getResources().getColor(R.color.colorAccent);
                        }else{
                            return getResources().getColor(R.color.train_btn_return);
                        }
                    case 3:
                        if (item_conents.contains("侧方停车")) {
                            return getResources().getColor(R.color.colorAccent);
                        }else{
                            return getResources().getColor(R.color.train_btn_return);
                        }
                    case 4:
                        if (item_conents.contains("曲线行驶")) {
                            return getResources().getColor(R.color.colorAccent);
                        }else{
                            return getResources().getColor(R.color.train_btn_return);
                        }
                    case 5:
                        if (item_conents.contains("直角转弯")) {
                            return getResources().getColor(R.color.colorAccent);
                        }else{
                            return getResources().getColor(R.color.train_btn_return);
                        }
                }
            case 1://进入考场项目
                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) {
        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);
        houseView = view.findViewById(R.id.hv);
//粉红色正在进行该项目的考试
        examStatusList.add(new ExamStatus(1, 2));
        examStatusList.add(new ExamStatus(2, 1));
        examStatusList.add(new ExamStatus(3, 0));
        examStatusList.add(new ExamStatus(4, 2));
        examStatusList.add(new ExamStatus(5, 1));
        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)));
        sendRTKConfig2RemoteService();
        mListView = view.findViewById(R.id.lv);
        mListView.setFocusable(false);
@@ -96,23 +171,25 @@
        btn_start_exam = view.findViewById(R.id.btn_start);
        btn_start_exam.setOnClickListener(this);
        view.findViewById(R.id.tv_stop).setOnClickListener(this);
        mListView.addHeaderView(LayoutInflater.from(_mActivity).inflate(R.layout.layout_score_item,null));
        mListView.addHeaderView(LayoutInflater.from(_mActivity).inflate(R.layout.layout_score_item, null));
    }
    private void sendRTKConfig2RemoteService() {
//        MyLog.d(TAG,"主动推送RTKConfig");
//        CEventCenter.dispatchEvent(Constant.BIND_RTKCONFIG_TOPIC,Constant.FETCH_RTK_PLATFORM_INFO,0,"");
    }
    @Override
    public void onClick(View v) {
        switch (v.getId()){
        switch (v.getId()) {
            case R.id.btn_start:
                try {
                    JSONObject jsonObject = new JSONObject();
                    jsonObject.put("exam",1);
                    jsonObject.put("exam", 1);
                    String examJson = jsonObject.toString();
                    Log.i(TAG, "onClick: "+examJson);
                    AYSdk.getInstance().sendCmd(Constant.EXAM_STATUS,examJson);
                    Log.i(TAG, "onClick: " + examJson);
                    AYSdk.getInstance().sendCmd(Constant.EXAM_STATUS, examJson);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
@@ -121,18 +198,18 @@
                Toast.makeText(_mActivity, "结束考试", Toast.LENGTH_SHORT).show();
                try {
                    JSONObject jsonObject = new JSONObject();
                    jsonObject.put("exam",0);
                    jsonObject.put("exam", 0);
                    String examJson = jsonObject.toString();
                    Log.i(TAG, "onClick: "+examJson);
                    AYSdk.getInstance().sendCmd(Constant.EXAM_STATUS,examJson);
                    Log.i(TAG, "onClick: " + examJson);
                    AYSdk.getInstance().sendCmd(Constant.EXAM_STATUS, examJson);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                break;
            case R.id.view_map:
                MapFragment mapFragment = findFragment(MapFragment.class);
                if (mapFragment==null){
                    mapFragment = (MapFragment)MapFragment.newInstance();
                if (mapFragment == null) {
                    mapFragment = (MapFragment) MapFragment.newInstance();
                }
                start(mapFragment);
                break;