|
@@ -12,6 +12,7 @@ import android.text.method.LinkMovementMethod;
|
|
import android.text.style.ClickableSpan;
|
|
import android.text.style.ClickableSpan;
|
|
import android.view.View;
|
|
import android.view.View;
|
|
import android.widget.FrameLayout;
|
|
import android.widget.FrameLayout;
|
|
|
|
+import android.widget.ImageView;
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
import android.widget.Toast;
|
|
import android.widget.Toast;
|
|
|
|
|
|
@@ -21,13 +22,17 @@ import com.edufound.reader.apiserver.UserApiServerImpl;
|
|
import com.edufound.reader.base.BasePresenter;
|
|
import com.edufound.reader.base.BasePresenter;
|
|
import com.edufound.reader.bean.ChannelCodeEnum;
|
|
import com.edufound.reader.bean.ChannelCodeEnum;
|
|
import com.edufound.reader.bean.HttpResultBean;
|
|
import com.edufound.reader.bean.HttpResultBean;
|
|
|
|
+import com.edufound.reader.bean.SignBean;
|
|
import com.edufound.reader.bean.UserBean;
|
|
import com.edufound.reader.bean.UserBean;
|
|
import com.edufound.reader.contract.LoginAlertContract;
|
|
import com.edufound.reader.contract.LoginAlertContract;
|
|
|
|
+import com.edufound.reader.cusview.CusToast;
|
|
import com.edufound.reader.interfaces.EfunboxInterfaces;
|
|
import com.edufound.reader.interfaces.EfunboxInterfaces;
|
|
|
|
+import com.edufound.reader.miutil.MiSoundSDKUtil;
|
|
import com.edufound.reader.model.LoginAlertModel;
|
|
import com.edufound.reader.model.LoginAlertModel;
|
|
import com.edufound.reader.util.Consts;
|
|
import com.edufound.reader.util.Consts;
|
|
import com.edufound.reader.util.DeviceUuidFactory;
|
|
import com.edufound.reader.util.DeviceUuidFactory;
|
|
import com.edufound.reader.util.EfunboxUtil;
|
|
import com.edufound.reader.util.EfunboxUtil;
|
|
|
|
+import com.edufound.reader.util.GlideUtils;
|
|
import com.edufound.reader.util.MMKVEncodeKey;
|
|
import com.edufound.reader.util.MMKVEncodeKey;
|
|
import com.edufound.reader.util.MMKVUtil;
|
|
import com.edufound.reader.util.MMKVUtil;
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
@@ -37,6 +42,8 @@ import com.okhttplib.HttpInfo;
|
|
import com.okhttplib.callback.Callback;
|
|
import com.okhttplib.callback.Callback;
|
|
import com.orhanobut.logger.Logger;
|
|
import com.orhanobut.logger.Logger;
|
|
|
|
|
|
|
|
+import org.json.JSONObject;
|
|
|
|
+
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
@@ -57,10 +64,13 @@ public class LoginAlertPresenter extends BasePresenter<LoginAlertContract.View>
|
|
String mServiceText = "点击登录表示您已阅读并同意《用户隐私政策》和《服务协议》。";
|
|
String mServiceText = "点击登录表示您已阅读并同意《用户隐私政策》和《服务协议》。";
|
|
int getVCode;
|
|
int getVCode;
|
|
int mVCodeResCount = 60;
|
|
int mVCodeResCount = 60;
|
|
|
|
+ boolean loginSuccess = false;
|
|
|
|
+ OrderApiServerImpl mOrderApi;
|
|
|
|
|
|
public LoginAlertPresenter() {
|
|
public LoginAlertPresenter() {
|
|
mModel = new LoginAlertModel();
|
|
mModel = new LoginAlertModel();
|
|
mUserApi = new UserApiServerImpl();
|
|
mUserApi = new UserApiServerImpl();
|
|
|
|
+ mOrderApi = new OrderApiServerImpl();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -75,9 +85,7 @@ public class LoginAlertPresenter extends BasePresenter<LoginAlertContract.View>
|
|
style.setSpan(new ClickableSpan() {
|
|
style.setSpan(new ClickableSpan() {
|
|
@Override
|
|
@Override
|
|
public void onClick(@NonNull View widget) {
|
|
public void onClick(@NonNull View widget) {
|
|
- setClickListener(widget, o -> {
|
|
|
|
- lookPrivacy(finalI);
|
|
|
|
- });
|
|
|
|
|
|
+ lookPrivacy(finalI);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -138,9 +146,14 @@ public class LoginAlertPresenter extends BasePresenter<LoginAlertContract.View>
|
|
Toast.makeText(mView.getActivity(), "请输入验证码", Toast.LENGTH_SHORT).show();
|
|
Toast.makeText(mView.getActivity(), "请输入验证码", Toast.LENGTH_SHORT).show();
|
|
return;
|
|
return;
|
|
} else {
|
|
} else {
|
|
- if (!mView.getCheckBox().isChecked()) {
|
|
|
|
- Toast.makeText(mView.getActivity(), "请勾选用户隐私政策和服务协议", Toast.LENGTH_SHORT).show();
|
|
|
|
- return;
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (mView.getActivity().getLocalClassName().contains("LoginAlertActivity")) {
|
|
|
|
+
|
|
|
|
+ if (!mView.getCheckBox().isChecked()) {
|
|
|
|
+ Toast.makeText(mView.getActivity(), "请勾选用户隐私政策和服务协议", Toast.LENGTH_SHORT).show();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
// if (Integer.valueOf(inputVCode) == getVCode || Integer.valueOf(inputVCode) == 9999) {
|
|
// if (Integer.valueOf(inputVCode) == getVCode || Integer.valueOf(inputVCode) == 9999) {
|
|
//输入的和返回的是一样的
|
|
//输入的和返回的是一样的
|
|
@@ -161,8 +174,7 @@ public class LoginAlertPresenter extends BasePresenter<LoginAlertContract.View>
|
|
mUserApi.registerMobileByVCode(mView.getActivity(), new Gson().toJson(params), new Callback() {
|
|
mUserApi.registerMobileByVCode(mView.getActivity(), new Gson().toJson(params), new Callback() {
|
|
@Override
|
|
@Override
|
|
public void onSuccess(HttpInfo info) throws IOException {
|
|
public void onSuccess(HttpInfo info) throws IOException {
|
|
-// Logger.e("注册成功:" + info.getRetDetail());
|
|
|
|
- Toast.makeText(mView.getActivity(), "登录成功", Toast.LENGTH_SHORT).show();
|
|
|
|
|
|
+ CusToast.getInstance(mView.getActivity()).show("登录成功", 3000);
|
|
HttpResultBean<UserBean> bean = info.getRetDetail(new TypeToken<HttpResultBean<UserBean>>() {
|
|
HttpResultBean<UserBean> bean = info.getRetDetail(new TypeToken<HttpResultBean<UserBean>>() {
|
|
}.getType());
|
|
}.getType());
|
|
Consts.setUID(bean.getData().getUid());
|
|
Consts.setUID(bean.getData().getUid());
|
|
@@ -208,9 +220,37 @@ public class LoginAlertPresenter extends BasePresenter<LoginAlertContract.View>
|
|
@Override
|
|
@Override
|
|
public void activityDestory() {
|
|
public void activityDestory() {
|
|
mLoginAlertHandler.removeMessages(LoginAlertModel.CHANGE_VCODE_TEXT);
|
|
mLoginAlertHandler.removeMessages(LoginAlertModel.CHANGE_VCODE_TEXT);
|
|
|
|
+ mLoginAlertHandler.removeMessages(0x1313);
|
|
mLoginAlertHandler = null;
|
|
mLoginAlertHandler = null;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void showLoginQRCode(ImageView img) {
|
|
|
|
+ mUserApi.getLoginQRCode(new Callback() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onSuccess(HttpInfo info) throws IOException {
|
|
|
|
+ Logger.e("info:" + info.getRetDetail());
|
|
|
|
+ HttpResultBean<String> bean = info.getRetDetail(new TypeToken<HttpResultBean<String>>() {
|
|
|
|
+ }.getType());
|
|
|
|
+ Logger.e("bean.getData:" + bean.getData());
|
|
|
|
+ if (bean.getCode().equals("200") && bean.getSuccess()) {
|
|
|
|
+ Logger.e("加载二维码");
|
|
|
|
+ GlideUtils.loadImageSizeKipMemoryCache(mView.getActivity(), bean.getData(), img);
|
|
|
|
+ loginSuccess = false;
|
|
|
|
+ mLoginAlertHandler.sendEmptyMessageDelayed(0x1313, 1000);
|
|
|
|
+ } else {
|
|
|
|
+ Logger.e("加载二维码失败");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onFailure(HttpInfo info) throws IOException {
|
|
|
|
+ Logger.e("获取登录二维码失败");
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
Handler mLoginAlertHandler = new Handler(new Handler.Callback() {
|
|
Handler mLoginAlertHandler = new Handler(new Handler.Callback() {
|
|
@Override
|
|
@Override
|
|
public boolean handleMessage(@androidx.annotation.NonNull Message message) {
|
|
public boolean handleMessage(@androidx.annotation.NonNull Message message) {
|
|
@@ -229,6 +269,107 @@ public class LoginAlertPresenter extends BasePresenter<LoginAlertContract.View>
|
|
}
|
|
}
|
|
|
|
|
|
break;
|
|
break;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ case 0x1313:
|
|
|
|
+ if (loginSuccess) {
|
|
|
|
+ mLoginAlertHandler.removeMessages(0x1313);
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ mUserApi.isLogin(mView.getActivity(), DeviceUuidFactory.getUuid(), new Callback() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onSuccess(HttpInfo info) throws IOException {
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ JSONObject object = new JSONObject(info.getRetDetail());
|
|
|
|
+ if (object.getString("code").equals("200") || object.getInt("code") == 200) {
|
|
|
|
+ //200算成功
|
|
|
|
+ mLoginAlertHandler.removeMessages(0x1313);
|
|
|
|
+ loginSuccess = true;
|
|
|
|
+ HttpResultBean<UserBean> bean = info.getRetDetail(new TypeToken<HttpResultBean<UserBean>>() {
|
|
|
|
+ }.getType());
|
|
|
|
+ Consts.setUID(bean.getData().getUid());
|
|
|
|
+ //用户是否登录,登录了,创建Consts的userbean
|
|
|
|
+ Consts.setmConstsUserBean(bean.getData());
|
|
|
|
+ mUserApi.loginSign(null, new Callback() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onSuccess(HttpInfo info) throws IOException {
|
|
|
|
+ try {
|
|
|
|
+ HttpResultBean<SignBean> bean = info.getRetDetail(new TypeToken<HttpResultBean<SignBean>>() {
|
|
|
|
+ }.getType());
|
|
|
|
+ if (bean.getData().getIsSign()) {
|
|
|
|
+ CusToast.getInstance(Consts.getmApplicAtion()).show("恭喜签到成功\n奖励" + bean.getData().getCount() + "朵小红花", 2000);
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ } finally {
|
|
|
|
+ if (!Consts.getUmengChannel().equals(ChannelCodeEnum.BAIDU.getChannelCode())) {
|
|
|
|
+ //不是小度的,检查权限
|
|
|
|
+ if (Consts.getmConstsUserBean() != null) {
|
|
|
|
+ mOrderApi.getAuth(new Callback() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onSuccess(HttpInfo info) throws IOException {
|
|
|
|
+ HttpResultBean<String> bean = info.getRetDetail(new TypeToken<HttpResultBean<String>>() {
|
|
|
|
+ }.getType());
|
|
|
|
+ if (!TextUtils.isEmpty(bean.getData())) {
|
|
|
|
+ Consts.setIsYFVip(true);
|
|
|
|
+ } else {
|
|
|
|
+ Consts.setIsYFVip(false);
|
|
|
|
+ }
|
|
|
|
+ //关闭界面
|
|
|
|
+ mView.getActivity().finish();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onFailure(HttpInfo info) throws IOException {
|
|
|
|
+ Logger.e("查询权限接口失败");
|
|
|
|
+ Consts.setIsYFVip(false);
|
|
|
|
+ mView.getActivity().finish();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onFailure(HttpInfo info) throws IOException {
|
|
|
|
+ CusToast.getInstance(Consts.getmApplicAtion()).show("其他错误:" + info.getRetDetail(), 2000);
|
|
|
|
+ //关闭界面
|
|
|
|
+ mView.getActivity().finish();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ } else if (object.getString("code").equals("300") || object.getInt("code") == 300) {
|
|
|
|
+ //暂无数据
|
|
|
|
+ Logger.e("暂无数据");
|
|
|
|
+ mLoginAlertHandler.sendEmptyMessageDelayed(0x1313, 1000);
|
|
|
|
+ return;
|
|
|
|
+ } else {
|
|
|
|
+ CusToast.getInstance(Consts.getmApplicAtion()).show(object.getString("code"), 2000);
|
|
|
|
+ mView.getActivity().finish();
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ Logger.e("onFailure--info.getRetDetail():" + info.getRetDetail());
|
|
|
|
+ CusToast.getInstance(Consts.getmApplicAtion()).show(e.getMessage(), 2000);
|
|
|
|
+ //关闭界面
|
|
|
|
+ mView.getActivity().finish();
|
|
|
|
+ } finally {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onFailure(HttpInfo info) throws IOException {
|
|
|
|
+// CusToast.getInstance(Consts.getmApplicAtion()).show(info.getRetDetail(), 2000);
|
|
|
|
+ Logger.e("onFailure--info.getRetDetail():" + info.getRetDetail());
|
|
|
|
+ //关闭界面
|
|
|
|
+ mView.getActivity().finish();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|