Skip to content

Commit

Permalink
Fix #106; add null check
Browse files Browse the repository at this point in the history
  • Loading branch information
QuadFlask committed Nov 7, 2019
1 parent 2f51275 commit 90e47cd
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions library/src/main/java/com/flask/colorpicker/ColorPickerView.java
Original file line number Diff line number Diff line change
Expand Up @@ -374,16 +374,18 @@ public void setLightness(float lightness) {
int lastSelectedColor = getSelectedColor();

this.lightness = lightness;
this.initialColor = Color.HSVToColor(Utils.alphaValueAsInt(this.alpha), currentColorCircle.getHsvWithLightness(lightness));
if (this.colorEdit != null)
this.colorEdit.setText(Utils.getHexString(this.initialColor, this.alphaSlider != null));
if (this.alphaSlider != null && this.initialColor != null)
this.alphaSlider.setColor(this.initialColor);

callOnColorChangedListeners(lastSelectedColor, this.initialColor);

updateColorWheel();
invalidate();
if (currentColorCircle != null) {
this.initialColor = Color.HSVToColor(Utils.alphaValueAsInt(this.alpha), currentColorCircle.getHsvWithLightness(lightness));
if (this.colorEdit != null)
this.colorEdit.setText(Utils.getHexString(this.initialColor, this.alphaSlider != null));
if (this.alphaSlider != null && this.initialColor != null)
this.alphaSlider.setColor(this.initialColor);

callOnColorChangedListeners(lastSelectedColor, this.initialColor);

updateColorWheel();
invalidate();
}
}

public void setColor(int color, boolean updateText) {
Expand Down

0 comments on commit 90e47cd

Please sign in to comment.