colorpicker icon indicating copy to clipboard operation
colorpicker copied to clipboard

Add a listener of slider?

Open frog1014 opened this issue 8 years ago • 5 comments

Is it possible to add the listener for sliders? And we can get the final selected color without one more click on color hue

frog1014 avatar Dec 28 '16 02:12 frog1014

If you use layout xml, you can add listener when value changed like

final AlphaSlider alphaSlider = (AlphaSlider) rootView.findViewById(R.id.v_alpha_slider);
alphaSlider.setOnValueChangedListener(new OnValueChangedListener() {
    @Override
    public void onValueChanged(float value) {
        // do something
    }
})

or if you using version 0.0.13 and dialog builder, you can add color changed listener like this

// 
ColorPickerDialogBuilder.with(context)
.setOnColorChangedListener(new OnColorChangedListener() {
	@Override
	public void onColorChanged(int selectedColor) {
		// Handle on color change
		Log.d("ColorPicker", "onColorChanged: 0x" + Integer.toHexString(selectedColor));
	}
})

QuadFlask avatar Jan 31 '17 07:01 QuadFlask

I got the build error with v0.0.13

C:\work\android\app\build\intermediates\res\merged\debug\values-v24\values-v24.xml Error:(3) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'. Error:(4) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'. Error:(3) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'. Error:(4) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.

my config:

compileSdkVersion 23 buildToolsVersion "23.0.3" defaultConfig { minSdkVersion 21 targetSdkVersion 23

v0.0.12 works fine. May I have your help?

frog1014 avatar Feb 06 '17 02:02 frog1014

I think android buildtool version is too old. Could you update compileSdkVersion 25 and targetSdkVersion 25 in app's build.gradle and update classpath 'com.android.tools.build:gradle:2.3.0-beta3' in project's build.gradle? I think This error relate to compile 'com.android.support:appcompat-v7:25.1.1'.

QuadFlask avatar Feb 06 '17 04:02 QuadFlask

Thanks ! It works! But I have an issue: There is a similar debounce principle in OnColorSelectedListener(), but not in OnColorChangedListener(). Thus it makes too many events when sliding in hue or slider with OnColorChangedListener(). Is there a good way to avoid this?

Thanks much again!

frog1014 avatar Feb 09 '17 08:02 frog1014

#34 should be implement to do that

QuadFlask avatar Feb 09 '17 08:02 QuadFlask