Cleanup in ColorPicker code

This commit is contained in:
Peter Osterlund 2020-03-21 19:38:46 +01:00
parent b35437dd3e
commit 4b9eb9ba6a
4 changed files with 7 additions and 38 deletions

View File

@ -86,12 +86,6 @@ public class ColorPickerDialog
@Override @Override
public void onColorChanged(int color) { public void onColorChanged(int color) {
mNewColor.setColor(color); mNewColor.setColor(color);
/*
if (mListener != null) {
mListener.onColorChanged(color);
}
*/
} }
public void setAlphaSliderVisible(boolean visible) { public void setAlphaSliderVisible(boolean visible) {
@ -101,7 +95,6 @@ public class ColorPickerDialog
/** /**
* Set a OnColorChangedListener to get notified when the color * Set a OnColorChangedListener to get notified when the color
* selected by the user has changed. * selected by the user has changed.
* @param listener
*/ */
public void setOnColorChangedListener(OnColorChangedListener listener) { public void setOnColorChangedListener(OnColorChangedListener listener) {
mListener = listener; mListener = listener;

View File

@ -131,7 +131,6 @@ public class ColorPickerPanelView extends View {
/** /**
* Set the color that should be shown by this view. * Set the color that should be shown by this view.
* @param color
*/ */
public void setColor(int color) { public void setColor(int color) {
mColor = color; mColor = color;
@ -140,7 +139,6 @@ public class ColorPickerPanelView extends View {
/** /**
* Get the color currently show by this view. * Get the color currently show by this view.
* @return
*/ */
public int getColor() { public int getColor() {
return mColor; return mColor;
@ -148,7 +146,6 @@ public class ColorPickerPanelView extends View {
/** /**
* Set the color of the border surrounding the panel. * Set the color of the border surrounding the panel.
* @param color
*/ */
public void setBorderColor(int color) { public void setBorderColor(int color) {
mBorderColor = color; mBorderColor = color;

View File

@ -204,17 +204,11 @@ public class ColorPickerPreference
/** /**
* Toggle Alpha Slider visibility (by default it's disabled) * Toggle Alpha Slider visibility (by default it's disabled)
* @param enable
*/ */
public void setAlphaSliderEnabled(boolean enable) { public void setAlphaSliderEnabled(boolean enable) {
mAlphaSliderEnabled = enable; mAlphaSliderEnabled = enable;
} }
/**
* For custom purposes. Not used by ColorPickerPreference
* @param color
* @author Unknown
*/
private static String convertToARGB(int color) { private static String convertToARGB(int color) {
String alpha = Integer.toHexString(Color.alpha(color)); String alpha = Integer.toHexString(Color.alpha(color));
String red = Integer.toHexString(Color.red(color)); String red = Integer.toHexString(Color.red(color));
@ -240,12 +234,6 @@ public class ColorPickerPreference
return "#" + alpha + red + green + blue; return "#" + alpha + red + green + blue;
} }
/**
* For custom purposes. Not used by ColorPickerPreference
* @param argb
* @throws NumberFormatException
* @author Unknown
*/
private static int convertToColorInt(String argb) throws NumberFormatException { private static int convertToColorInt(String argb) throws NumberFormatException {
if (argb.startsWith("#")) { if (argb.startsWith("#")) {
argb = argb.replace("#", ""); argb = argb.replace("#", "");

View File

@ -317,9 +317,9 @@ public class ColorPickerView extends View {
canvas.drawRect(rect, mAlphaPaint); canvas.drawRect(rect, mAlphaPaint);
if (mAlphaSliderText != null && mAlphaSliderText!= "") { if (mAlphaSliderText != null && !mAlphaSliderText.isEmpty())
canvas.drawText(mAlphaSliderText, rect.centerX(), rect.centerY() + 4 * mDensity, mAlphaTextPaint); canvas.drawText(mAlphaSliderText, rect.centerX(), rect.centerY() + 4 * mDensity,
} mAlphaTextPaint);
float rectWidth = 4 * mDensity / 2; float rectWidth = 4 * mDensity / 2;
@ -677,7 +677,6 @@ public class ColorPickerView extends View {
/** /**
* Set a OnColorChangedListener to get notified when the color * Set a OnColorChangedListener to get notified when the color
* selected by the user has changed. * selected by the user has changed.
* @param listener
*/ */
public void setOnColorChangedListener(OnColorChangedListener listener) { public void setOnColorChangedListener(OnColorChangedListener listener) {
mListener = listener; mListener = listener;
@ -685,7 +684,6 @@ public class ColorPickerView extends View {
/** /**
* Set the color of the border surrounding all panels. * Set the color of the border surrounding all panels.
* @param color
*/ */
public void setBorderColor(int color) { public void setBorderColor(int color) {
mBorderColor = color; mBorderColor = color;
@ -718,8 +716,7 @@ public class ColorPickerView extends View {
/** /**
* Set the color this view should show. * Set the color this view should show.
* @param color The color that should be selected. * @param color The color that should be selected.
* @param callback If you want to get a callback to * @param callback If you want to get a callback to your OnColorChangedListener.
* your OnColorChangedListener.
*/ */
public void setColor(int color, boolean callback) { public void setColor(int color, boolean callback) {
int alpha = Color.alpha(color); int alpha = Color.alpha(color);
@ -757,7 +754,6 @@ public class ColorPickerView extends View {
/** /**
* Set if the user is allowed to adjust the alpha panel. Default is false. * Set if the user is allowed to adjust the alpha panel. Default is false.
* If it is set to false no alpha will be set. * If it is set to false no alpha will be set.
* @param visible
*/ */
public void setAlphaSliderVisible(boolean visible) { public void setAlphaSliderVisible(boolean visible) {
if (mShowAlphaPanel != visible) { if (mShowAlphaPanel != visible) {
@ -788,8 +784,7 @@ public class ColorPickerView extends View {
} }
/** /**
* Set the text that should be shown in the * Set the text that should be shown in the alpha slider. Set to null to disable text.
* alpha slider. Set to null to disable text.
* @param res string resource id. * @param res string resource id.
*/ */
public void setAlphaSliderText(int res) { public void setAlphaSliderText(int res) {
@ -798,8 +793,7 @@ public class ColorPickerView extends View {
} }
/** /**
* Set the text that should be shown in the * Set the text that should be shown in the alpha slider. Set to null to disable text.
* alpha slider. Set to null to disable text.
* @param text Text that should be shown. * @param text Text that should be shown.
*/ */
public void setAlphaSliderText(String text) { public void setAlphaSliderText(String text) {
@ -808,10 +802,7 @@ public class ColorPickerView extends View {
} }
/** /**
* Get the current value of the text * Get the current value of the text that will be shown in the alpha slider.
* that will be shown in the alpha
* slider.
* @return
*/ */
public String getAlphaSliderText() { public String getAlphaSliderText() {
return mAlphaSliderText; return mAlphaSliderText;