|
@@ -9,10 +9,12 @@ import android.support.v7.widget.RecyclerView;
|
|
|
import android.view.LayoutInflater;
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewGroup;
|
|
|
|
|
+import android.widget.TextView;
|
|
|
|
|
|
|
|
import com.jcodecraeer.xrecyclerview.XRecyclerView;
|
|
import com.jcodecraeer.xrecyclerview.XRecyclerView;
|
|
|
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
|
|
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
|
|
|
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
|
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
|
|
|
|
+import com.scwang.smartrefresh.layout.api.ScrollBoundaryDecider;
|
|
|
import com.scwang.smartrefresh.layout.constant.SpinnerStyle;
|
|
import com.scwang.smartrefresh.layout.constant.SpinnerStyle;
|
|
|
import com.scwang.smartrefresh.layout.footer.BallPulseFooter;
|
|
import com.scwang.smartrefresh.layout.footer.BallPulseFooter;
|
|
|
import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
|
|
import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
|
|
@@ -81,6 +83,8 @@ public abstract class BaseListFragment2<T> extends BaseFragment {
|
|
|
protected SmartRefreshLayout refreshLayout;
|
|
protected SmartRefreshLayout refreshLayout;
|
|
|
@BindView(R.id.view_list)
|
|
@BindView(R.id.view_list)
|
|
|
protected RecyclerView view_list;
|
|
protected RecyclerView view_list;
|
|
|
|
|
+ @BindView(R.id.click_tv)
|
|
|
|
|
+ protected TextView click_tv;
|
|
|
|
|
|
|
|
protected BaseMessage lastMessage;//最后一个网络获取的结果
|
|
protected BaseMessage lastMessage;//最后一个网络获取的结果
|
|
|
protected int page = 1;//页数
|
|
protected int page = 1;//页数
|
|
@@ -138,8 +142,27 @@ public abstract class BaseListFragment2<T> extends BaseFragment {
|
|
|
},1000);
|
|
},1000);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
+ click_tv.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onClick(View v) {
|
|
|
|
|
+
|
|
|
|
|
+ refreshLayout.autoLoadMore();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+// refreshLayout.setScrollBoundaryDecider(new ScrollBoundaryDecider() {
|
|
|
|
|
+// @Override
|
|
|
|
|
+// public boolean canRefresh(View view) {
|
|
|
|
|
+// return false;
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// @Override
|
|
|
|
|
+// public boolean canLoadMore(View view) {
|
|
|
|
|
+// refreshLayout.autoLoadMore();
|
|
|
|
|
+// return true;
|
|
|
|
|
+// }
|
|
|
|
|
+// });
|
|
|
|
|
|
|
|
-// bottomLine = ViewUtil.setBottomLine(recyclerView, getNoMoreCallBack());
|
|
|
|
|
|
|
+// bottomLine = ViewUtil.setBottomLine(refreshLayout, getNoMoreCallBack());
|
|
|
view_list.setLayoutManager(new LinearLayoutManager(SheepApp.getInstance()));
|
|
view_list.setLayoutManager(new LinearLayoutManager(SheepApp.getInstance()));
|
|
|
view_list.setAdapter(getAdapter());
|
|
view_list.setAdapter(getAdapter());
|
|
|
|
|
|
|
@@ -238,6 +261,14 @@ public abstract class BaseListFragment2<T> extends BaseFragment {
|
|
|
}
|
|
}
|
|
|
public void notifyDataSetChanged(){
|
|
public void notifyDataSetChanged(){
|
|
|
loadMore = false;
|
|
loadMore = false;
|
|
|
|
|
+ if(list.isEmpty()){
|
|
|
|
|
+ refreshLayout.setVisibility(View.GONE);
|
|
|
|
|
+ click_tv.setVisibility(View.GONE);
|
|
|
|
|
+ }else {
|
|
|
|
|
+
|
|
|
|
|
+ refreshLayout.setVisibility(View.VISIBLE);
|
|
|
|
|
+ click_tv.setVisibility(View.VISIBLE);
|
|
|
|
|
+ }
|
|
|
CommonUtil.getInstance().updateEmptyView(empty_view, list.isEmpty());
|
|
CommonUtil.getInstance().updateEmptyView(empty_view, list.isEmpty());
|
|
|
if(page == 1){
|
|
if(page == 1){
|
|
|
refreshLayout.finishLoadMore(2000/*,false*/);//传入false表示加载失败
|
|
refreshLayout.finishLoadMore(2000/*,false*/);//传入false表示加载失败
|