@@ -236,14 +236,11 @@ private void onFinishInflated() {
236
236
final int persisted = preferenceManager .getColor (getPreferenceName (), -1 );
237
237
if (palette .getDrawable () instanceof ColorHsvPalette && persisted != -1 ) {
238
238
post (
239
- new Runnable () {
240
- @ Override
241
- public void run () {
242
- try {
243
- selectByHsvColor (persisted );
244
- } catch (IllegalAccessException e ) {
245
- e .printStackTrace ();
246
- }
239
+ () -> {
240
+ try {
241
+ selectByHsvColor (persisted );
242
+ } catch (IllegalAccessException e ) {
243
+ e .printStackTrace ();
247
244
}
248
245
});
249
246
}
@@ -339,12 +336,9 @@ public boolean isHuePalette() {
339
336
private void notifyColorChanged () {
340
337
this .debounceHandler .removeCallbacksAndMessages (null );
341
338
Runnable debounceRunnable =
342
- new Runnable () {
343
- @ Override
344
- public void run () {
345
- fireColorListener (getColor (), true );
346
- notifyToFlagView (selectedPoint );
347
- }
339
+ () -> {
340
+ fireColorListener (getColor (), true );
341
+ notifyToFlagView (selectedPoint );
348
342
};
349
343
this .debounceHandler .postDelayed (debounceRunnable , this .debounceDuration );
350
344
}
@@ -471,19 +465,17 @@ private void notifyToFlagView(Point point) {
471
465
flagView .setRotation (0 );
472
466
flagView .setX (posX );
473
467
flagView .setY (centerPoint .y - flagView .getHeight ());
474
- flagView .onRefresh (getColorEnvelope ());
475
468
} else {
476
469
flagView .setRotation (180 );
477
470
flagView .setX (posX );
478
471
flagView .setY (centerPoint .y + flagView .getHeight () - selector .getHeight () * 0.5f );
479
- flagView .onRefresh (getColorEnvelope ());
480
472
}
481
473
} else {
482
474
flagView .setRotation (0 );
483
475
flagView .setX (posX );
484
476
flagView .setY (centerPoint .y - flagView .getHeight ());
485
- flagView .onRefresh (getColorEnvelope ());
486
477
}
478
+ flagView .onRefresh (getColorEnvelope ());
487
479
if (posX < 0 ) flagView .setX (0 );
488
480
if (posX + flagView .getMeasuredWidth () > getMeasuredWidth ()) {
489
481
flagView .setX (getMeasuredWidth () - flagView .getMeasuredWidth ());
@@ -592,6 +584,7 @@ public void setDebounceDuration(long debounceDuration) {
592
584
private Point getCenterPoint (int x , int y ) {
593
585
return new Point (x - (selector .getMeasuredWidth () / 2 ), y - (selector .getMeasuredHeight () / 2 ));
594
586
}
587
+
595
588
/**
596
589
* gets a selector.
597
590
*
@@ -600,6 +593,7 @@ private Point getCenterPoint(int x, int y) {
600
593
public ImageView getSelector () {
601
594
return this .selector ;
602
595
}
596
+
603
597
/**
604
598
* gets a selector's selected coordinate x.
605
599
*
@@ -681,14 +675,11 @@ public void setInitialColor(@ColorInt final int color) {
681
675
|| (getPreferenceName () != null
682
676
&& preferenceManager .getColor (getPreferenceName (), -1 ) == -1 )) {
683
677
post (
684
- new Runnable () {
685
- @ Override
686
- public void run () {
687
- try {
688
- selectByHsvColor (color );
689
- } catch (IllegalAccessException e ) {
690
- e .printStackTrace ();
691
- }
678
+ () -> {
679
+ try {
680
+ selectByHsvColor (color );
681
+ } catch (IllegalAccessException e ) {
682
+ e .printStackTrace ();
692
683
}
693
684
});
694
685
}
@@ -961,7 +952,7 @@ public void onDestroy() {
961
952
962
953
/** Builder class for create {@link ColorPickerView}. */
963
954
public static class Builder {
964
- private Context context ;
955
+ private final Context context ;
965
956
private ColorPickerViewListener colorPickerViewListener ;
966
957
private int debounceDuration = 0 ;
967
958
private FlagView flagView ;
0 commit comments