Skip to content

Commit 388b0ef

Browse files
committed
fix bugs of header/footer,status.
1. refreshHeader is invisible after setFloatRefresh(true). 2. setOverScrollTopShow/setOverScrollBottomShow is invalid. 3. add a method to add a default header/footer. 4. add StrictMode and BlockCanary for performance detection.
1 parent 806d750 commit 388b0ef

File tree

13 files changed

+169
-65
lines changed

13 files changed

+169
-65
lines changed

README_CN.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -199,18 +199,15 @@ public interface IHeaderView {
199199

200200
3.在onAttachedToWindow()或者构造函数方法中获取一下需要用到的布局
201201

202+
4. 在onFinish()方法中调用listener.onAnimEnd()。此方法的目的是为了在finish之前可以执行一段动画。
203+
202204
```java
203-
@Override
204-
protected void onAttachedToWindow() {
205-
super.onAttachedToWindow();
206-
207-
if (rootView == null) {
208-
rootView = View.inflate(getContext(), R.layout.view_sinaheader, null);
209-
refreshArrow = (ImageView) rootView.findViewById(R.id.iv_arrow);
210-
refreshTextView = (TextView) rootView.findViewById(R.id.tv);
211-
loadingView = (ImageView) rootView.findViewById(R.id.iv_loading);
212-
addView(rootView);
213-
}
205+
private void init() {
206+
View rootView = View.inflate(getContext(), R.layout.view_sinaheader, null);
207+
refreshArrow = (ImageView) rootView.findViewById(R.id.iv_arrow);
208+
refreshTextView = (TextView) rootView.findViewById(R.id.tv);
209+
loadingView = (ImageView) rootView.findViewById(R.id.iv_loading);
210+
addView(rootView);
214211
}
215212
```
216213

@@ -243,6 +240,11 @@ public interface IHeaderView {
243240
refreshArrow.setVisibility(GONE);
244241
loadingView.setVisibility(VISIBLE);
245242
}
243+
244+
@Override
245+
public void onFinish(OnAnimEndListener listener) {
246+
listener.onAnimEnd();
247+
}
246248
```
247249

248250
5.布局文件
@@ -292,6 +294,10 @@ startAnim则是在onRefresh/onLoadMore之后才会回调的过程(此处是显
292294
- 考虑是否需要控制底部下拉后或者顶部上拉后再次进入动画可以保持
293295

294296
## 更新日志
297+
#### v1.07
298+
- 你们要的设置默认刷新头/脚的方法来啦
299+
- Demo中集成StrictMode、BlockCanary检测ANR
300+
295301
#### v1.06
296302
- 修复触摸监听失效问题
297303
- 修复wrap_content时刷新控件显示在屏幕中央问题

TODO_list.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# v1.07开发计划
2+
- 华为7.0 P9奔溃问题
3+
- setFloatRefresh(true)下拉刷新不可见问题 --View添加顺序的问题 **done**
4+
- 确认item点击失效问题是否解决
5+
- header添加时机的空指针和不显示问题 --去掉post **done**
6+
- 提供设置默认header、footer的方法 **done**
7+
- 频繁设置禁止下拉和加载失效问题?(增加RefreshMode类)
8+
- fixedHeader ontouch事件无响应,需手动设置clickable=true
9+
- setOverScrollTopShow(false)/setOverScrollBottomShow(false)/setOverScrollRefreshShow(false) 设置无效 **done**
10+
11+
12+
13+
# v1.06开发计划
114
## 存在的问题
215
1. 三星、酷派手机的兼容问题
316
2. 依赖太旧的问题->选择去除依赖还是更新依赖 **done** 已去除依赖

app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ dependencies {
3131
compile 'com.android.support:cardview-v7:25.2.0'
3232
compile 'com.jakewharton:butterknife:7.0.1'
3333
compile 'com.squareup.leakcanary:leakcanary-android:1.5'
34+
compile 'com.github.moduth:blockcanary-android:1.2.1'
3435
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.os.Bundle;
44
import android.os.Handler;
5+
import android.support.v4.widget.SwipeRefreshLayout;
56
import android.support.v7.app.AppCompatActivity;
67
import android.support.v7.widget.RecyclerView;
78
import android.support.v7.widget.StaggeredGridLayoutManager;

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ private void setupListView(ListView listView) {
4848
listView.setAdapter(adapter);
4949
adapter.refreshCard();
5050

51+
exHeader.setOnClickListener(new View.OnClickListener() {
52+
@Override
53+
public void onClick(View v) {
54+
ToastUtil.show("fixed header clicked!");
55+
}
56+
});
57+
5158
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
5259
@Override
5360
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
import com.lcodecore.tkrefreshlayout.RefreshListenerAdapter;
88
import com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout;
9+
import com.lcodecore.tkrefreshlayout.footer.LoadingView;
10+
import com.lcodecore.tkrefreshlayout.header.progresslayout.ProgressLayout;
911

1012
public class StoryActivity extends AppCompatActivity {
1113

@@ -14,14 +16,14 @@ protected void onCreate(Bundle savedInstanceState) {
1416
super.onCreate(savedInstanceState);
1517
setContentView(R.layout.activity_story);
1618

17-
TwinklingRefreshLayout refreshLayout = (TwinklingRefreshLayout) findViewById(R.id.refresh);
19+
final TwinklingRefreshLayout refreshLayout = (TwinklingRefreshLayout) findViewById(R.id.refresh);
1820
// ProgressLayout header = new ProgressLayout(this);
1921
// refreshLayout.setHeaderView(header);
2022
// refreshLayout.setFloatRefresh(true);
2123
refreshLayout.setOverScrollRefreshShow(false);
2224
refreshLayout.setOnRefreshListener(new RefreshListenerAdapter() {
2325
@Override
24-
public void onRefresh(final TwinklingRefreshLayout refreshLayout) {
26+
public void onRefresh(TwinklingRefreshLayout refreshLayout1) {
2527
new Handler().postDelayed(new Runnable() {
2628
@Override
2729
public void run() {
@@ -31,7 +33,7 @@ public void run() {
3133
}
3234

3335
@Override
34-
public void onLoadMore(final TwinklingRefreshLayout refreshLayout) {
36+
public void onLoadMore(final TwinklingRefreshLayout refreshLayout1) {
3537
new Handler().postDelayed(new Runnable() {
3638
@Override
3739
public void run() {

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
import android.content.Context;
55
import android.os.StrictMode;
66

7+
import com.github.moduth.blockcanary.BlockCanary;
8+
import com.github.moduth.blockcanary.BlockCanaryContext;
9+
import com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout;
10+
import com.lcodecore.tkrefreshlayout.footer.BallPulseView;
11+
import com.lcodecore.tkrefreshlayout.header.SinaRefreshView;
712
import com.squareup.leakcanary.LeakCanary;
813

914
import static android.os.Build.VERSION.SDK_INT;
@@ -28,8 +33,18 @@ public void onCreate() {
2833
}
2934
enabledStrictMode();
3035
LeakCanary.install(this);
36+
37+
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyDeath().build());
38+
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyDeath().build());
39+
40+
BlockCanary.install(this,new AppBlockCanaryContext()).start();
41+
42+
TwinklingRefreshLayout.setDefaultHeader(SinaRefreshView.class.getName());
43+
TwinklingRefreshLayout.setDefaultFooter(BallPulseView.class.getName());
3144
}
3245

46+
private class AppBlockCanaryContext extends BlockCanaryContext{}
47+
3348
private void enabledStrictMode() {
3449
if (SDK_INT >= GINGERBREAD) {
3550
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() //

app/src/main/res/layout/activity_coordinate.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
android:id="@+id/refresh"
55
android:layout_width="match_parent"
66
android:layout_height="match_parent"
7-
android:addStatesFromChildren="true"
8-
app:layout_behavior="@string/appbar_scrolling_view_behavior">
7+
android:addStatesFromChildren="true">
98

109
<android.support.design.widget.CoordinatorLayout
1110
android:id="@+id/coord_container"
@@ -32,9 +31,9 @@
3231
<ImageView
3332
android:layout_width="match_parent"
3433
android:layout_height="200dp"
35-
android:src="@drawable/photo9"
3634
android:scaleType="centerCrop"
37-
app:layout_collapseParallaxMultiplier="1"/>
35+
android:src="@drawable/photo9"
36+
app:layout_collapseParallaxMultiplier="1" />
3837

3938
<android.support.v7.widget.Toolbar
4039
android:id="@+id/toolbar"
@@ -56,4 +55,5 @@
5655
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
5756

5857
</android.support.design.widget.CoordinatorLayout>
59-
</com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout>
58+
</com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout>
59+

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.3'
8+
classpath 'com.android.tools.build:gradle:2.3.0'
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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ android {
3434
dependencies {
3535
compile fileTree(include: ['*.jar'], dir: 'libs')
3636
compile 'com.android.support:recyclerview-v7:25.2.0'
37+
compile 'com.android.support:support-v4:25.2.0'
3738
}

0 commit comments

Comments
 (0)