Fields Summary |
---|
public static final int | SIZE_LARGE |
public static final int | SIZE_SMALL |
protected android.app.AlertDialog | mAlertDialog |
protected static final String | KEY_TITLE_ID |
protected static final String | KEY_COLORS |
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 int | mSelectedColor |
protected int | mColumns |
protected int | mSize |
private ColorPickerPalette | mPalette |
private android.widget.ProgressBar | mProgress |
protected com.android.colorpicker.ColorPickerSwatch.OnColorSelectedListener | mListener |
Methods Summary |
---|
public int[] | getColors()
return mColors;
|
public int | getSelectedColor()
return mSelectedColor;
|
public void | initialize(int titleResId, int[] colors, int selectedColor, int columns, int size)
setArguments(titleResId, columns, size);
setColors(colors, selectedColor);
|
public static com.android.colorpicker.ColorPickerDialog | newInstance(int titleResId, int[] colors, int selectedColor, int columns, int size)
ColorPickerDialog ret = new ColorPickerDialog();
ret.initialize(titleResId, colors, selectedColor, columns, size);
return ret;
|
public void | onColorSelected(int color)
if (mListener != null) {
mListener.onColorSelected(color);
}
if (getTargetFragment() instanceof OnColorSelectedListener) {
final OnColorSelectedListener listener =
(OnColorSelectedListener) getTargetFragment();
listener.onColorSelected(color);
}
if (color != mSelectedColor) {
mSelectedColor = color;
// Redraw palette to show checkmark on newly selected color before dismissing.
mPalette.drawPalette(mColors, mSelectedColor);
}
dismiss();
|
public void | onCreate(android.os.Bundle savedInstanceState)
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mTitleResId = getArguments().getInt(KEY_TITLE_ID);
mColumns = getArguments().getInt(KEY_COLUMNS);
mSize = getArguments().getInt(KEY_SIZE);
}
if (savedInstanceState != null) {
mColors = savedInstanceState.getIntArray(KEY_COLORS);
mSelectedColor = (Integer) savedInstanceState.getSerializable(KEY_SELECTED_COLOR);
}
|
public android.app.Dialog | onCreateDialog(android.os.Bundle savedInstanceState)
final Activity activity = getActivity();
View view = LayoutInflater.from(getActivity()).inflate(R.layout.color_picker_dialog, null);
mProgress = (ProgressBar) view.findViewById(android.R.id.progress);
mPalette = (ColorPickerPalette) view.findViewById(R.id.color_picker);
mPalette.init(mSize, mColumns, this);
if (mColors != null) {
showPaletteView();
}
mAlertDialog = new AlertDialog.Builder(activity)
.setTitle(mTitleResId)
.setView(view)
.create();
return mAlertDialog;
|
public void | onSaveInstanceState(android.os.Bundle outState)
super.onSaveInstanceState(outState);
outState.putIntArray(KEY_COLORS, mColors);
outState.putSerializable(KEY_SELECTED_COLOR, mSelectedColor);
|
private void | refreshPalette()
if (mPalette != null && mColors != null) {
mPalette.drawPalette(mColors, mSelectedColor);
}
|
public void | setArguments(int titleResId, int columns, int size)
Bundle bundle = new Bundle();
bundle.putInt(KEY_TITLE_ID, titleResId);
bundle.putInt(KEY_COLUMNS, columns);
bundle.putInt(KEY_SIZE, size);
setArguments(bundle);
|
public void | setColors(int[] colors, int selectedColor)
if (mColors != colors || mSelectedColor != selectedColor) {
mColors = colors;
mSelectedColor = selectedColor;
refreshPalette();
}
|
public void | setColors(int[] colors)
if (mColors != colors) {
mColors = colors;
refreshPalette();
}
|
public void | setOnColorSelectedListener(com.android.colorpicker.ColorPickerSwatch.OnColorSelectedListener listener)
mListener = listener;
|
public void | setSelectedColor(int color)
if (mSelectedColor != color) {
mSelectedColor = color;
refreshPalette();
}
|
public void | showPaletteView()
if (mProgress != null && mPalette != null) {
mProgress.setVisibility(View.GONE);
refreshPalette();
mPalette.setVisibility(View.VISIBLE);
}
|
public void | showProgressBarView()
if (mProgress != null && mPalette != null) {
mProgress.setVisibility(View.VISIBLE);
mPalette.setVisibility(View.GONE);
}
|