| | |
| | | |
| | | import android.os.Bundle; |
| | | |
| | | import android.util.Log; |
| | | 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 androidx.annotation.NonNull; |
| | | import androidx.annotation.Nullable; |
| | | |
| | | import com.anyun.exam.lib.AYSdk; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.JsonElement; |
| | | import com.google.gson.JsonObject; |
| | | |
| | | import org.json.JSONException; |
| | | import org.json.JSONObject; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | import me.yokeyword.fragmentation.SupportFragment; |
| | | import safeluck.drive.evaluation.Constant; |
| | | import safeluck.drive.evaluation.R; |
| | | import safeluck.drive.evaluation.adapter.ScoreAdapter; |
| | | import safeluck.drive.evaluation.bean.ScoreBean; |
| | |
| | | */ |
| | | public class NetWorkTrainFragment extends SupportFragment implements View.OnClickListener { |
| | | |
| | | private static final String TAG = NetWorkTrainFragment.class.getSimpleName(); |
| | | private ListView mListView ; |
| | | private Button btn_start_exam; |
| | | private ScoreAdapter mScoreAdapter; |
| | |
| | | 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); |
| | | mListView.addHeaderView(LayoutInflater.from(_mActivity).inflate(R.layout.layout_score_item,null)); |
| | | mArrayList.add(new ScoreBean(12,"直角转弯","后轮胎压线")); |
| | | mArrayList.add(new ScoreBean(100,"倒车入库","未系安全带")); |
| | |
| | | public void onClick(View v) { |
| | | switch (v.getId()){ |
| | | case R.id.btn_start: |
| | | AYSdk.getInstance().at_sendCmd("AT+BEGIN_EXAM:0\r\n"); |
| | | try { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("exam",1); |
| | | 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(); |
| | | 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(); |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |