Package eltos.simpledialogfragment.form
Class FormElementViewHolder<E extends FormElement>
java.lang.Object
eltos.simpledialogfragment.form.FormElementViewHolder<E>
The Base class for all ViewHolders
This class is used to create the View that represents the corresponding
FormElement
and to maintain it's functionality
Created by eltos on 23.02.17.-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract boolean
focus
(SimpleFormDialog.FocusActions actions) Method to focus this elementprotected abstract int
Implement this method to return a custom layout resource id for this viewprotected abstract boolean
posButtonEnabled
(android.content.Context context) Method to check for empty input, (un-)checked state etc.protected abstract void
putResults
(android.os.Bundle results, String key) Method to publish results from this view inSimpleDialog.OnDialogResultListener.onResult(java.lang.String, int, android.os.Bundle)
protected abstract void
saveState
(android.os.Bundle outState) Method to save this elements state Bundles are maintained on a per-view basis, so that keys can be arbitraryprotected abstract void
setUpView
(android.view.View view, android.content.Context context, android.os.Bundle savedInstanceState, SimpleFormDialog.DialogActions actions) Implement this method to setup your view for the first time or after asaveState(android.os.Bundle)
protected abstract boolean
validate
(android.content.Context context) Method to validate input, state etc. and display an error message or indicator
-
Field Details
-
field
The FormElement that this ViewHolder represents.
-
-
Constructor Details
-
FormElementViewHolder
-
-
Method Details
-
getContentViewLayout
@LayoutRes protected abstract int getContentViewLayout()Implement this method to return a custom layout resource id for this view- Returns:
- layout string resource
-
setUpView
protected abstract void setUpView(android.view.View view, android.content.Context context, android.os.Bundle savedInstanceState, SimpleFormDialog.DialogActions actions) Implement this method to setup your view for the first time or after asaveState(android.os.Bundle)
- Parameters:
view
- The view that was inflated using the layout fromgetContentViewLayout()
context
- The context of this viewsavedInstanceState
- A bundle containing everything that was saved insaveState(Bundle)
actions
- A callback for convenient methods. SeeSimpleFormDialog.DialogActions
-
saveState
protected abstract void saveState(android.os.Bundle outState) Method to save this elements state Bundles are maintained on a per-view basis, so that keys can be arbitrary- Parameters:
outState
- The bundle to save the state to
-
putResults
Method to publish results from this view inSimpleDialog.OnDialogResultListener.onResult(java.lang.String, int, android.os.Bundle)
- Parameters:
results
- The bundle to save the results tokey
- The key that has to be used when storing results in the bundle
-
focus
Method to focus this element- Parameters:
actions
- An object providing useful callbacks, seeSimpleFormDialog.FocusActions
- Returns:
- Whether this view or one of its descendants actually took focus.
-
posButtonEnabled
protected abstract boolean posButtonEnabled(android.content.Context context) Method to check for empty input, (un-)checked state etc. Only simple (and fast) checks here, no error displaying! This is used only for single element forms.- Parameters:
context
- A context- Returns:
- true if positive button can be enabled
-
validate
protected abstract boolean validate(android.content.Context context) Method to validate input, state etc. and display an error message or indicator- Parameters:
context
- A context- Returns:
- true if the input, state etc. is valid, false otherwise
-