Skip to content

Commit 42ecfe2

Browse files
committed
Fix bugs when enableRefresh,enableLoadmore equals false.
1 parent 48e5ab1 commit 42ecfe2

File tree

4 files changed

+53
-24
lines changed

4 files changed

+53
-24
lines changed

README_CN.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,17 +286,26 @@ startAnim则是在onRefresh/onLoadMore之后才会回调的过程(此处是显
286286
- 带视差效果的Header
287287

288288
## 更新日志
289+
#### v1.06
290+
- 修复触摸监听失效问题
291+
- 修复wrap_content时刷新控件显示在屏幕中央问题
292+
- 去除AVLoadingIndicatorView等依赖,改为BallPulseView
293+
- 优化加载更多完成时出现的闪烁问题
294+
- 修复ValueAnimator以及Demo中WebView带来的内存泄漏问题
295+
- 理论上解决了触摸、点击以及滚动监听失效等问题
296+
- 新增setTargetView()方法,可设置滚动事件的作用对象
297+
- 添加了CoordinateLayout demo(暂未在RefreshLayout中添加相关逻辑)
298+
- 修复三星、酷派手机出现的兼容问题 TODO
299+
- 支持更多的Vew TODO
300+
- 修复BezierLayout偶现的白屏问题 TODO
301+
289302
#### v1.05紧急修复版
290303
- 修复底部自动加载更多问题
291304
- 修复FixedHeader遮挡item问题
292305
- RefreshListenerAdapter添加接口onRefreshCanceled()/onLoadmoreCanceled() 回调刷新被取消的状态
293306
- 修复刷新状态重复回调问题
294307
- 添加Apache License 2.0开源协议
295308

296-
#### v1.05
297-
- 修复触摸监听失效问题
298-
- TODO 修复wrap_content时刷新控件显示在屏幕中央问题
299-
300309
#### v1.04
301310
##### 新增功能
302311
- **第二次重构完成**,将核心逻辑拆分为RefreshProcessor、AnimProcessor、OverScrollProcessor、CoProcessor

TODO_list.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
## 存在的问题
22
1. 三星、酷派手机的兼容问题
3-
2. 依赖太旧的问题->选择去除依赖还是更新依赖 done 以去除依赖
3+
2. 依赖太旧的问题->选择去除依赖还是更新依赖 **done** 已去除依赖
44
3. 自动刷新动画生硬 todo 问题待验证
5-
4. 加载更多闪烁问题 done 做了优化
5+
4. 加载更多闪烁问题 **done** 做了优化
66
5. layout_behavior支持问题 添加了Demo但未完成任何逻辑处理
77
6. 是否要支持ViewPager回弹问题 TODO
8-
7. 是否要支持所有的View TODO 不能滑动NormalView是因为没有焦点的原因(需手动设置)
9-
8. 测试事件监听冲突问题 理论上修改后已经不存在这个问题
10-
9. 内存泄漏问题 -> 解决ValueAnimator潜在的内存泄漏问题;WebView内存泄漏问题;done
8+
7. 是否要支持所有的View TODO 不能滑动NormalView是因为没有焦点的原因(需手动设置),暂时不考虑支持
9+
8. 测试事件监听冲突问题 理论上修改后已经不存在这个问题 **done**
10+
9. 内存泄漏问题 -> 解决ValueAnimator潜在的内存泄漏问题;WebView内存泄漏问题;**done**
1111
10. 仿QQ视差效果
12-
11. 测试加载更多后不添加数据 done
12+
11. 测试加载更多后不添加数据 **done**
1313
12. 考虑是否要给Loadmore添加完成延时
1414
13. FixedHeader问题
1515
14. 多点触摸处理
1616
15. 控制底部下拉后或者顶部上拉后再次进入动画可以保持!
17+
16. Refresh和OverScroll的开关耦合问题
1718

1819
## 新发现的问题
1920
1. beizierlayout主动调用刷新时会一片白
20-
2. BallPulseView引入了内存泄漏 done
21-
3. 新的方案,怎么让scroll更平滑;计算Footer降低与TargetView显示距离是否一致:结论,一致,问题在每次滚动的距离上 done
21+
2. BallPulseView引入了内存泄漏 **done**
22+
3. 新的方案,怎么让scroll更平滑;计算Footer降低与TargetView显示距离是否一致:结论,一致,问题在每次滚动的距离上 **done**
2223
4. requestLayout时提示 **improperly called by android.support.v7.widget.AppCompatTextView**
2324
5. WebView上拉不起作用
24-
25+
6. 修改IBottomView中的参数错误,增加max_head_height,max_bottom_height属性;修改setWaveHeight方法为setMaxHeadHeight,增加setMaxBottomHeight方法 **done**
26+
7. 在最顶部或最底部时fling会多次反弹 **TODO**(解决办法,在最顶端fling时不响应动作)

library/src/main/java/com/lcodecore/tkrefreshlayout/TwinklingRefreshLayout.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public TwinklingRefreshLayout(Context context, AttributeSet attrs, int defStyleA
103103
try {
104104
mMaxHeadHeight = a.getDimensionPixelSize(R.styleable.TwinklingRefreshLayout_tr_max_head_height, (int) DensityUtil.dp2px(context, 120));
105105
mHeadHeight = a.getDimensionPixelSize(R.styleable.TwinklingRefreshLayout_tr_head_height, (int) DensityUtil.dp2px(context, 80));
106-
mMaxBottomHeight = a.getDimensionPixelSize(R.styleable.TwinklingRefreshLayout_tr_max_bottom_height, (int) DensityUtil.dp2px(context, 60));
106+
mMaxBottomHeight = a.getDimensionPixelSize(R.styleable.TwinklingRefreshLayout_tr_max_bottom_height, (int) DensityUtil.dp2px(context, 120));
107107
mBottomHeight = a.getDimensionPixelSize(R.styleable.TwinklingRefreshLayout_tr_bottom_height, (int) DensityUtil.dp2px(context, 60));
108108
mOverScrollHeight = a.getDimensionPixelSize(R.styleable.TwinklingRefreshLayout_tr_overscroll_height, (int) mHeadHeight);
109109
enableLoadmore = a.getBoolean(R.styleable.TwinklingRefreshLayout_tr_enable_loadmore, true);
@@ -540,25 +540,29 @@ private void setPullListener(PullListener pullListener) {
540540
@Override
541541
public void onPullingDown(TwinklingRefreshLayout refreshLayout, float fraction) {
542542
mHeadView.onPullingDown(fraction, mMaxHeadHeight, mHeadHeight);
543+
if (!enableRefresh) return;
543544
if (refreshListener != null) refreshListener.onPullingDown(refreshLayout, fraction);
544545
}
545546

546547
@Override
547548
public void onPullingUp(TwinklingRefreshLayout refreshLayout, float fraction) {
548549
mBottomView.onPullingUp(fraction, mMaxHeadHeight, mHeadHeight);
550+
if (!enableLoadmore) return;
549551
if (refreshListener != null) refreshListener.onPullingUp(refreshLayout, fraction);
550552
}
551553

552554
@Override
553555
public void onPullDownReleasing(TwinklingRefreshLayout refreshLayout, float fraction) {
554556
mHeadView.onPullReleasing(fraction, mMaxHeadHeight, mHeadHeight);
557+
if (!enableRefresh) return;
555558
if (refreshListener != null)
556559
refreshListener.onPullDownReleasing(refreshLayout, fraction);
557560
}
558561

559562
@Override
560563
public void onPullUpReleasing(TwinklingRefreshLayout refreshLayout, float fraction) {
561564
mBottomView.onPullReleasing(fraction, mMaxBottomHeight, mBottomHeight);
565+
if (!enableLoadmore) return;
562566
if (refreshListener != null) refreshListener.onPullUpReleasing(refreshLayout, fraction);
563567
}
564568

@@ -766,18 +770,26 @@ public void finishLoadmore() {
766770
}
767771

768772
//TODO 支持分别设置头部或者顶部允许越界
769-
private boolean enableOverScrollTop = false, enableOverScrollBottom = false;
773+
//private boolean enableOverScrollTop = false, enableOverScrollBottom = false;
770774

771775
public boolean enableOverScroll() {
772776
return enableOverScroll;
773777
}
774778

775779
public boolean allowPullDown() {
776-
return enableRefresh || enableOverScrollTop;
780+
return enableRefresh || enableOverScroll;
777781
}
778782

779783
public boolean allowPullUp() {
780-
return enableLoadmore || enableOverScrollBottom;
784+
return enableLoadmore || enableOverScroll;
785+
}
786+
787+
public boolean enableRefresh(){
788+
return enableRefresh;
789+
}
790+
791+
public boolean enableLoadmore(){
792+
return enableLoadmore;
781793
}
782794

783795
public boolean allowOverScroll() {

library/src/main/java/com/lcodecore/tkrefreshlayout/processor/AnimProcessor.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ public void scrollBottomByMove(float moveY) {
6060
}
6161

6262
public void dealPullDownRelease() {
63-
if (!cp.isPureScrollModeOn() && getVisibleHeadHeight() >= cp.getHeadHeight() - cp.getTouchSlop()) {
63+
if (!cp.isPureScrollModeOn() && cp.enableRefresh() && getVisibleHeadHeight() >= cp.getHeadHeight() - cp.getTouchSlop()) {
6464
animHeadToRefresh();
6565
} else {
6666
animHeadBack();
6767
}
6868
}
6969

7070
public void dealPullUpRelease() {
71-
if (!cp.isPureScrollModeOn() && getVisibleFootHeight() >= cp.getBottomHeight() - cp.getTouchSlop()) {
71+
if (!cp.isPureScrollModeOn() && cp.enableLoadmore() && getVisibleFootHeight() >= cp.getBottomHeight() - cp.getTouchSlop()) {
7272
animBottomToLoad();
7373
} else {
7474
animBottomBack();
@@ -144,12 +144,16 @@ public void animBottomBack() {
144144
animLayoutByTime(getVisibleFootHeight(), 0, new AnimatorUpdateListener() {
145145
@Override
146146
public void onAnimationUpdate(ValueAnimator animation) {
147-
int dy = getVisibleFootHeight() - (int) animation.getAnimatedValue();
148-
//可以让TargetView滚动dy高度,但这样两个方向上滚动感觉画面闪烁,改为dy/2是为了消除闪烁
149-
if (dy > 0) {
150-
if (cp.getTargetView() instanceof RecyclerView)ScrollingUtil.scrollAViewBy(cp.getTargetView(), dy);
151-
else ScrollingUtil.scrollAViewBy(cp.getTargetView(), dy/2);
147+
if (!ScrollingUtil.isViewTopBottom(cp.getTargetView(),cp.getTouchSlop())){
148+
int dy = getVisibleFootHeight() - (int) animation.getAnimatedValue();
149+
//可以让TargetView滚动dy高度,但这样两个方向上滚动感觉画面闪烁,改为dy/2是为了消除闪烁
150+
if (dy > 0) {
151+
if (cp.getTargetView() instanceof RecyclerView)
152+
ScrollingUtil.scrollAViewBy(cp.getTargetView(), dy);
153+
else ScrollingUtil.scrollAViewBy(cp.getTargetView(), dy / 2);
154+
}
152155
}
156+
153157
//decorate the AnimatorUpdateListener
154158
animBottomUpListener.onAnimationUpdate(animation);
155159
}
@@ -205,6 +209,7 @@ public void onAnimationEnd(Animator animation) {
205209

206210
private boolean isAnimOsTop = false;
207211
private boolean isOverScrollTopLocked = false;
212+
208213
/**
209214
* 7.执行顶部越界 To executive cross-border springback at the top.
210215
* 越界高度height ∝ vy/computeTimes,此处采用的模型是 height=A*(vy + B)/computeTimes
@@ -236,6 +241,7 @@ public void onAnimationEnd(Animator animation) {
236241

237242
private boolean isAnimOsBottom = false;
238243
private boolean isOverScrollBottomLocked = false;
244+
239245
/**
240246
* 8.执行底部越界
241247
*

0 commit comments

Comments
 (0)