Class FormElement<T extends FormElement,V extends FormElementViewHolder>

java.lang.Object
eltos.simpledialogfragment.form.FormElement<T,V>
All Implemented Interfaces:
android.os.Parcelable
Direct Known Subclasses:
Check, ColorField, DateTime, Hint, Input, Spinner

public abstract class FormElement<T extends FormElement,V extends FormElementViewHolder> extends Object implements android.os.Parcelable
Base-class for form elements to be used with SimpleFormDialog Each form element holds a resultKey that is used to receive element specific results in SimpleFormDialog.onResult(int) Created by eltos on 20.02.17.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface android.os.Parcelable

    android.os.Parcelable.ClassLoaderCreator<T extends Object>, android.os.Parcelable.Creator<T extends Object>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final int
     
    protected boolean
     
    protected String
     

    Fields inherited from interface android.os.Parcelable

    CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    FormElement(android.os.Parcel in)
     
    protected
    FormElement(String resultKey)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract V
    Return your custom implementation of FormElementViewHolder here
    int
     
    protected String
    getText(android.content.Context context)
     
    label(int textResourceId)
    Sets the label
    label(String text)
    Sets the label
    Mark this Field as required.
    required(boolean required)
    Set the required flag for this field.
    void
    writeToParcel(android.os.Parcel dest, int flags)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • NO_ID

      protected static final int NO_ID
      See Also:
    • resultKey

      protected String resultKey
    • required

      protected boolean required
  • Constructor Details

    • FormElement

      protected FormElement(String resultKey)
    • FormElement

      protected FormElement(android.os.Parcel in)
  • Method Details

    • buildViewHolder

      public abstract V buildViewHolder()
      Return your custom implementation of FormElementViewHolder here
      Returns:
      The view holder that can represent this form element
    • required

      public T required()
      Mark this Field as required. See required(boolean)
      Returns:
      this instance
    • required

      public T required(boolean required)
      Set the required flag for this field. This has different meanings depending on the element type Input fields will display an error message if their input is empty. Check fields will be required to be checked
      Parameters:
      required - whether this field is required
      Returns:
      this instance
    • label

      public T label(String text)
      Sets the label
      Parameters:
      text - label text as string
      Returns:
      this instance
    • label

      public T label(@StringRes int textResourceId)
      Sets the label
      Parameters:
      textResourceId - label text as android string resource
      Returns:
      this instance
    • getText

      @Nullable protected String getText(android.content.Context context)
    • describeContents

      public int describeContents()
      Specified by:
      describeContents in interface android.os.Parcelable
    • writeToParcel

      public void writeToParcel(android.os.Parcel dest, int flags)
      Specified by:
      writeToParcel in interface android.os.Parcelable