|
|
@@ -3,6 +3,8 @@ package com.webrain.dailypay.ui.mvp.model;
|
|
|
import android.content.Context;
|
|
|
import android.text.TextUtils;
|
|
|
|
|
|
+import com.webrain.baselibrary.AppConstant;
|
|
|
+import com.webrain.dailypay.AppCacheManager;
|
|
|
import com.webrain.dailypay.bean.ResumeBean;
|
|
|
import com.webrain.dailypay.bean.api.ApiResumeListBean;
|
|
|
import com.webrain.dailypay.callback.MvpDataCallBack;
|
|
|
@@ -22,6 +24,7 @@ public class ResumeFragmentModel extends BaseModel implements ResumeFragmentCont
|
|
|
private int pageNum = 0;//第一页为1开始 初始为0
|
|
|
private boolean isLoading = false;//是否加载中
|
|
|
private boolean isLastPage;//是否已经最后一页
|
|
|
+ private boolean isInit;//是否初始化过
|
|
|
private String searchKey;
|
|
|
|
|
|
|
|
|
@@ -40,47 +43,48 @@ public class ResumeFragmentModel extends BaseModel implements ResumeFragmentCont
|
|
|
* @param callBack
|
|
|
*/
|
|
|
private void httpPositionList(final MvpDataCallBack<List<ResumeBean>> callBack, boolean isShowDialog, final boolean isInit) {
|
|
|
-// if (AppCacheManager.getInstance().isLogin() && AppCacheManager.getInstance().getLoginModel().getAuthenticationStatus() == AppConstant.APPROVE_SUCCESS) {//身份认证成功后才可
|
|
|
- isLoading = true;
|
|
|
- RetrofitHttpParams params = new RetrofitHttpParams(mContext);
|
|
|
- params.put("pageNo", pageNum + 1);
|
|
|
- params.put("pageSize", 10);
|
|
|
- if (!TextUtils.isEmpty(searchKey))
|
|
|
- params.put("search_key", searchKey);
|
|
|
- new ResumeSubscribe(mContext).requestApplyResume(params.getRequestParams(), new ApiObserver<ApiResumeListBean>(mContext, isShowDialog, false) {
|
|
|
- @Override
|
|
|
- public void onSuccess(ApiResumeListBean data) {
|
|
|
- if (data != null) {
|
|
|
- pageNum = data.getPageNum();
|
|
|
- isLastPage = data.isLastPage();
|
|
|
- if (pageNum == 1 || pageNum == 0) {
|
|
|
- mPositionData.clear();
|
|
|
- }
|
|
|
- if (data.getApplyResume() != null && !data.getApplyResume().isEmpty()) {
|
|
|
- mPositionData.addAll(data.getApplyResume());
|
|
|
+ if (AppCacheManager.getInstance().isLogin() && AppCacheManager.getInstance().getLoginModel().getAuthenticationStatus() == AppConstant.APPROVE_SUCCESS) {//身份认证成功后才可
|
|
|
+ this.isInit = true;
|
|
|
+ isLoading = true;
|
|
|
+ RetrofitHttpParams params = new RetrofitHttpParams(mContext);
|
|
|
+ params.put("pageNo", pageNum + 1);
|
|
|
+ params.put("pageSize", 10);
|
|
|
+ if (!TextUtils.isEmpty(searchKey))
|
|
|
+ params.put("search_key", searchKey);
|
|
|
+ new ResumeSubscribe(mContext).requestApplyResume(params.getRequestParams(), new ApiObserver<ApiResumeListBean>(mContext, isShowDialog, false) {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(ApiResumeListBean data) {
|
|
|
+ if (data != null) {
|
|
|
+ pageNum = data.getPageNum();
|
|
|
+ isLastPage = data.isLastPage();
|
|
|
+ if (pageNum == 1 || pageNum == 0) {
|
|
|
+ mPositionData.clear();
|
|
|
+ }
|
|
|
+ if (data.getApplyResume() != null && !data.getApplyResume().isEmpty()) {
|
|
|
+ mPositionData.addAll(data.getApplyResume());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onError(ApiResumeListBean data, ApiException exception) {
|
|
|
- super.onError(data, exception);
|
|
|
- if (isInit)
|
|
|
- isError = true;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onFinish() {
|
|
|
- callBack.onData(mPositionData);
|
|
|
- if (isError) {
|
|
|
- callBack.onError();
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(ApiResumeListBean data, ApiException exception) {
|
|
|
+ super.onError(data, exception);
|
|
|
+ if (isInit)
|
|
|
+ isError = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFinish() {
|
|
|
+ callBack.onData(mPositionData);
|
|
|
+ if (isError) {
|
|
|
+ callBack.onError();
|
|
|
+ }
|
|
|
+ isError = false;
|
|
|
+ isLoading = false;
|
|
|
}
|
|
|
- isError = false;
|
|
|
- isLoading = false;
|
|
|
- }
|
|
|
|
|
|
- });
|
|
|
-// }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -114,6 +118,16 @@ public class ResumeFragmentModel extends BaseModel implements ResumeFragmentCont
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 是否初始化过
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public boolean isInit() {
|
|
|
+ return isInit;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 刷新页码
|
|
|
*/
|
|
|
@Override
|