From 9119ae3e2d99b5afbc8611a99fc134f35260955b Mon Sep 17 00:00:00 2001 From: endian11 <Dana_Lee1016@126.com> Date: 星期一, 26 十月 2020 17:42:22 +0800 Subject: [PATCH] 完成规则设置 --- app/src/main/java/safeluck/drive/evaluation/fragment/rulefragments/FragmentSetting9.java | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 43 insertions(+), 0 deletions(-) diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/rulefragments/FragmentSetting9.java b/app/src/main/java/safeluck/drive/evaluation/fragment/rulefragments/FragmentSetting9.java index e62cfa4..f8e8cbe 100644 --- a/app/src/main/java/safeluck/drive/evaluation/fragment/rulefragments/FragmentSetting9.java +++ b/app/src/main/java/safeluck/drive/evaluation/fragment/rulefragments/FragmentSetting9.java @@ -5,16 +5,22 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Toast; import androidx.annotation.Nullable; import androidx.lifecycle.Observer; import androidx.lifecycle.ViewModelProviders; +import com.anyun.exam.lib.AYSdk; +import com.google.gson.Gson; + import me.yokeyword.fragmentation.SupportFragment; +import safeluck.drive.evaluation.Constant; import safeluck.drive.evaluation.R; import safeluck.drive.evaluation.bean.CommonSetting; import safeluck.drive.evaluation.bean.SideStopSetting; import safeluck.drive.evaluation.fragment.rulefragments.cview.TextEditText; +import safeluck.drive.evaluation.util.Utils; import safeluck.drive.evaluation.viewmodels.CommonSettingViewModel; import safeluck.drive.evaluation.viewmodels.SideStopSettingViewModel; @@ -25,6 +31,7 @@ * All Rights Saved! Chongqing AnYun Tech co. LTD */ public class FragmentSetting9 extends SupportFragment { + private Gson gson = new Gson(); private static final String ARG_NUMBER = "arg_number"; private static final String TAG = FragmentSetting9.class.getSimpleName(); @@ -82,7 +89,43 @@ te_stop_car_limit_distance = view.findViewById(R.id.stop_car_limit_distance); te_stop_car_edge_red_distance = view.findViewById(R.id.stop_car_edge_red_distance); te_stop_car_edge_yellow_distance = view.findViewById(R.id.stop_car_edge_yellow_distance); + view.findViewById(R.id.btn_setting_save).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + String teRoadMaxSpeedInput = te_road_max_speed.getInput(); + String teRoadTotalDistanceInput = te_road_total_distance.getInput(); + String teStopCarOpenDoorAllowTimeInput = te_stop_car_open_door_allow_time.getInput(); + String teStopCarLimitDistanceInput = te_stop_car_limit_distance.getInput(); + String teStopCarEdgeRedDistanceInput = te_stop_car_edge_red_distance.getInput(); + String teStopCarEdgeYellowDistanceInput = te_stop_car_edge_yellow_distance.getInput(); + if (mSideStopSetting!=null){ + if (Utils.isDigital(teRoadTotalDistanceInput)){ + mSideStopSetting.setRoad_total_distance(Integer.parseInt(teRoadTotalDistanceInput)); + } + if (Utils.isDigital(teRoadMaxSpeedInput)){ + mSideStopSetting.setRoad_max_speed(Integer.parseInt(teRoadMaxSpeedInput)); + } + if (Utils.isDigital(teStopCarOpenDoorAllowTimeInput)){ + mSideStopSetting.setStop_car_open_door_allow_time(Integer.parseInt(teStopCarOpenDoorAllowTimeInput)); + } + if (Utils.isDigital(teStopCarLimitDistanceInput)){ + mSideStopSetting.setStop_car_limit_distance(Integer.parseInt(teStopCarLimitDistanceInput)); + } + if (Utils.isNumber(teStopCarEdgeRedDistanceInput)){ + mSideStopSetting.setStop_car_edge_red_distance(Double.parseDouble(teStopCarEdgeRedDistanceInput)); + } + if (Utils.isNumber(teStopCarEdgeYellowDistanceInput)){ + mSideStopSetting.setStop_car_edge_yellow_distance(Double.parseDouble(teStopCarEdgeYellowDistanceInput)); + } + + + mSideStopSettingViewModel.saveSideStopSetting(mSideStopSetting); + Toast.makeText(_mActivity, "闈犺竟鍋滆溅璁剧疆", Toast.LENGTH_SHORT).show(); + AYSdk.getInstance().sendCmd(Constant.ID_judge_args,gson.toJson(mSideStopSetting)); + } + } + }); } private void setDatas() { -- Gitblit v1.8.0