@@ -1138,8 +1138,8 @@ protected boolean startFlingIfNeed(float flingVelocity) { |
1138 | 1138 | protected boolean interceptAnimatorByAction(int action) { |
1139 | 1139 | if (action == MotionEvent.ACTION_DOWN) { |
1140 | 1140 | if (reboundAnimator != null) { |
1141 | | - if (mState.isFinishing || mState == RefreshState.TwoLevelReleased) { |
1142 | | - return true; |
| 1141 | + if (mState.isFinishing || mState == RefreshState.TwoLevelReleased || mState == RefreshState.RefreshReleased || mState == RefreshState.LoadReleased) { |
| 1142 | + return true;//完成动画和打开动画不能被打断 |
1143 | 1143 | } |
1144 | 1144 | if (mState == RefreshState.PullDownCanceled) { |
1145 | 1145 | mKernel.setState(RefreshState.PullDownToRefresh); |
@@ -1515,7 +1515,6 @@ protected ValueAnimator animSpinner(int endSpinner, int startDelay, Interpolator |
1515 | 1515 | reboundAnimator.setDuration(duration); |
1516 | 1516 | reboundAnimator.setInterpolator(interpolator); |
1517 | 1517 | reboundAnimator.addListener(new AnimatorListenerAdapter() { |
1518 | | - private Animator Animator = reboundAnimator; |
1519 | 1518 | @Override |
1520 | 1519 | public void onAnimationEnd(Animator animation) { |
1521 | 1520 | if (animation != null && animation.getDuration() == 0) { |
@@ -1642,7 +1641,7 @@ protected void moveSpinnerInfinitely(float spinner) { |
1642 | 1641 | * 如果彩蛋影响了您的APP,可以通过以下三种方法关闭 |
1643 | 1642 | * |
1644 | 1643 | * 1.全局关闭(推荐) |
1645 | | - * SmartRefreshLayout.setDefaultRefreshInitializer(new DefaultRefreshInitializer() { |
| 1644 | + * SmartRefreshLayout.setDefaultRefreshInitializer(new DefaultRefreshInitializer() { |
1646 | 1645 | * @Override |
1647 | 1646 | * public void initialize(@NonNull Context context, @NonNull RefreshLayout layout) { |
1648 | 1647 | * layout.getLayout().setTag("close egg"); |
@@ -2433,7 +2432,7 @@ public RefreshLayout setDisableContentWhenLoading(boolean disable) { |
2433 | 2432 | */ |
2434 | 2433 | @Override |
2435 | 2434 | public RefreshLayout setRefreshHeader(@NonNull RefreshHeader header) { |
2436 | | - return setRefreshHeader(header, MATCH_PARENT, WRAP_CONTENT); |
| 2435 | + return setRefreshHeader(header, 0, 0); |
2437 | 2436 | } |
2438 | 2437 |
|
2439 | 2438 | /** |
@@ -2455,16 +2454,26 @@ public RefreshLayout setRefreshHeader(@NonNull RefreshHeader header, int width, |
2455 | 2454 | this.mHeaderBackgroundColor = 0; |
2456 | 2455 | this.mHeaderNeedTouchEventWhenRefreshing = false; |
2457 | 2456 | this.mHeaderHeightStatus = mHeaderHeightStatus.unNotify(); |
| 2457 | + /* |
| 2458 | + * 2019-12-24 修复 DefaultRefreshHeaderCreator 返回 null 时出现空指针 |
| 2459 | + * 不过 DefaultRefreshHeaderCreator 是定义为不允许返回空的 |
| 2460 | + */ |
2458 | 2461 | if (mRefreshHeader != null) { |
2459 | 2462 | /* |
2460 | | - * 2019-12-24 修复 DefaultRefreshHeaderCreator 返回 null 时出现空指针 |
2461 | | - * 不过 DefaultRefreshHeaderCreator 是定义为不允许返回空的 |
| 2463 | + * 2020-3-16 修复 header 中自带 LayoutParams 丢失问题 |
2462 | 2464 | */ |
| 2465 | + width = width == 0 ? MATCH_PARENT : width; |
| 2466 | + height = height == 0 ? WRAP_CONTENT : height; |
| 2467 | + LayoutParams lp = new LayoutParams(width, height); |
| 2468 | + Object olp = header.getView().getLayoutParams(); |
| 2469 | + if (olp instanceof LayoutParams) { |
| 2470 | + lp = ((LayoutParams) olp); |
| 2471 | + } |
2463 | 2472 | if (mRefreshHeader.getSpinnerStyle().front) { |
2464 | 2473 | final ViewGroup thisGroup = this; |
2465 | | - super.addView(mRefreshHeader.getView(), thisGroup.getChildCount(), new LayoutParams(width, height)); |
| 2474 | + super.addView(mRefreshHeader.getView(), thisGroup.getChildCount(), lp); |
2466 | 2475 | } else { |
2467 | | - super.addView(mRefreshHeader.getView(), 0, new LayoutParams(width, height)); |
| 2476 | + super.addView(mRefreshHeader.getView(), 0, lp); |
2468 | 2477 | } |
2469 | 2478 | if (mPrimaryColors != null && mRefreshHeader != null) { |
2470 | 2479 | mRefreshHeader.setPrimaryColors(mPrimaryColors); |
@@ -2481,7 +2490,7 @@ public RefreshLayout setRefreshHeader(@NonNull RefreshHeader header, int width, |
2481 | 2490 | */ |
2482 | 2491 | @Override |
2483 | 2492 | public RefreshLayout setRefreshFooter(@NonNull RefreshFooter footer) { |
2484 | | - return setRefreshFooter(footer, MATCH_PARENT, WRAP_CONTENT); |
| 2493 | + return setRefreshFooter(footer, 0, 0); |
2485 | 2494 | } |
2486 | 2495 |
|
2487 | 2496 | /** |
@@ -2506,16 +2515,26 @@ public RefreshLayout setRefreshFooter(@NonNull RefreshFooter footer, int width, |
2506 | 2515 | this.mFooterNeedTouchEventWhenLoading = false; |
2507 | 2516 | this.mFooterHeightStatus = mFooterHeightStatus.unNotify(); |
2508 | 2517 | this.mEnableLoadMore = !mManualLoadMore || mEnableLoadMore; |
| 2518 | + /* |
| 2519 | + * 2019-12-24 修复 DefaultRefreshFooterCreator 返回 null 时出现空指针 |
| 2520 | + * 不过 DefaultRefreshFooterCreator 是定义为不允许返回空的 |
| 2521 | + */ |
2509 | 2522 | if (mRefreshFooter != null) { |
2510 | 2523 | /* |
2511 | | - * 2019-12-24 修复 DefaultRefreshFooterCreator 返回 null 时出现空指针 |
2512 | | - * 不过 DefaultRefreshFooterCreator 是定义为不允许返回空的 |
| 2524 | + * 2020-3-16 修复 header 中自带 LayoutParams 丢失问题 |
2513 | 2525 | */ |
| 2526 | + width = width == 0 ? MATCH_PARENT : width; |
| 2527 | + height = height == 0 ? WRAP_CONTENT : height; |
| 2528 | + LayoutParams lp = new LayoutParams(width, height); |
| 2529 | + Object olp = footer.getView().getLayoutParams(); |
| 2530 | + if (olp instanceof LayoutParams) { |
| 2531 | + lp = ((LayoutParams) olp); |
| 2532 | + } |
2514 | 2533 | if (mRefreshFooter.getSpinnerStyle().front) { |
2515 | 2534 | final ViewGroup thisGroup = this; |
2516 | | - super.addView(mRefreshFooter.getView(), thisGroup.getChildCount(), new LayoutParams(width, height)); |
| 2535 | + super.addView(mRefreshFooter.getView(), thisGroup.getChildCount(), lp); |
2517 | 2536 | } else { |
2518 | | - super.addView(mRefreshFooter.getView(), 0, new LayoutParams(width, height)); |
| 2537 | + super.addView(mRefreshFooter.getView(), 0, lp); |
2519 | 2538 | } |
2520 | 2539 | if (mPrimaryColors != null && mRefreshFooter != null) { |
2521 | 2540 | mRefreshFooter.setPrimaryColors(mPrimaryColors); |
@@ -2532,7 +2551,7 @@ public RefreshLayout setRefreshFooter(@NonNull RefreshFooter footer, int width, |
2532 | 2551 | */ |
2533 | 2552 | @Override |
2534 | 2553 | public RefreshLayout setRefreshContent(@NonNull View content) { |
2535 | | - return setRefreshContent(content, MATCH_PARENT, MATCH_PARENT); |
| 2554 | + return setRefreshContent(content, 0, 0); |
2536 | 2555 | } |
2537 | 2556 |
|
2538 | 2557 | /** |
@@ -2552,7 +2571,19 @@ public RefreshLayout setRefreshContent(@NonNull View content, int width, int hei |
2552 | 2571 | super.removeView(mRefreshContent.getView()); |
2553 | 2572 | } |
2554 | 2573 | final ViewGroup thisGroup = this; |
2555 | | - super.addView(content, thisGroup.getChildCount(), new LayoutParams(width, height)); |
| 2574 | + |
| 2575 | + /* |
| 2576 | + * 2020-3-16 修复 content 中自带 LayoutParams 丢失问题 |
| 2577 | + */ |
| 2578 | + width = width == 0 ? MATCH_PARENT : width; |
| 2579 | + height = height == 0 ? MATCH_PARENT : height; |
| 2580 | + LayoutParams lp = new LayoutParams(width, height); |
| 2581 | + Object olp = content.getLayoutParams(); |
| 2582 | + if (olp instanceof LayoutParams) { |
| 2583 | + lp = ((LayoutParams) olp); |
| 2584 | + } |
| 2585 | + |
| 2586 | + super.addView(content, thisGroup.getChildCount(), lp); |
2556 | 2587 |
|
2557 | 2588 | mRefreshContent = new RefreshContentWrapper(content); |
2558 | 2589 | if (mAttachedToWindow) { |
|