refactoring code

This commit is contained in:
yannick.blanken@csc-online.eu 2022-07-22 09:54:49 +02:00
parent 7d6a9ad981
commit e73f9ba122
3 changed files with 21 additions and 6 deletions

View File

@ -33,11 +33,19 @@ public abstract class AbstractFragment extends Fragment {
}
protected void setText(TextInputLayout item, String text) {
item.getEditText().setText(text);
setText(item.getEditText(), text);
}
protected void setText(EditText item, String text) {
item.setText(text);
}
protected void clearText(TextInputLayout item) {
item.getEditText().setText(null);
clearText(item.getEditText());
}
protected void clearText(EditText item) {
item.setText(null);
}
//endregion

View File

@ -80,11 +80,18 @@ public class DeviceRegistrationFragment extends AbstractFragment {
mViewModel.getMCustomerDevice().observe(getViewLifecycleOwner(), customerDevice -> {
binding.btnStore.setEnabled(customerDevice != null);
if (customerDevice != null) {
binding.editSerialNumber.setText(customerDevice.getSerialNumber());
binding.editDeviceNumber.setText(customerDevice.getDeviceNumber());
binding.editName.setText(customerDevice.getName());
setText( binding.editSerialNumber, customerDevice.getSerialNumber());
setText( binding.editDeviceNumber, customerDevice.getDeviceNumber());
setText( binding.editName, customerDevice.getName());
binding.imgDevice.setImageBitmap(customerDevice.getBitmap());
}else{
clearText(binding.editSerialNumber);
clearText(binding.editDeviceNumber);
clearText(binding.editName);
//ToDo set -NO IMAGE- IMAGE
}
});

View File

@ -149,7 +149,7 @@ public class VehicleRegistrationViewModel extends AbstractBaseViewModel {
}
public String getCurrentVehicleVin() {
if(getCurrentVehicle().getValue() != null)
if (getCurrentVehicle().getValue() != null)
return getCurrentVehicle().getValue().getVin();
return null;