Skip to content

Commit 5a26e30

Browse files
committed
emergency fix
1 parent 0a9b613 commit 5a26e30

File tree

15 files changed

+77
-52
lines changed

15 files changed

+77
-52
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
.DS_Store
66
/build
77
/captures
8-
8+
gradle*
99

.idea/encodings.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.

.idea/gradle.xml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 0 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README_CN.md

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

288288
## 更新日志
289+
#### v1.05紧急修复版
290+
- 修复底部自动加载更多问题
291+
- 修复FixedHeader遮挡item问题
292+
- RefreshListenerAdapter添加接口onRefreshCanceled()/onLoadmoreCanceled() 回调刷新被取消的状态
293+
- 修复刷新状态重复回调问题
294+
- 添加Apache License 2.0开源协议
295+
289296
#### v1.04
290297
##### 新增功能
291298
- **第二次重构完成**,将核心逻辑拆分为RefreshProcessor、AnimProcessor、OverScrollProcessor、CoProcessor

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
22

33
android {
44
compileSdkVersion 23
5-
buildToolsVersion "23.0.2"
5+
buildToolsVersion '25.0.2'
66
defaultConfig {
77
applicationId 'com.lcodecore.twinklingrefreshlayout'
88
minSdkVersion 14

app/src/main/java/com/lcodecore/twinklingrefreshlayout/WebActivity.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ protected void onCreate(Bundle savedInstanceState) {
2727
refreshLayout.setWaveHeight(240);
2828
refreshLayout.setOverScrollHeight(200);
2929
refreshLayout.setEnableLoadmore(false);
30+
header.setColorSchemeResources(R.color.Blue,R.color.Orange,R.color.Yellow,R.color.Green);
31+
// header.setColorSchemeColors(0xff4674e7,0xff0ba62c);
3032

3133
mWebView = (WebView) findViewById(R.id.webView);
3234
mWebView.loadUrl("https://dribbble.com/shots");
@@ -40,7 +42,7 @@ public void onRefresh(final TwinklingRefreshLayout refreshLayout) {
4042
public void run() {
4143
refreshLayout.finishRefreshing();
4244
}
43-
}, 2000);
45+
}, 4000);
4446
}
4547
});
4648
}

app/src/main/java/com/lcodecore/twinklingrefreshlayout/adapter/ScienceAdapter.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ public void refreshCard() {
6868
cards.add(new Card("globe", "", R.drawable.science2));
6969
cards.add(new Card("lab-flask-leaf", "", R.drawable.science3));
7070
cards.add(new Card("magnet", "", R.drawable.science4));
71-
cards.add(new Card("microscope", "", R.drawable.science5));
72-
cards.add(new Card("moon", "", R.drawable.science6));
73-
cards.add(new Card("telescope", "", R.drawable.science7));
74-
cards.add(new Card("satellite", "", R.drawable.science8));
75-
cards.add(new Card("Newtons-cradle", "", R.drawable.science9));
76-
cards.add(new Card("nuclear-symbol", "", R.drawable.science10));
71+
// cards.add(new Card("microscope", "", R.drawable.science5));
72+
// cards.add(new Card("moon", "", R.drawable.science6));
73+
// cards.add(new Card("telescope", "", R.drawable.science7));
74+
// cards.add(new Card("satellite", "", R.drawable.science8));
75+
// cards.add(new Card("Newtons-cradle", "", R.drawable.science9));
76+
// cards.add(new Card("nuclear-symbol", "", R.drawable.science10));
7777
notifyDataSetChanged();
7878
}
7979

@@ -82,12 +82,12 @@ public void loadMoreCard() {
8282
cards.add(new Card("globe", "", R.drawable.science2));
8383
cards.add(new Card("lab-flask-leaf", "", R.drawable.science3));
8484
cards.add(new Card("magnet", "", R.drawable.science4));
85-
cards.add(new Card("microscope", "", R.drawable.science5));
86-
cards.add(new Card("moon", "", R.drawable.science6));
87-
cards.add(new Card("telescope", "", R.drawable.science7));
88-
cards.add(new Card("satellite", "", R.drawable.science8));
89-
cards.add(new Card("Newtons-cradle", "", R.drawable.science9));
90-
cards.add(new Card("nuclear-symbol", "", R.drawable.science10));
85+
// cards.add(new Card("microscope", "", R.drawable.science5));
86+
// cards.add(new Card("moon", "", R.drawable.science6));
87+
// cards.add(new Card("telescope", "", R.drawable.science7));
88+
// cards.add(new Card("satellite", "", R.drawable.science8));
89+
// cards.add(new Card("Newtons-cradle", "", R.drawable.science9));
90+
// cards.add(new Card("nuclear-symbol", "", R.drawable.science10));
9191
notifyDataSetChanged();
9292
}
9393
}

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
jcenter()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:2.2.2'
8+
classpath 'com.android.tools.build:gradle:2.2.3'
99
classpath 'com.novoda:bintray-release:0.3.4'
1010
// NOTE: Do not place your application dependencies here; they belong
1111
// in the individual module build.gradle files

