| | |
| | | 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.CorneringLampSetting; |
| | | 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.CorneringLampSettingViewModel; |
| | | |
| | | /** |
| | | * DriveJudge |
| | |
| | | private static final String ARG_NUMBER = "arg_number"; |
| | | private static final String TAG = FragmentSetting6.class.getSimpleName(); |
| | | |
| | | |
| | | private Gson gson = new Gson(); |
| | | private int mNumber; |
| | | |
| | | private TextEditText te_turn_signal_min_advance; |
| | | private CorneringLampSetting mCornerLampSetting; |
| | | private CorneringLampSettingViewModel corneringLampSettingViewModel; |
| | | |
| | | public static FragmentSetting6 newInstance(String number) { |
| | | FragmentSetting6 fragment = new FragmentSetting6(); |
| | |
| | | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
| | | View view = inflater.inflate(R.layout.layout_fragment_setlights, container, false); |
| | | initView(view); |
| | | corneringLampSettingViewModel = ViewModelProviders.of(this).get(CorneringLampSettingViewModel.class); |
| | | corneringLampSettingViewModel.getCorneringLampSetting().observe(this, new Observer<CorneringLampSetting>() { |
| | | @Override |
| | | public void onChanged(CorneringLampSetting commonSetting) { |
| | | if (commonSetting != null){ |
| | | mCornerLampSetting = commonSetting; |
| | | setDatas(); |
| | | } |
| | | } |
| | | }); |
| | | return view; |
| | | } |
| | | |
| | | private void initView(View view) { |
| | | te_turn_signal_min_advance = view.findViewById(R.id.turn_signal_min_advance); |
| | | view.findViewById(R.id.btn_setting_save).setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | String teTurnSignalMinAdvanceInput = te_turn_signal_min_advance.getInput(); |
| | | if (mCornerLampSetting != null){ |
| | | if (Utils.isDigital(teTurnSignalMinAdvanceInput)){ |
| | | |
| | | mCornerLampSetting.setTurn_signal_min_advance(Integer.parseInt(teTurnSignalMinAdvanceInput)); |
| | | Toast.makeText(_mActivity, "转向灯设置成功", Toast.LENGTH_SHORT).show(); |
| | | corneringLampSettingViewModel.saveCommonSetting(mCornerLampSetting); |
| | | AYSdk.getInstance().sendCmd(Constant.ID_judge_args,gson.toJson(mCornerLampSetting)); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | private void setDatas() { |
| | | te_turn_signal_min_advance.setInput(String.valueOf(mCornerLampSetting.getTurn_signal_min_advance())); |
| | | } |
| | | } |