Skip to content

Commit 86a3dc2

Browse files
author
Chris Banes
committed
More Code Style Fixes
1 parent 6d204b5 commit 86a3dc2

1 file changed

Lines changed: 18 additions & 29 deletions

File tree

library/src/com/handmark/pulltorefresh/library/PullToRefreshBase.java

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ public void stop() {
9999
private float lastMotionX;
100100
private float lastMotionY;
101101
private boolean isBeingDragged = false;
102-
private boolean isUnableToDrag = false;
103102

104103
private int state = PULL_TO_REFRESH;
105104
private int mode = MODE_PULL_DOWN_TO_REFRESH;
@@ -231,11 +230,11 @@ public final void setRefreshingLabel(String refreshingLabel) {
231230

232231
@Override
233232
public final boolean onTouchEvent(MotionEvent event) {
234-
if (isPullToRefreshEnabled == false) {
233+
if (!isPullToRefreshEnabled) {
235234
return false;
236235
}
237236

238-
if (state == REFRESHING && disableScrollingWhileRefreshing == true) {
237+
if (state == REFRESHING && disableScrollingWhileRefreshing) {
239238
return true;
240239
}
241240

@@ -255,22 +254,21 @@ public final boolean onTouchEvent(MotionEvent event) {
255254
final float yDiff = Math.abs(dy);
256255

257256
if (yDiff > touchSlop && yDiff > xDiff) {
258-
if (dy >= 0.0001f && isReadyForPullDown()) {
259-
if (mode == MODE_PULL_DOWN_TO_REFRESH || mode == MODE_BOTH) {
260-
lastMotionY = y;
261-
isBeingDragged = true;
262-
if (mode == MODE_BOTH) {
263-
currentMode = MODE_PULL_DOWN_TO_REFRESH;
264-
}
257+
if ((mode == MODE_PULL_DOWN_TO_REFRESH || mode == MODE_BOTH) && dy >= 0.0001f
258+
&& isReadyForPullDown()) {
259+
lastMotionY = y;
260+
isBeingDragged = true;
261+
if (mode == MODE_BOTH) {
262+
currentMode = MODE_PULL_DOWN_TO_REFRESH;
265263
}
266-
} else if (dy < -0.0001f && isReadyForPullUp()) {
267-
if (mode == MODE_PULL_UP_TO_REFRESH || mode == MODE_BOTH) {
268-
lastMotionY = y;
269-
isBeingDragged = true;
270-
if (mode == MODE_BOTH) {
271-
currentMode = MODE_PULL_UP_TO_REFRESH;
272-
}
264+
} else if ((mode == MODE_PULL_UP_TO_REFRESH || mode == MODE_BOTH) && dy <= -0.0001f
265+
&& isReadyForPullUp()) {
266+
lastMotionY = y;
267+
isBeingDragged = true;
268+
if (mode == MODE_BOTH) {
269+
currentMode = MODE_PULL_UP_TO_REFRESH;
273270
}
271+
274272
} else {
275273
lastMotionY = initialMotionY = y;
276274
isBeingDragged = false;
@@ -297,7 +295,6 @@ public final boolean onTouchEvent(MotionEvent event) {
297295
case MotionEvent.ACTION_CANCEL: {
298296
if (isBeingDragged) {
299297
isBeingDragged = false;
300-
isUnableToDrag = false;
301298
if (state == RELEASE_TO_REFRESH && null != onRefreshListener) {
302299
setRefreshing();
303300
onRefreshListener.onRefresh();
@@ -311,7 +308,6 @@ public final boolean onTouchEvent(MotionEvent event) {
311308
case MotionEvent.ACTION_UP: {
312309
if (isBeingDragged) {
313310
isBeingDragged = false;
314-
isUnableToDrag = false;
315311
if (state == RELEASE_TO_REFRESH && null != onRefreshListener) {
316312
setRefreshing();
317313
onRefreshListener.onRefresh();
@@ -329,29 +325,25 @@ public final boolean onTouchEvent(MotionEvent event) {
329325
@Override
330326
public final boolean onInterceptTouchEvent(MotionEvent event) {
331327

332-
if (isPullToRefreshEnabled == false) {
328+
if (!isPullToRefreshEnabled) {
333329
return false;
334330
}
335331

336-
if (state == REFRESHING && disableScrollingWhileRefreshing == true) {
332+
if (state == REFRESHING && disableScrollingWhileRefreshing) {
337333
return true;
338334
}
339335

340336
final int action = event.getAction();
341337

342338
if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) {
343339
isBeingDragged = false;
344-
isUnableToDrag = false;
345340
return false;
346341
}
347342

348343
if (action != MotionEvent.ACTION_DOWN) {
349344
if (isBeingDragged == true) {
350345
return true;
351346
}
352-
if (isUnableToDrag == true) {
353-
return false;
354-
}
355347
}
356348

357349
switch (action) {
@@ -374,16 +366,14 @@ && isReadyForPullDown()) {
374366
if (mode == MODE_BOTH) {
375367
currentMode = MODE_PULL_DOWN_TO_REFRESH;
376368
}
377-
} else if ((mode == MODE_PULL_UP_TO_REFRESH || mode == MODE_BOTH) && dy < 0.0001f
369+
} else if ((mode == MODE_PULL_UP_TO_REFRESH || mode == MODE_BOTH) && dy <= 0.0001f
378370
&& isReadyForPullUp()) {
379371
lastMotionY = y;
380372
isBeingDragged = true;
381373
if (mode == MODE_BOTH) {
382374
currentMode = MODE_PULL_UP_TO_REFRESH;
383375
}
384376
}
385-
} else if (xDiff > touchSlop) {
386-
isUnableToDrag = false;
387377
}
388378
}
389379
break;
@@ -447,7 +437,6 @@ protected void addRefreshableView(Context context, T refreshableView) {
447437
protected final void resetHeader() {
448438
state = PULL_TO_REFRESH;
449439
isBeingDragged = false;
450-
isUnableToDrag = false;
451440

452441
if (null != headerLayout) {
453442
headerLayout.reset();

0 commit comments

Comments
 (0)