Skip to content

Commit 00c3894

Browse files
committed
Apply flag_isFlipAble attribute by the defined styles
1 parent e03f373 commit 00c3894

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

colorpickerview/src/main/java/com/skydoves/colorpickerview/ColorPickerView.java

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ public class ColorPickerView extends FrameLayout implements LifecycleObserver {
9292
@FloatRange(from = 0.0, to = 1.0)
9393
private float flag_alpha = 1.0f;
9494

95+
private boolean flag_isFlipAble = true;
96+
9597
@Px private int selectorSize = 0;
9698

9799
private boolean VISIBLE_FLAG = false;
@@ -146,6 +148,10 @@ private void getAttrs(AttributeSet attrs) {
146148
if (a.hasValue(R.styleable.ColorPickerView_flag_alpha)) {
147149
this.flag_alpha = a.getFloat(R.styleable.ColorPickerView_flag_alpha, flag_alpha);
148150
}
151+
if (a.hasValue(R.styleable.ColorPickerView_flag_isFlipAble)) {
152+
this.flag_isFlipAble =
153+
a.getBoolean(R.styleable.ColorPickerView_flag_isFlipAble, flag_isFlipAble);
154+
}
149155
if (a.hasValue(R.styleable.ColorPickerView_actionMode)) {
150156
int actionMode = a.getInteger(R.styleable.ColorPickerView_actionMode, 0);
151157
if (actionMode == 0) {
@@ -260,8 +266,8 @@ protected void onCreateByBuilder(Builder builder) {
260266

261267
this.paletteDrawable = builder.paletteDrawable;
262268
this.selectorDrawable = builder.selectorDrawable;
263-
this.selector_alpha = builder.alpha_selector;
264-
this.flag_alpha = builder.alpha_flag;
269+
this.selector_alpha = builder.selector_alpha;
270+
this.flag_alpha = builder.flag_alpha;
265271
this.selectorSize = builder.selectorSize;
266272
this.debounceDuration = builder.debounceDuration;
267273
onCreate();
@@ -549,6 +555,7 @@ public void setFlagView(@NonNull FlagView flagView) {
549555
addView(flagView);
550556
this.flagView = flagView;
551557
flagView.setAlpha(flag_alpha);
558+
flagView.setFlipAble(flag_isFlipAble);
552559
}
553560

554561
/**
@@ -959,10 +966,12 @@ public static class Builder {
959966
@ColorInt private int initialColor = 0;
960967

961968
@FloatRange(from = 0.0, to = 1.0)
962-
private float alpha_selector = 1.0f;
969+
private float selector_alpha = 1.0f;
963970

964971
@FloatRange(from = 0.0, to = 1.0)
965-
private float alpha_flag = 1.0f;
972+
private float flag_alpha = 1.0f;
973+
974+
private boolean flag_isFlipAble = false;
966975

967976
@Dp private int selectorSize = 0;
968977
@Dp private int width = LayoutParams.MATCH_PARENT;
@@ -1015,12 +1024,17 @@ public Builder setActionMode(ActionMode actionMode) {
10151024
}
10161025

10171026
public Builder setSelectorAlpha(@FloatRange(from = 0.0, to = 1.0) float alpha) {
1018-
this.alpha_selector = alpha;
1027+
this.selector_alpha = alpha;
10191028
return this;
10201029
}
10211030

10221031
public Builder setFlagAlpha(@FloatRange(from = 0.0, to = 1.0) float alpha) {
1023-
this.alpha_flag = alpha;
1032+
this.flag_alpha = alpha;
1033+
return this;
1034+
}
1035+
1036+
public Builder setFlagIsFlipAble(boolean isFlipAble) {
1037+
this.flag_isFlipAble = isFlipAble;
10241038
return this;
10251039
}
10261040

0 commit comments

Comments
 (0)