@@ -115,9 +115,11 @@ private void initAttrs(Context context, AttributeSet attrs) {
115
115
} else if (index == R .styleable .TLRLinearLayout_keepFootLoading ) {
116
116
isKeepFootLoading = array .getBoolean (index , isKeepFootLoading );
117
117
} else if (index == R .styleable .TLRLinearLayout_refreshMaxMoveDistance ) {
118
- mRefreshMaxMoveDistance = array .getDimensionPixelOffset (index , mRefreshMaxMoveDistance );
118
+ mRefreshMaxMoveDistance = array .getDimensionPixelOffset (index ,
119
+ mRefreshMaxMoveDistance );
119
120
} else if (index == R .styleable .TLRLinearLayout_loadMaxMoveDistance ) {
120
- mLoadMaxMoveDistance = array .getDimensionPixelOffset (index , mLoadMaxMoveDistance );
121
+ mLoadMaxMoveDistance = array .getDimensionPixelOffset (index ,
122
+ mLoadMaxMoveDistance );
121
123
}
122
124
}
123
125
} finally {
@@ -182,8 +184,6 @@ public void eventUp(float x, float y) {
182
184
183
185
/**
184
186
* eventMove distance must more than {@link ViewConfiguration#getScaledTouchSlop()}
185
- *
186
- * @return
187
187
*/
188
188
public boolean canCalculatorV () {
189
189
if (mDirection == Direction .DOWN || mDirection == Direction .UP ) {
@@ -202,8 +202,6 @@ public void touchMoveLayoutView(int offsetY) {
202
202
203
203
/**
204
204
* call view {@link android.view.View#offsetTopAndBottom(int)} method must cast offset to int
205
- *
206
- * @return
207
205
*/
208
206
private void moveOffsetY (int y ) {
209
207
if (y == 0 ) {
@@ -250,12 +248,14 @@ private int calculateMaxMoveDistance(int y, int totalOffsetY) {
250
248
int tempTotalOffsetY = totalOffsetY + y ;
251
249
252
250
// calculate refresh over max move distance
253
- if (tempTotalOffsetY > 0 && mRefreshMaxMoveDistance > 0 && tempTotalOffsetY > mRefreshMaxMoveDistance ) {
251
+ if (tempTotalOffsetY > 0 && mRefreshMaxMoveDistance > 0
252
+ && tempTotalOffsetY > mRefreshMaxMoveDistance ) {
254
253
y = mRefreshMaxMoveDistance - mTotalOffsetY ;
255
254
}
256
255
257
256
// calculate load over max move distance
258
- if (tempTotalOffsetY < 0 && mLoadMaxMoveDistance > 0 && -tempTotalOffsetY > mLoadMaxMoveDistance ) {
257
+ if (tempTotalOffsetY < 0 && mLoadMaxMoveDistance > 0
258
+ && -tempTotalOffsetY > mLoadMaxMoveDistance ) {
259
259
y = -mLoadMaxMoveDistance - mTotalOffsetY ;
260
260
}
261
261
return y ;
@@ -271,7 +271,8 @@ private void notifyPixOffset(int totalOffsetY, int height, int y) {
271
271
offset = (float ) (Math .round (((float ) totalThresholdY / height ) * 100 )) / 100 ;
272
272
}
273
273
boolean isRefresh = totalOffsetY != 0 ? totalOffsetY > 0 : y < 0 ;
274
- mTLRUiHandler .onOffsetChanged (tLRLinearLayout .getTouchView (), isRefresh , totalOffsetY , totalThresholdY , y , offset );
274
+ mTLRUiHandler .onOffsetChanged (tLRLinearLayout .getTouchView (), isRefresh , totalOffsetY ,
275
+ totalThresholdY , y , offset );
275
276
}
276
277
277
278
private void setDirection (float xDiff , float yDiff ) {
@@ -299,18 +300,21 @@ public void startAutoRefresh() {
299
300
TLRLog .d ("autoRefresh mHeadHeight:" + mHeadHeight );
300
301
mStatusController .setAutoRefreshing (true );
301
302
if (mHeadHeight == 0 ) {
302
- tLRLinearLayout .getViewTreeObserver ().addOnGlobalLayoutListener (new ViewTreeObserver .OnGlobalLayoutListener () {
303
- @ Override
304
- public void onGlobalLayout () {
305
- TLRLog .d ("autoRefresh onGlobalLayout mHeadHeight:" + mHeadHeight );
306
- startAutoRefreshAnimator ();
307
- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .JELLY_BEAN ) {
308
- tLRLinearLayout .getViewTreeObserver ().removeOnGlobalLayoutListener (this );
309
- } else {
310
- tLRLinearLayout .getViewTreeObserver ().removeGlobalOnLayoutListener (this );
311
- }
312
- }
313
- });
303
+ tLRLinearLayout .getViewTreeObserver ().addOnGlobalLayoutListener (
304
+ new ViewTreeObserver .OnGlobalLayoutListener () {
305
+ @ Override
306
+ public void onGlobalLayout () {
307
+ TLRLog .d ("autoRefresh onGlobalLayout mHeadHeight:" + mHeadHeight );
308
+ startAutoRefreshAnimator ();
309
+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .JELLY_BEAN ) {
310
+ tLRLinearLayout .getViewTreeObserver ().removeOnGlobalLayoutListener (
311
+ this );
312
+ } else {
313
+ tLRLinearLayout .getViewTreeObserver ().removeGlobalOnLayoutListener (
314
+ this );
315
+ }
316
+ }
317
+ });
314
318
} else {
315
319
startAutoRefreshAnimator ();
316
320
}
@@ -328,7 +332,8 @@ private void startAutoRefreshAnimator() {
328
332
@ Override
329
333
public void onAnimationEnd (Animator animation ) {
330
334
mAutoAnimator .removeListener (this );
331
- TLRLog .v ("startAutoRefreshAnimator isKeepHeadRefreshing:" + isKeepHeadRefreshing );
335
+ TLRLog .v ("startAutoRefreshAnimator isKeepHeadRefreshing:"
336
+ + isKeepHeadRefreshing );
332
337
if (isKeepHeadRefreshing ) {
333
338
startKeepAnimator ();
334
339
} else {
@@ -379,7 +384,9 @@ private void startResetAnimator() {
379
384
endAllRunningAnimator ();
380
385
int startY = mTotalOffsetY ;
381
386
mResetAnimator = ValueAnimator .ofInt (startY , 0 );
382
- mResetAnimator .setDuration (mCloseAnimDuration );
387
+ long duration = (long ) (mCloseAnimDuration * ((float ) Math .abs (mTotalOffsetY )
388
+ / mHeadHeight ));
389
+ mResetAnimator .setDuration (duration );
383
390
mResetAnimator .setInterpolator (new DecelerateInterpolator ());
384
391
mResetAnimator .addUpdateListener (new AnimUpdateListener (startY ));
385
392
mResetAnimator .start ();
0 commit comments