Package eltos.simpledialogfragment.form
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-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
static final int
protected int[]
static final android.os.Parcelable.Creator<ColorField>
static final int
protected int
Fields inherited from class eltos.simpledialogfragment.form.FormElement
NO_ID, required, resultKey
Fields inherited from interface android.os.Parcelable
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionallowCustom
(boolean allow) Set this to true to show a field with a color picker optioneltos.simpledialogfragment.form.ColorViewHolder
Return your custom implementation ofFormElementViewHolder
herecolor
(int preset) Sets the initial colorcolorRes
(int presetResourceId) Sets the initial colorcolors
(int[] colors) Sets the colors to choose from Default is theSimpleColorDialog.DEFAULT_COLORS
setcolors
(android.content.Context context, int colorArrayRes) Sets the color pallet to choose from May be one ofSimpleColorDialog.MATERIAL_COLOR_PALLET
,SimpleColorDialog.MATERIAL_COLOR_PALLET_DARK
,SimpleColorDialog.MATERIAL_COLOR_PALLET_LIGHT
,SimpleColorDialog.BEIGE_COLOR_PALLET
or a custom palletint
protected int
getInitialColor
(android.content.Context context) static ColorField
Factory method for a color field.showOutline
(int color) Add a colored outline to the color fields.void
writeToParcel
(android.os.Parcel dest, int flags)
-
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
-
-
Constructor Details
-
ColorField
protected ColorField(android.os.Parcel in)
-
-
Method Details
-
picker
Factory method for a color field.- Parameters:
key
- the key that can be used to receive the final state from the bundle inSimpleDialog.OnDialogResultListener.onResult(java.lang.String, int, android.os.Bundle)
- Returns:
- this instance
-
color
Sets the initial color- Parameters:
preset
- initial state- Returns:
- this instance
-
colorRes
Sets the initial color- Parameters:
presetResourceId
- initial color as resource- Returns:
- this instance
-
colors
Sets the colors to choose from Default is theSimpleColorDialog.DEFAULT_COLORS
set- Parameters:
colors
- array of rgb-colors- Returns:
- this instance
-
colors
Sets the color pallet to choose from May be one ofSimpleColorDialog.MATERIAL_COLOR_PALLET
,SimpleColorDialog.MATERIAL_COLOR_PALLET_DARK
,SimpleColorDialog.MATERIAL_COLOR_PALLET_LIGHT
,SimpleColorDialog.BEIGE_COLOR_PALLET
or a custom pallet- Parameters:
context
- a context to resolve the resourcecolorArrayRes
- color array resource id- Returns:
- this instance
-
allowCustom
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
-
buildViewHolder
public eltos.simpledialogfragment.form.ColorViewHolder buildViewHolder()Description copied from class:FormElement
Return your custom implementation ofFormElementViewHolder
here- Specified by:
buildViewHolder
in classFormElement<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 interfaceandroid.os.Parcelable
- Overrides:
writeToParcel
in classFormElement<ColorField,
eltos.simpledialogfragment.form.ColorViewHolder>
-
describeContents
public int describeContents()- Specified by:
describeContents
in interfaceandroid.os.Parcelable
- Overrides:
describeContents
in classFormElement<ColorField,
eltos.simpledialogfragment.form.ColorViewHolder>
-