| | |
| | | package safeluck.drive.evaluation.fragment; |
| | | |
| | | import android.content.Context; |
| | | import android.os.Bundle; |
| | | |
| | | import androidx.annotation.NonNull; |
| | |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.widget.Button; |
| | | import android.widget.ListView; |
| | | import android.widget.Toast; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.EventListener; |
| | | import java.util.List; |
| | | |
| | | import me.yokeyword.fragmentation.SupportFragment; |
| | |
| | | import safeluck.drive.evaluation.R; |
| | | import safeluck.drive.evaluation.adapter.ScoreAdapter; |
| | | import safeluck.drive.evaluation.bean.ScoreBean; |
| | | import safeluck.drive.evaluation.cEventCenter.CEventCenter; |
| | | import safeluck.drive.evaluation.cEventCenter.ICEventListener; |
| | | |
| | | /**单机训练UI |
| | | * MyApplication2 |
| | |
| | | |
| | | private static final String TAG = TrainFragment.class.getSimpleName(); |
| | | private ListView mListView ; |
| | | private Button btn_train; |
| | | private ScoreAdapter mScoreAdapter; |
| | | |
| | | private int item_id; |
| | | |
| | | private List<ScoreBean> mArrayList = new ArrayList<>(); |
| | | |
| | | private ICEventListener eventListener =new ICEventListener() { |
| | | @Override |
| | | public void onCEvent(String topic, int msgCode, int resultCode, Object obj) { |
| | | Log.i(TAG, "onCEvent: "+(String)obj); |
| | | } |
| | | }; |
| | | |
| | | @Override |
| | | public void onAttach(Context context) { |
| | | super.onAttach(context); |
| | | CEventCenter.onBindEvent(true, eventListener,"train"); |
| | | } |
| | | |
| | | @Override |
| | | public void onDetach() { |
| | | super.onDetach(); |
| | | CEventCenter.onBindEvent(false,eventListener,"train"); |
| | | } |
| | | |
| | | public static SupportFragment newInstance(){ |
| | | return new TrainFragment(); |
| | |
| | | return view; |
| | | } |
| | | private void initView(View view) { |
| | | |
| | | mListView = view.findViewById(R.id.lv); |
| | | 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)); |
| | | mArrayList.add(new ScoreBean(12,"直角转弯","后轮胎压线")); |
| | | mArrayList.add(new ScoreBean(100,"倒车入库","未系安全带")); |
| | |
| | | start(passwordFragment); |
| | | } |
| | | break; |
| | | case R.id.btn_start: |
| | | Toast.makeText(_mActivity, "开始巽寮", Toast.LENGTH_SHORT).show(); |
| | | break; |
| | | } |
| | | } |
| | | } |