|
|
@@ -1,15 +1,8 @@
|
|
|
package com.miekir.eden.ui.home.tool;
|
|
|
|
|
|
-import android.text.TextUtils;
|
|
|
-
|
|
|
import com.miekir.eden.base.ApiService;
|
|
|
-import com.miekir.eden.base.CommonApi;
|
|
|
-import com.miekir.eden.bean.BeiUser;
|
|
|
-import com.miekir.eden.bean.IPInfoBean;
|
|
|
import com.miekir.eden.bean.SystemBean;
|
|
|
-import com.miekir.eden.constant.ConstantString;
|
|
|
import com.miekir.eden.constant.EdenError;
|
|
|
-import com.miekir.eden.manager.EdenManager;
|
|
|
import com.miekir.eden.net.RetrofitHelper;
|
|
|
import com.miekir.mvp.presenter.BasePresenter;
|
|
|
import com.miekir.network.core.base.BaseObserver;
|
|
|
@@ -43,21 +36,7 @@ public class SystemPresenter extends BasePresenter<ISystemView> {
|
|
|
@Override
|
|
|
public void onSuccess(int code, SystemBean result) {
|
|
|
if (getView() != null) {
|
|
|
- // 老用户直接登录
|
|
|
- BeiUser userInfo = EdenManager.getInstance().getBeiUser();
|
|
|
- long existTime = System.currentTimeMillis() - userInfo.registerTimeMillis;
|
|
|
- boolean isOldUser = Math.abs(existTime) > (24 * 60 * 60 * 1000);
|
|
|
- if (isOldUser || userInfo.vip) {
|
|
|
- getView().onGetConfigResult(true, EdenError.SUCCESS, result);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (TextUtils.equals(userInfo.email, ConstantString.NAME_ADMIN)) {
|
|
|
- getView().onGetConfigResult(true, EdenError.SUCCESS, result);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- getRegionInfo(result);
|
|
|
+ getView().onGetConfigResult(true, EdenError.SUCCESS, result);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -70,35 +49,6 @@ public class SystemPresenter extends BasePresenter<ISystemView> {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- private void getRegionInfo(SystemBean systemBean) {
|
|
|
- RetrofitHelper.getInstance()
|
|
|
- .getRequestApi(CommonApi.class)
|
|
|
- .getIPInfo()
|
|
|
- .subscribeOn(Schedulers.io())
|
|
|
- .observeOn(AndroidSchedulers.mainThread())
|
|
|
- .subscribe(new BaseObserver<IPInfoBean>() {
|
|
|
- @Override
|
|
|
- public void onSuccess(int code, IPInfoBean ipInfo) {
|
|
|
- if (getView() != null) {
|
|
|
- // 暂不支持中国地区
|
|
|
- if ((ipInfo == null || TextUtils.equals("CN", ipInfo.getCountrycode()))) {
|
|
|
- getView().onGetConfigResult(false, EdenError.REGION_INVALID, null);
|
|
|
- return;
|
|
|
- }
|
|
|
- getView().onGetConfigResult(true, EdenError.SUCCESS, systemBean);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onFailure(int code, Throwable e, String errMsg) {
|
|
|
- if (getView() != null) {
|
|
|
- // 获取区域信息失败
|
|
|
- getView().onGetConfigResult(false, EdenError.REGION_GET_FAILED, null);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
/**
|
|
|
* 设置是否爬虫
|