|
|
@@ -96,7 +96,7 @@ public abstract class BaseListFragment2<T> extends BaseFragment {
|
|
|
refreshLayout.setOnRefreshListener(new OnRefreshListener() {
|
|
|
@Override
|
|
|
public void onRefresh(RefreshLayout refreshlayout) {
|
|
|
- refreshlayout.finishRefresh(1000/*,false*/);//传入false表示刷新失败
|
|
|
+ refreshlayout.finishRefresh(100/*,false*/);//传入false表示刷新失败
|
|
|
refreshData();
|
|
|
}
|
|
|
});
|
|
|
@@ -107,13 +107,14 @@ public abstract class BaseListFragment2<T> extends BaseFragment {
|
|
|
page += 1;
|
|
|
initData();
|
|
|
}else {
|
|
|
- refreshlayout.finishLoadMore(1000/*,false*/);//传入false表示加载失败
|
|
|
+ refreshlayout.finishLoadMore(100/*,false*/);//传入false表示加载失败
|
|
|
setNoMore(true);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
});
|
|
|
view_list.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
|
|
+ boolean isSlidingToLast;
|
|
|
@Override
|
|
|
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
|
|
|
super.onScrollStateChanged(recyclerView, newState);
|
|
|
@@ -136,7 +137,7 @@ public abstract class BaseListFragment2<T> extends BaseFragment {
|
|
|
int totalCount = linearLayoutManager.getItemCount();
|
|
|
Log.e("lastvisi_item_-----", lastVisibleItem+","+totalCount);
|
|
|
|
|
|
- if(newState == RecyclerView.SCROLL_STATE_IDLE && lastVisibleItem == totalCount -1){//滑动到了底部
|
|
|
+ if(newState == RecyclerView.SCROLL_STATE_IDLE && isSlidingToLast){//滑动到了底部
|
|
|
if(ListUtil.size(list) >= per_page*page){
|
|
|
|
|
|
refreshLayout.autoLoadMore();
|
|
|
@@ -145,6 +146,20 @@ public abstract class BaseListFragment2<T> extends BaseFragment {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
|
|
+ super.onScrolled(recyclerView, dx, dy);
|
|
|
+ Log.e("dx-----", dx+","+dy);
|
|
|
+ if (dy > 0) {
|
|
|
+ //大于0表示正在向下滚动
|
|
|
+ isSlidingToLast = true;
|
|
|
+ } else {
|
|
|
+ //小于等于0表示停止或向上滚动
|
|
|
+ isSlidingToLast = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
// bottomLine = ViewUtil.setBottomLine(refreshLayout, getNoMoreCallBack());
|
|
|
@@ -162,6 +177,7 @@ public abstract class BaseListFragment2<T> extends BaseFragment {
|
|
|
}
|
|
|
|
|
|
protected List<T> list = ListUtil.emptyList();
|
|
|
+ protected List<T> listCacheOneList = ListUtil.emptyList();
|
|
|
protected List<T> lastCacheList = ListUtil.emptyList();
|
|
|
//默认先获取缓存
|
|
|
protected boolean isFirstGetACache(){
|
|
|
@@ -189,6 +205,15 @@ public abstract class BaseListFragment2<T> extends BaseFragment {
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
+ getData(urlKey);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取数据
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public void getData(final String urlKey){
|
|
|
+
|
|
|
getApi(SheepApp.getInstance().getNetComponent().getApiService())
|
|
|
.subscribeOn(Schedulers.io())
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
|
@@ -264,9 +289,9 @@ public abstract class BaseListFragment2<T> extends BaseFragment {
|
|
|
}
|
|
|
CommonUtil.getInstance().updateEmptyView(empty_view, list.isEmpty());
|
|
|
if(page == 1){
|
|
|
- refreshLayout.finishRefresh(1000/*,false*/);//传入false表示加载失败
|
|
|
+ refreshLayout.finishRefresh(100/*,false*/);//传入false表示加载失败
|
|
|
} else {
|
|
|
- refreshLayout.finishLoadMore(1000/*,false*/);//传入false表示加载失败
|
|
|
+ refreshLayout.finishLoadMore(100/*,false*/);//传入false表示加载失败
|
|
|
}
|
|
|
view_list.getAdapter().notifyDataSetChanged();
|
|
|
notifyData();
|