标签:err bsp lse state creat cte 初始化 ase load
/** * Fragment 加载网络请求 */ public abstract class BaseLoadDataForNetFragment extends Fragment { // 视图是否初始化完成 protected boolean isViewInitiated; // 界面是否可见 protected boolean isVisibleToUser; // 数据是否加载 protected boolean isDataInitiated; @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); WLog.d("onActivityCreated"); isViewInitiated = true; prepareFetchData(); } @Override public void setUserVisibleHint(boolean isVisibleToUser) { super.setUserVisibleHint(isVisibleToUser); WLog.d("setUserVisibleHint:" + isVisibleToUser); this.isVisibleToUser = isVisibleToUser; prepareFetchData(); } private boolean prepareFetchData() { WLog.d("prepareFetchData"); return prepareFetchData(false); } /** * 设置true,可强制刷新界面 * * @param forceUpdate 是否强制刷新界面 * @return */ protected boolean prepareFetchData(boolean forceUpdate) { if (isVisibleToUser && isViewInitiated && (!isDataInitiated || forceUpdate)) { fetchDataForNet(); isDataInitiated = true; return true; } return false; } /** * 刷新数据,网络刷新数据 */ public abstract void fetchDataForNet();
标签:err bsp lse state creat cte 初始化 ase load
原文地址:https://www.cnblogs.com/H-BolinBlog/p/9007340.html