|
|
@@ -1,12 +1,12 @@
|
|
|
-package com.miekir.newmvp.main.presenter;
|
|
|
+package com.miekir.newmvp.main.user.presenter;
|
|
|
|
|
|
import com.miekir.common.utils.LogTool;
|
|
|
import com.miekir.mvp.constant.MvpRepository;
|
|
|
import com.miekir.mvp.presenter.BasePresenter;
|
|
|
-import com.miekir.newmvp.main.model.user.IUserModel;
|
|
|
-import com.miekir.newmvp.main.model.user.UserFileModel;
|
|
|
-import com.miekir.newmvp.main.model.user.UserNetModel;
|
|
|
-import com.miekir.newmvp.main.view.IMainView;
|
|
|
+import com.miekir.newmvp.main.user.model.IUserModel;
|
|
|
+import com.miekir.newmvp.main.user.model.LocalUserModel;
|
|
|
+import com.miekir.newmvp.main.user.model.NetUserModel;
|
|
|
+import com.miekir.newmvp.main.ui.home.IMainView;
|
|
|
|
|
|
import io.reactivex.Observable;
|
|
|
import io.reactivex.ObservableOnSubscribe;
|
|
|
@@ -24,32 +24,33 @@ import io.reactivex.schedulers.Schedulers;
|
|
|
public class UserPresenter extends BasePresenter<IMainView> {
|
|
|
private IUserModel mModel;
|
|
|
|
|
|
+ @Override
|
|
|
+ public void onInit() {
|
|
|
+ mModel = new NetUserModel();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
- * 设置当前仓库
|
|
|
- * @param type 仓库
|
|
|
+ * 设置当前model
|
|
|
+ * @param type model类型
|
|
|
*/
|
|
|
- public void setRepoType(int type) {
|
|
|
+ public UserPresenter with(int type) {
|
|
|
switch (type) {
|
|
|
case MvpRepository.REPO_NET:
|
|
|
- mModel = new UserNetModel();
|
|
|
+ mModel = new NetUserModel();
|
|
|
break;
|
|
|
case MvpRepository.REPO_FILE:
|
|
|
- mModel = new UserFileModel();
|
|
|
+ mModel = new LocalUserModel();
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onInit() {
|
|
|
- mModel = new UserNetModel();
|
|
|
+ return this;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 让具体的Model去执行任务
|
|
|
*/
|
|
|
- public void getUserData() {
|
|
|
+ public void fetchUserData() {
|
|
|
mModel.getData(bean -> {
|
|
|
// 执行完毕,回调
|
|
|
getCallbackView().onMainResult();
|