@@ -91,9 +91,9 @@ public boolean onTouchEvent(MotionEvent event) {
91
91
x = (x < ball .xIni ) ? ball .xIni : x ;
92
92
x = (x > ball .xFin ) ? ball .xFin : x ;
93
93
if (x > ball .xCen ) {
94
- check = true ;
94
+ eventCheck = true ;
95
95
} else {
96
- check = false ;
96
+ eventCheck = false ;
97
97
}
98
98
ViewHelper .setX (ball , x );
99
99
ball .changeBackground ();
@@ -106,7 +106,7 @@ public boolean onTouchEvent(MotionEvent event) {
106
106
press = false ;
107
107
isLastTouch = false ;
108
108
if (eventCheck != check ) {
109
- eventCheck = check ;
109
+ check = eventCheck ;
110
110
if (onCheckListener != null )
111
111
onCheckListener .onCheck (check );
112
112
}
@@ -130,7 +130,7 @@ protected void onDraw(Canvas canvas) {
130
130
Canvas temp = new Canvas (bitmap );
131
131
Paint paint = new Paint ();
132
132
paint .setAntiAlias (true );
133
- paint .setColor ((check ) ? backgroundColor : Color .parseColor ("#B0B0B0" ));
133
+ paint .setColor ((eventCheck ) ? backgroundColor : Color .parseColor ("#B0B0B0" ));
134
134
paint .setStrokeWidth (Utils .dpToPx (2 , getResources ()));
135
135
temp .drawLine (getHeight () / 2 , getHeight () / 2 , getWidth ()
136
136
- getHeight () / 2 , getHeight () / 2 , paint );
@@ -196,6 +196,7 @@ public void setBackgroundColor(int color) {
196
196
public void setChecked (boolean check ) {
197
197
invalidate ();
198
198
this .check = check ;
199
+ this .eventCheck = check ;
199
200
ball .animateCheck ();
200
201
}
201
202
@@ -213,7 +214,7 @@ public Ball(Context context) {
213
214
}
214
215
215
216
public void changeBackground () {
216
- if (check ) {
217
+ if (eventCheck ) {
217
218
setBackgroundResource (R .drawable .background_checkbox );
218
219
LayerDrawable layer = (LayerDrawable ) getBackground ();
219
220
GradientDrawable shape = (GradientDrawable ) layer
@@ -227,7 +228,7 @@ public void changeBackground() {
227
228
public void animateCheck () {
228
229
changeBackground ();
229
230
ObjectAnimator objectAnimator ;
230
- if (check ) {
231
+ if (eventCheck ) {
231
232
objectAnimator = ObjectAnimator .ofFloat (this , "x" , ball .xFin );
232
233
233
234
} else {
0 commit comments