public class FormCheckable<V extends android.view.View & android.widget.Checkable> extends BaseFormComponent<V,Boolean>
BaseFormComponent implementation that wraps form checkable view like
CheckBox or RadioButton into
component that can be validated by FormValidator when
validating a form in which is such a view presented.FormEditable| Constructor and Description |
|---|
FormCheckable(int id)
Same as
FormCheckable(int, boolean) with requiresChecked parameter set to
true. |
FormCheckable(int id,
boolean requiresChecked)
Creates a new instance of FormCheckable component for a checkable view with the specified
id.
|
FormCheckable(V checkable)
Same as
FormCheckable(View, boolean) with requiresChecked parameter
set to true. |
FormCheckable(V checkable,
boolean requiresChecked)
Creates a new instance of FormCheckable component for the given checkable view.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearError()
This implementation does nothing.
|
Boolean |
getInput()
Returns the current input presented by an attached view of this form component.
|
boolean |
isChecked()
Checks, whether the compound view of this component is checked or not.
|
protected boolean |
onValidate(Boolean input)
Invoked whenever
BaseFormComponent.validate() is called. |
void |
setError(CharSequence errorMessage)
Sets an error for this form component.
|
attachToValidator, findComponent, findComponentTraversal, getId, getLastValidatedInput, getResources, getValidator, getView, hasError, hasInputChanged, isAttachedToValidator, obtainString, obtainText, onAttachedToValidator, onComponentViewAttached, resetCurrentState, setHasError, validatepublic FormCheckable(@IdRes
int id)
FormCheckable(int, boolean) with requiresChecked parameter set to
true.public FormCheckable(@IdRes
int id,
boolean requiresChecked)
id - Id used to find the checkable view within the form view hierarchy of
the associated FormValidator via FormValidator.findViewById(int).requiresChecked - Flag to be compared to the checked state of the checkable view during
the validation process.public FormCheckable(@NonNull
V checkable)
FormCheckable(View, boolean) with requiresChecked parameter
set to true.public FormCheckable(@NonNull
V checkable,
boolean requiresChecked)
checkable - Checkable view that should be validated.requiresChecked - Flag to be compared to the checked state of the checkable view during
the validation process.BaseFormComponent.BaseFormComponent(int, View)protected boolean onValidate(@NonNull
Boolean input)
BaseFormComponentBaseFormComponent.validate() is called. Note, that there will be BaseFormComponent.resetCurrentState()
always called before this.onValidate in class BaseFormComponent<V extends android.view.View & android.widget.Checkable,Boolean>input - Current input of this form component to be validated.true if the current form component's view state passed
validation requirements, false otherwise.FormComponent.getInput()public boolean isChecked()
True if checkable view is checked, false otherwise.@NonNull public Boolean getInput()
FormComponentpublic void setError(@NonNull
CharSequence errorMessage)
FormComponentNote, that a specific implementations can ignore this call and also depends on the specific implementation how the requested error parameter will be shown.
errorMessage - The desired error message.FormComponent.clearError()public void clearError()
Note, that this form component cannot have error specified as it just shows a toast
whenever setError(CharSequence) is called.
clearError in interface FormComponent<V extends android.view.View & android.widget.Checkable,Boolean>clearError in class BaseFormComponent<V extends android.view.View & android.widget.Checkable,Boolean>