QuadFlask / colorpicker

🍭color picker for android
1.22k stars 219 forks source link

LightnessSlider not updated when setInitialColor() called #71

Open gitdefllo opened 7 years ago

gitdefllo commented 7 years ago

By setting an initial value with setInitialColor(int, boolean), the lightness slider is not updating. It stays at position 0, whereas the alpha slider is updated correctly.

For example, if I do this:

int mColor = -154296; // yellow, full light, full opacity
colorPickerView.setInitialColor(mColor, false);

I got the below result on the left:

screenshot_wheel

However, if I select another color directly in the wheel, the sliders are both updating properly, like the right screenshot above (full light, full opacity).

context: used in fragment with widgets in xml (no dialog)

gitdefllo commented 7 years ago

Weirdly I have to set (again) the lightness color in a runnable as:

colorPickerView.setInitialColor(mColor, false);
// assuming that mBarLightness is the LightnessSlider view
mBarLightness.post(new Runnable() {
    @Override
    public void run() {
        mBarLightness.setColor(mColor);
    }
});

I said again because in the ColorPickerVIew you already did it in onLayout(...) which call setLightnessSlider(...) and set the color into it... that's why it seems weird.

frog1014 commented 7 years ago

I have met same issue