| | |
| | | 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.StraightLineSetting; |
| | | 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.StraightLineSettingViewModel; |
| | | |
| | | /** |
| | | * DriveJudge |
| | | * |
| | | * 直线行驶设置 |
| | | * Created by lzw on 2020/9/14. 10:16:39 |
| | | * 邮箱:632393724@qq.com |
| | | * All Rights Saved! Chongqing AnYun Tech co. LTD |
| | |
| | | public class FragmentSetting4 extends SupportFragment { |
| | | private static final String ARG_NUMBER = "arg_number"; |
| | | private static final String TAG = FragmentSetting4.class.getSimpleName(); |
| | | |
| | | private Gson gson = new Gson(); |
| | | |
| | | private int mNumber; |
| | | |
| | | private TextEditText te_straight_limit_distance; |
| | | private TextEditText te_straight_max_offset; |
| | | |
| | | private StraightLineSetting mStrarightLineSetting; |
| | | private StraightLineSettingViewModel straightLineSettingViewModel; |
| | | |
| | | public static FragmentSetting4 newInstance(String number) { |
| | | FragmentSetting4 fragment = new FragmentSetting4(); |
| | |
| | | @Nullable |
| | | @Override |
| | | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
| | | View view = inflater.inflate(R.layout.layout_fragment_parkover, container, false); |
| | | View view = inflater.inflate(R.layout.layout_fragment_straight_line, container, false); |
| | | initView(view); |
| | | straightLineSettingViewModel = ViewModelProviders.of(this).get(StraightLineSettingViewModel.class); |
| | | straightLineSettingViewModel.getStraightLineSetting().observe(this, new Observer<StraightLineSetting>() { |
| | | @Override |
| | | public void onChanged(StraightLineSetting commonSetting) { |
| | | if (commonSetting != null){ |
| | | mStrarightLineSetting = commonSetting; |
| | | setDatas(); |
| | | } |
| | | } |
| | | }); |
| | | return view; |
| | | } |
| | | |
| | | private void initView(View view) { |
| | | te_straight_limit_distance = view.findViewById(R.id.straight_limit_distance); |
| | | te_straight_max_offset = view.findViewById(R.id.straight_max_offset); |
| | | |
| | | view.findViewById(R.id.btn_setting_save).setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | String teStraightLimitDistanceInput = te_straight_limit_distance.getInput(); |
| | | String teStraightMaxOffsetInput = te_straight_max_offset.getInput(); |
| | | if (mStrarightLineSetting != null){ |
| | | if (Utils.isDigital(teStraightLimitDistanceInput)){ |
| | | |
| | | mStrarightLineSetting.setStraight_limit_distance(Integer.parseInt(teStraightLimitDistanceInput)); |
| | | } |
| | | if (Utils.isNumber(teStraightMaxOffsetInput)){ |
| | | |
| | | mStrarightLineSetting.setStraight_max_offset(Double.parseDouble(teStraightMaxOffsetInput)); |
| | | } |
| | | |
| | | straightLineSettingViewModel.saveCommonSetting(mStrarightLineSetting); |
| | | AYSdk.getInstance().sendCmd(Constant.ID_judge_args,gson.toJson(mStrarightLineSetting)); |
| | | Toast.makeText(_mActivity, "直线行驶设置成功", Toast.LENGTH_SHORT).show(); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | private void setDatas() { |
| | | te_straight_limit_distance.setInput(String.valueOf(mStrarightLineSetting.getStraight_limit_distance())); |
| | | te_straight_max_offset.setInput(String.valueOf(mStrarightLineSetting.getStraight_max_offset())); |
| | | } |
| | | } |