public static 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; }
@Override 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(); }
@Override public Dialog onCreateDialog(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 initialize(int titleResId, int[] colors, int selectedColor, int columns, int size) { setArguments(titleResId, columns, size); setColors(colors, selectedColor); }
public void setColors(int[] colors, int selectedColor) { if (mColors != colors || mSelectedColor != selectedColor) { mColors = colors; mSelectedColor = selectedColor; refreshPalette(); } }
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); }
@Override public void onCreate(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 void setColors(int[] colors) { if (mColors != colors) { mColors = colors; refreshPalette(); } }
private void initialize(int titleResId, int[] colors, int selectedColor, int columns, int size) { setArguments(titleResId, columns, size); setColors(colors, selectedColor); }
private 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); }
@Override public void onCreate(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); mColorContentDescriptions = savedInstanceState.getStringArray( KEY_COLOR_CONTENT_DESCRIPTIONS); } }
public void setSelectedColor(int color) { if (mSelectedColor != color) { mSelectedColor = color; refreshPalette(); } }
public static 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; }
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final Activity activity = getActivity(); View view = View.inflate(activity, R.layout.color_picker_dialog, null); mProgress = view.findViewById(android.R.id.progress); mPalette = view.findViewById(R.id.color_picker); mPalette.init(mSize, mColumns, this); if (mColors != null) { showPaletteView(); } return new AlertDialog.Builder(activity) .setTitle(mTitleResId) .setView(view) .create(); }
@Override 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 showPaletteView() { if (mProgress != null && mPalette != null) { mProgress.setVisibility(View.GONE); refreshPalette(); mPalette.setVisibility(View.VISIBLE); } }
private void setColors(int[] colors, int selectedColor) { if (mColors != colors || mSelectedColor != selectedColor) { mColors = colors; mSelectedColor = selectedColor; refreshPalette(); } }
public void setColorContentDescriptions(String[] colorContentDescriptions) { if (mColorContentDescriptions != colorContentDescriptions) { mColorContentDescriptions = colorContentDescriptions; refreshPalette(); } }
public void setSelectedColor(int color) { if (mSelectedColor != color) { mSelectedColor = color; refreshPalette(); } }
public void setColors(int[] colors) { if (mColors != colors) { mColors = colors; refreshPalette(); } }