Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
yanyiqun001 committed Dec 11, 2017
1 parent c17e58e commit 2168729
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 28 deletions.
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ module下添加依赖

```
dependencies{
compile 'com.github.yanyiqun001.goRefresh:refreshlayout:0.6.1'
compile 'com.github.yanyiqun001.goRefresh:refreshlayout_lottie:0.6.1' (需要使用lottie动画时添加)
compile 'com.github.yanyiqun001.goRefresh:refreshlayout:0.6.2'
compile 'com.github.yanyiqun001.goRefresh:refreshlayout_lottie:0.6.2' (需要使用lottie动画时添加)
}
```

Expand Down Expand Up @@ -209,28 +209,34 @@ dependencies{
```
public class CustomFooter implements IFooterView {
private LayoutInflater inflater;
private View mLoadingView;
private View mErrorview;
private View mFinishView;
public CustomFooter(Context context) {
inflater=LayoutInflater.from(context);
mErrorview=inflater.inflate(R.layout.footerview_error,null);
mLoadingView=inflater.inflate(R.layout.lottle_loading_animation_footer,null);
mFinishView=inflater.inflate(R.layout.footer_finish,null);
}
@Override
public View getLoadingView() {
return inflater.inflate(R.layout.lottle_loading_animation_footer,null);
return mLoadingView;
}
@Override
public View getFinishView() {
return inflater.inflate(R.layout.footer_finish,null);
return mFinishView;
}
@Override
public View getFailureView() {
return inflater.inflate(R.layout.footer_error,null);
return mErrorview;
}
@Override
public int getRetryId() {
return R.id.tips;
return R.id.tv_retry;
}
}
```
Expand Down
14 changes: 10 additions & 4 deletions app/src/main/java/com/refreshDemo/CustomFooter.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,34 @@

public class CustomFooter implements IFooterView {
private LayoutInflater inflater;
private View mLoadingView;
private View mErrorview;
private View mFinishView;
public CustomFooter(Context context) {
inflater=LayoutInflater.from(context);
mErrorview=inflater.inflate(R.layout.footerview_error,null);
mLoadingView=inflater.inflate(R.layout.lottle_loading_animation_footer,null);
mFinishView=inflater.inflate(R.layout.footer_finish,null);
}

@Override
public View getLoadingView() {
return inflater.inflate(R.layout.lottle_loading_animation_footer,null);
return mLoadingView;
}

@Override
public View getFinishView() {
return inflater.inflate(R.layout.footer_finish,null);
return mFinishView;
}

@Override
public View getFailureView() {
return inflater.inflate(R.layout.footer_error,null);
return mErrorview;
}

@Override
public int getRetryId() {
return R.id.tips;
return R.id.tv_retry;
}


Expand Down
6 changes: 1 addition & 5 deletions app/src/main/java/com/refreshDemo/ListViewActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,10 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
if (list.size() >= 10) {
goRefreshLayout.setHasFooter(true);
}
listView.setAdapter(adapter);

CustomFooter customFooter = new CustomFooter(this);
goRefreshLayout.setFooterView(customFooter);

goRefreshLayout.setLoadingView(R.layout.footer_loading);
goRefreshLayout.setErrorViewWithRetry(R.layout.footerview_error, R.id.tips);

//下拉刷新
goRefreshLayout.setOnRefreshListener( new RefreshListener() {
@Override
Expand Down Expand Up @@ -113,7 +109,7 @@ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCoun
// Toast.makeText(ListViewActivity.this, i + "", Toast.LENGTH_SHORT).show();
// }
// });

listView.setAdapter(adapter);

}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/footerview_error.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
android:layout_height="match_parent"
>
<TextView
android:id="@+id/tips"
android:id="@+id/tv_retry"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_gravity="center"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<resources>
<string name="app_name">GoRefresh</string>

<string name="retry"><u>加载失败,请重试</u></string>
<string name="retry"><u>加载失败,点击重试</u></string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ private void init(Context context, AttributeSet attrs) {
duration_autotoRefreshHeight = typedArray.getInt(R.styleable.GoRefreshLayout_duration_autotoRefreshHeight, duration_autotoRefreshHeight);
typedArray.recycle();
mHeader = new DefaultHeaderLayout(context);
mFooter = new DefaultFooterView(context);

}


Expand Down
12 changes: 8 additions & 4 deletions refreshlayout/src/main/java/com/GoRefresh/LoadMoreHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public void setHasFooter(boolean hasFooter, View contentView, IFooterView defaul
if (hasFooter) {
if (mFooter == null) {
setFooterView(defaultFooterView, contentView);
}else{
setFooterView();
}
} else {
removeFooterView((ListView) contentView);
Expand Down Expand Up @@ -127,9 +129,11 @@ public void finishLoadMoreWithError(final View contentView) {
}
} else if (contentView instanceof ListView) {
if (mFooterStatus != ERROR) {
View view = mFooter.getFailureView().findViewById(mFooter.getRetryId());
if (view != null) {
view.setOnClickListener(new View.OnClickListener() {
switchFooterView((ListView) contentView, ERROR);
View errorView = mFooter.getFailureView();
View retryView= errorView.findViewById(mFooter.getRetryId());
if (retryView != null) {
retryView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (listener != null) {
Expand All @@ -141,7 +145,7 @@ public void onClick(View v) {
}
});
}
switchFooterView((ListView) contentView, ERROR);

}
}
}
Expand Down
2 changes: 1 addition & 1 deletion refreshlayout/src/main/res/layout/footer_error.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
android:layout_height="40dp"
android:layout_gravity="center"
android:gravity="center"
android:text="加载失败请重试"
android:text="@string/string_gorefresh_retry"
android:textColor="@android:color/holo_red_dark" />
</LinearLayout>
2 changes: 1 addition & 1 deletion refreshlayout/src/main/res/layout/footer_finish.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
android:gravity="center">
<TextView
android:gravity="center"
android:text="没有更多数据了"
android:text="@string/string_gorefresh_nomore"
android:id="@+id/tips"
android:layout_width="wrap_content"
android:layout_height="40dp" />
Expand Down
4 changes: 2 additions & 2 deletions refreshlayout/src/main/res/layout/footer_loading.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_height="wrap_content"
android:gravity="center">
<com.GoRefresh.weight.RingProgressBar
android:id="@+id/progressbar"
Expand All @@ -17,6 +17,6 @@
android:textColor="#9e9e9e"
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="40dp"
android:text="@string/loadingtext"/>
</LinearLayout>
2 changes: 1 addition & 1 deletion refreshlayout/src/main/res/layout/headerview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:gravity="center"
android:text="下拉刷新"
android:text="@string/pulltorefresh"
android:textColor="#9e9e9e" />
</LinearLayout>
2 changes: 2 additions & 0 deletions refreshlayout/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
<string name="release">释放刷新</string>
<string name="pulltorefresh">下拉刷新</string>
<string name="loading">正在加载</string>
<string name="string_gorefresh_retry">加载失败,点击重试</string>
<string name="string_gorefresh_nomore">没有更多数据了</string>
</resources>

0 comments on commit 2168729

Please sign in to comment.