public class ColorPickerDialog extends DialogFragment implements ColorPickerSwatch.OnColorSelectedListener
Fragment.InstantiationException, Fragment.SavedState
Modifier and Type | Field and Description |
---|---|
protected static String |
KEY_COLOR_CONTENT_DESCRIPTIONS |
protected static String |
KEY_COLORS |
protected static String |
KEY_COLUMNS |
protected static String |
KEY_SELECTED_COLOR |
protected static String |
KEY_SIZE |
protected static String |
KEY_TITLE_ID |
protected AlertDialog |
mAlertDialog |
protected String[] |
mColorContentDescriptions |
protected int[] |
mColors |
protected int |
mColumns |
protected ColorPickerSwatch.OnColorSelectedListener |
mListener |
protected int |
mSelectedColor |
protected int |
mSize |
protected int |
mTitleResId |
static int |
SIZE_LARGE |
static int |
SIZE_SMALL |
STYLE_NO_FRAME, STYLE_NO_INPUT, STYLE_NO_TITLE, STYLE_NORMAL
TRIM_MEMORY_BACKGROUND, TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_RUNNING_CRITICAL, TRIM_MEMORY_RUNNING_LOW, TRIM_MEMORY_RUNNING_MODERATE, TRIM_MEMORY_UI_HIDDEN
Constructor and Description |
---|
ColorPickerDialog() |
Modifier and Type | Method and Description |
---|---|
int[] |
getColors() |
int |
getSelectedColor() |
void |
initialize(int titleResId,
int[] colors,
int selectedColor,
int columns,
int size) |
static ColorPickerDialog |
newInstance(int titleResId,
int[] colors,
int selectedColor,
int columns,
int size) |
void |
onColorSelected(int color)
Called when a specific color square has been selected.
|
void |
onCreate(Bundle savedInstanceState)
Called to do initial creation of a fragment.
|
Dialog |
onCreateDialog(Bundle savedInstanceState)
Override to build your own custom Dialog container.
|
void |
onSaveInstanceState(Bundle outState)
Called to ask the fragment to save its current dynamic state, so it
can later be reconstructed in a new instance of its process is
restarted.
|
void |
setArguments(int titleResId,
int columns,
int size) |
void |
setColorContentDescriptions(String[] colorContentDescriptions) |
void |
setColors(int[] colors) |
void |
setColors(int[] colors,
int selectedColor) |
void |
setOnColorSelectedListener(ColorPickerSwatch.OnColorSelectedListener listener) |
void |
setSelectedColor(int color) |
void |
showPaletteView() |
void |
showProgressBarView() |
dismiss, dismissAllowingStateLoss, dump, getDialog, getLayoutInflater, getShowsDialog, getTheme, isCancelable, onActivityCreated, onAttach, onCancel, onDestroyView, onDetach, onDismiss, onStart, onStop, setCancelable, setShowsDialog, setStyle, show, show, showAllowingStateLoss
equals, getActivity, getAllowEnterTransitionOverlap, getAllowReturnTransitionOverlap, getArguments, getChildFragmentManager, getContext, getEnterTransition, getExitTransition, getFragmentManager, getHost, getId, getLoaderManager, getParentFragment, getReenterTransition, getResources, getRetainInstance, getReturnTransition, getSharedElementEnterTransition, getSharedElementReturnTransition, getString, getString, getTag, getTargetFragment, getTargetRequestCode, getText, getUserVisibleHint, getView, hashCode, instantiate, instantiate, isAdded, isDetached, isHidden, isInLayout, isRemoving, isResumed, isVisible, onActivityResult, onAttach, onAttachFragment, onConfigurationChanged, onContextItemSelected, onCreateAnimator, onCreateContextMenu, onCreateOptionsMenu, onCreateView, onDestroy, onDestroyOptionsMenu, onHiddenChanged, onInflate, onInflate, onInflate, onLowMemory, onMultiWindowModeChanged, onOptionsItemSelected, onOptionsMenuClosed, onPause, onPictureInPictureModeChanged, onPrepareOptionsMenu, onRequestPermissionsResult, onResume, onTrimMemory, onViewCreated, onViewStateRestored, registerForContextMenu, requestPermissions, setAllowEnterTransitionOverlap, setAllowReturnTransitionOverlap, setArguments, setEnterSharedElementCallback, setEnterSharedElementTransitionCallback, setEnterTransition, setExitSharedElementCallback, setExitSharedElementTransitionCallback, setExitTransition, setHasOptionsMenu, setInitialSavedState, setMenuVisibility, setReenterTransition, setRetainInstance, setReturnTransition, setSharedElementEnterTransition, setSharedElementReturnTransition, setTargetFragment, setUserVisibleHint, shouldShowRequestPermissionRationale, startActivity, startActivity, startActivityForResult, startActivityForResult, startIntentSenderForResult, toString, unregisterForContextMenu
public static final int SIZE_LARGE
public static final int SIZE_SMALL
protected AlertDialog mAlertDialog
protected static final String KEY_TITLE_ID
protected static final String KEY_COLORS
protected static final String KEY_COLOR_CONTENT_DESCRIPTIONS
protected static final String KEY_SELECTED_COLOR
protected static final String KEY_COLUMNS
protected static final String KEY_SIZE
protected int mTitleResId
protected int[] mColors
protected String[] mColorContentDescriptions
protected int mSelectedColor
protected int mColumns
protected int mSize
protected ColorPickerSwatch.OnColorSelectedListener mListener
public static ColorPickerDialog newInstance(int titleResId, int[] colors, int selectedColor, int columns, int size)
public void initialize(int titleResId, int[] colors, int selectedColor, int columns, int size)
public void setArguments(int titleResId, int columns, int size)
public void setOnColorSelectedListener(ColorPickerSwatch.OnColorSelectedListener listener)
public void onCreate(Bundle savedInstanceState)
Fragment
Fragment.onAttach(Activity)
and before
Fragment.onCreateView(LayoutInflater, ViewGroup, Bundle)
, but is not called if the fragment
instance is retained across Activity re-creation (see Fragment.setRetainInstance(boolean)
).
Note that this can be called while the fragment's activity is
still in the process of being created. As such, you can not rely
on things like the activity's content view hierarchy being initialized
at this point. If you want to do work once the activity itself is
created, see Fragment.onActivityCreated(Bundle)
.
If your app's targetSdkVersion
is Build.VERSION_CODES.M
or lower, child fragments being restored from the savedInstanceState are restored after
onCreate
returns. When targeting Build.VERSION_CODES.N
or
above and running on an N or newer platform version
they are restored by Fragment.onCreate
.
onCreate
in class DialogFragment
savedInstanceState
- If the fragment is being re-created from
a previous saved state, this is the state.public Dialog onCreateDialog(Bundle savedInstanceState)
DialogFragment
Fragment.onCreateView(LayoutInflater, ViewGroup, Bundle)
does not need
to be implemented since the AlertDialog takes care of its own content.
This method will be called after DialogFragment.onCreate(Bundle)
and
before Fragment.onCreateView(LayoutInflater, ViewGroup, Bundle)
. The
default implementation simply instantiates and returns a Dialog
class.
Note: DialogFragment own the Dialog.setOnCancelListener
and Dialog.setOnDismissListener
callbacks. You must not set them yourself.
To find out about these events, override DialogFragment.onCancel(DialogInterface)
and DialogFragment.onDismiss(DialogInterface)
.
onCreateDialog
in class DialogFragment
savedInstanceState
- The last saved instance state of the Fragment,
or null if this is a freshly created Fragment.public void onColorSelected(int color)
ColorPickerSwatch.OnColorSelectedListener
onColorSelected
in interface ColorPickerSwatch.OnColorSelectedListener
public void showPaletteView()
public void showProgressBarView()
public void setColors(int[] colors, int selectedColor)
public void setColors(int[] colors)
public void setSelectedColor(int color)
public void setColorContentDescriptions(String[] colorContentDescriptions)
public int[] getColors()
public int getSelectedColor()
public void onSaveInstanceState(Bundle outState)
Fragment
Fragment.onCreate(Bundle)
,
Fragment.onCreateView(LayoutInflater, ViewGroup, Bundle)
, and
Fragment.onActivityCreated(Bundle)
.
This corresponds to Activity.onSaveInstanceState(Bundle)
and most of the discussion there
applies here as well. Note however: this method may be called
at any time before Fragment.onDestroy()
. There are many situations
where a fragment may be mostly torn down (such as when placed on the
back stack with no UI showing), but its state will not be saved until
its owning activity actually needs to save its state.
onSaveInstanceState
in class DialogFragment
outState
- Bundle in which to place your saved state.