Class ColorField

java.lang.Object
eltos.simpledialogfragment.form.FormElement<ColorField,eltos.simpledialogfragment.form.ColorViewHolder>
eltos.simpledialogfragment.form.ColorField
All Implemented Interfaces:
android.os.Parcelable

public class ColorField extends FormElement<ColorField,eltos.simpledialogfragment.form.ColorViewHolder>
A color element to be used with SimpleFormDialog One can pick a color here This will add a ColorInt to resource bundle containing the color. Created by eltos on 06.07.18
  • Field Details

    • NONE

      @ColorInt public static final int NONE
      See Also:
    • AUTO

      @ColorInt public static final int AUTO
      See Also:
    • colors

      protected int[] colors
    • allowCustom

      protected boolean allowCustom
    • outline

      protected int outline
    • CREATOR

      public static final android.os.Parcelable.Creator<ColorField> CREATOR
  • Constructor Details

    • ColorField

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

    • picker

      public static ColorField picker(String key)
      Factory method for a color field.
      Parameters:
      key - the key that can be used to receive the final state from the bundle in SimpleDialog.OnDialogResultListener.onResult(java.lang.String, int, android.os.Bundle)
      Returns:
      this instance
    • color

      public ColorField color(@ColorInt int preset)
      Sets the initial color
      Parameters:
      preset - initial state
      Returns:
      this instance
    • colorRes

      public ColorField colorRes(@ColorRes int presetResourceId)
      Sets the initial color
      Parameters:
      presetResourceId - initial color as resource
      Returns:
      this instance
    • colors

      public ColorField colors(@ColorInt int[] colors)
      Sets the colors to choose from Default is the SimpleColorDialog.DEFAULT_COLORS set
      Parameters:
      colors - array of rgb-colors
      Returns:
      this instance
    • colors

      public ColorField colors(android.content.Context context, @ArrayRes int colorArrayRes)
      Parameters:
      context - a context to resolve the resource
      colorArrayRes - color array resource id
      Returns:
      this instance
    • allowCustom

      public ColorField allowCustom(boolean allow)
      Set this to true to show a field with a color picker option
      Parameters:
      allow - allow custom picked color if true
      Returns:
      this instance
    • showOutline

      public ColorField showOutline(@ColorInt int color)
      Add a colored outline to the color fields. NONE disables the outline (default) AUTO uses a black or white outline depending on the brightness
      Parameters:
      color - color int or NONE or AUTO
      Returns:
      this instance
    • buildViewHolder

      public eltos.simpledialogfragment.form.ColorViewHolder buildViewHolder()
      Description copied from class: FormElement
      Return your custom implementation of FormElementViewHolder here
      Specified by:
      buildViewHolder in class FormElement<ColorField,eltos.simpledialogfragment.form.ColorViewHolder>
      Returns:
      The view holder that can represent this form element
    • getInitialColor

      @ColorInt protected int getInitialColor(android.content.Context context)
    • writeToParcel

      public void writeToParcel(android.os.Parcel dest, int flags)
      Specified by:
      writeToParcel in interface android.os.Parcelable
      Overrides:
      writeToParcel in class FormElement<ColorField,eltos.simpledialogfragment.form.ColorViewHolder>
    • describeContents

      public int describeContents()
      Specified by:
      describeContents in interface android.os.Parcelable
      Overrides:
      describeContents in class FormElement<ColorField,eltos.simpledialogfragment.form.ColorViewHolder>