library/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ publish{
1111

1212
android {
1313
compileSdkVersion 23
14-
buildToolsVersion "23.0.2"
14+
buildToolsVersion '25.0.2'
1515

1616
defaultConfig {
1717
minSdkVersion 14

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ public void onAnimationEnd(Animator animation) {
159159
*/
160160
public void animHeadHideByVy(int vy) {
161161
isAnimHeadHide = true;
162+
cp.onRefreshCanceled();
162163
vy = Math.abs(vy);
163164
if (vy < 5000) vy = 8000;
164165
animLayoutByTime(getVisibleHeadHeight(), 0, 5 * Math.abs(getVisibleHeadHeight() * 1000 / vy), animHeadUpListener, new AnimatorListenerAdapter() {
@@ -179,6 +180,7 @@ public void onAnimationEnd(Animator animation) {
179180
*/
180181
public void animBottomHideByVy(int vy) {
181182
isAnimBottomHide = true;
183+
cp.onLoadmoreCanceled();
182184
vy = Math.abs(vy);
183185
if (vy < 5000) vy = 8000;
184186
animLayoutByTime(getVisibleFootHeight(), 0, 5 * getVisibleFootHeight() * 1000 / vy, animBottomUpListener, new AnimatorListenerAdapter() {
@@ -231,15 +233,15 @@ public void onAnimationEnd(Animator animation) {
231233
*/
232234
public void animOverScrollBottom(float vy, int computeTimes) {
233235
if (cp.isOsBottomLocked()) return;
234-
cp.lockOsBottom();
235-
isAnimOsBottom = true;
236236
cp.setStatePBU();
237237
int oh = (int) Math.abs(vy / computeTimes / 2);
238238
final int overHeight = oh > cp.getOsHeight() ? cp.getOsHeight() : oh;
239239
final int time = overHeight <= 50 ? 115 : (int) (0.3 * overHeight + 100);
240240
if (cp.autoLoadMore()) {
241241
cp.startLoadMore();
242242
} else {
243+
cp.lockOsBottom();
244+
isAnimOsBottom = true;
243245
animLayoutByTime(0, overHeight, time, overScrollBottomUpListener, new AnimatorListenerAdapter() {
244246
@Override
245247
public void onAnimationEnd(Animator animation) {

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,14 @@ public interface PullListener {
4343
void onFinishRefresh();
4444

4545
void onFinishLoadMore();
46+
47+
/**
48+
* 正在刷新时向上滑动屏幕,刷新被取消
49+
*/
50+
void onRefreshCanceled();
51+
52+
/**
53+
* 正在加载更多时向下滑动屏幕,加载更多被取消
54+
*/
55+
void onLoadmoreCanceled();
4656
}

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,14 @@ public void onFinishRefresh() {
3434
public void onFinishLoadMore() {
3535

3636
}
37-
}
37+
38+
@Override
39+
public void onRefreshCanceled() {
40+
41+
}
42+
43+
@Override
44+
public void onLoadmoreCanceled() {
45+
46+
}
47+
}

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

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ protected void onAttachedToWindow() {
126126
layoutParams.addRule(CENTER_VERTICAL);
127127

128128
FrameLayout extraHeadLayout = new FrameLayout(getContext());
129-
extraHeadLayout.setId(View.NO_ID);
129+
extraHeadLayout.setId(R.id.ex_header);
130130
LayoutParams layoutParams2 = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
131131

132132
this.addView(extraHeadLayout, layoutParams2);
@@ -446,6 +446,16 @@ public void onFinishLoadMore() {
446446
if (!isLoadingVisible) return;
447447
mBottomView.onFinish();
448448
}
449+
450+
@Override
451+
public void onRefreshCanceled() {
452+
if (refreshListener != null) refreshListener.onRefreshCanceled();
453+
}
454+
455+
@Override
456+
public void onLoadmoreCanceled() {
457+
if (refreshListener != null) refreshListener.onLoadmoreCanceled();
458+
}
449459
}
450460

451461
public class CoProcessor {
@@ -614,41 +624,34 @@ public void onAddExHead() {
614624
LayoutParams params = (LayoutParams) mChildView.getLayoutParams();
615625
params.addRule(BELOW, mExtraHeadLayout.getId());
616626
mChildView.setLayoutParams(params);
627+
requestLayout();
617628
}
618629

619630

620631
/**
621632
* 主动刷新、加载更多、结束
622633
*/
623634
public void startRefresh() {
624-
setRefreshing(true);
625635
post(new Runnable() {
626636
@Override
627637
public void run() {
628638
setStatePTD();
629639
if (!isPureScrollModeOn && mChildView != null) {
630640
setRefreshing(true);
631641
animProcessor.animHeadToRefresh();
632-
if (pullListener != null) {
633-
pullListener.onRefresh(TwinklingRefreshLayout.this);
634-
}
635642
}
636643
}
637644
});
638645
}
639646

640647
public void startLoadMore() {
641-
setLoadingMore(true);
642648
post(new Runnable() {
643649
@Override
644650
public void run() {
645651
setStatePBU();
646652
if (!isPureScrollModeOn && mChildView != null) {
647653
setLoadingMore(true);
648654
animProcessor.animBottomToLoad();
649-
if (pullListener != null) {
650-
pullListener.onLoadMore(TwinklingRefreshLayout.this);
651-
}
652655
}
653656
}
654657
});
@@ -761,6 +764,14 @@ public void onPullUpReleasing(float offsetY) {
761764
pullListener.onPullUpReleasing(TwinklingRefreshLayout.this, offsetY / mBottomHeight);
762765
}
763766

767+
public void onRefreshCanceled(){
768+
pullListener.onRefreshCanceled();
769+
}
770+
771+
public void onLoadmoreCanceled(){
772+
pullListener.onLoadmoreCanceled();
773+
}
774+
764775
public void setStatePTD() {
765776
state = PULLING_TOP_DOWN;
766777
}

library/src/main/res/values/ids.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<item name="ex_header" type="id"/>
4+
</resources>

0 commit comments

Comments
 (0)