|
@@ -0,0 +1,227 @@
|
|
|
+package com.edufound.reader.presenter;
|
|
|
+
|
|
|
+import android.content.Intent;
|
|
|
+import android.net.Uri;
|
|
|
+import android.text.TextUtils;
|
|
|
+
|
|
|
+import com.baidu.duer.membersdk.MemberSdkManager;
|
|
|
+import com.baidu.duer.membersdk.constant.MemberSdkConstants;
|
|
|
+import com.edufound.reader.activity.MainActivity;
|
|
|
+import com.edufound.reader.activity.RecordActivity;
|
|
|
+import com.edufound.reader.activity.SmallFullVideoActivity;
|
|
|
+import com.edufound.reader.apiserver.ActivityEventServerImpl;
|
|
|
+import com.edufound.reader.apiserver.OrderApiServerImpl;
|
|
|
+import com.edufound.reader.apiserver.UserApiServerImpl;
|
|
|
+import com.edufound.reader.base.BaseActivity;
|
|
|
+import com.edufound.reader.base.BasePresenter;
|
|
|
+import com.edufound.reader.bean.ActivityEventBean;
|
|
|
+import com.edufound.reader.bean.ChannelCodeEnum;
|
|
|
+import com.edufound.reader.bean.HttpResultBean;
|
|
|
+import com.edufound.reader.bean.SignBean;
|
|
|
+import com.edufound.reader.bean.ThroughType;
|
|
|
+import com.edufound.reader.bean.ThroughTypeBean;
|
|
|
+import com.edufound.reader.bean.UserBean;
|
|
|
+import com.edufound.reader.contract.SplashContract;
|
|
|
+import com.edufound.reader.cusview.CusToast;
|
|
|
+import com.edufound.reader.listener.PopUtilClickListener;
|
|
|
+import com.edufound.reader.popwindow.PopWindowUtil;
|
|
|
+import com.edufound.reader.util.Consts;
|
|
|
+import com.edufound.reader.util.DeviceUuidFactory;
|
|
|
+import com.edufound.reader.util.EfunboxUtil;
|
|
|
+import com.edufound.reader.util.MMKVEncodeKey;
|
|
|
+import com.edufound.reader.util.MMKVUtil;
|
|
|
+import com.edufound.reader.util.ThroughUtil;
|
|
|
+import com.google.gson.reflect.TypeToken;
|
|
|
+import com.okhttplib.HttpInfo;
|
|
|
+import com.okhttplib.callback.Callback;
|
|
|
+import com.orhanobut.logger.Logger;
|
|
|
+
|
|
|
+import org.json.JSONException;
|
|
|
+import org.json.JSONObject;
|
|
|
+
|
|
|
+import java.io.IOException;
|
|
|
+
|
|
|
+public class SplashPresenter extends BasePresenter implements SplashContract.Presenter {
|
|
|
+
|
|
|
+ UserApiServerImpl mUserApi;
|
|
|
+ OrderApiServerImpl mOrderApi;
|
|
|
+ ActivityEventServerImpl mEventApi;
|
|
|
+
|
|
|
+ public SplashPresenter() {
|
|
|
+ mUserApi = new UserApiServerImpl();
|
|
|
+ mOrderApi = new OrderApiServerImpl();
|
|
|
+ mEventApi = new ActivityEventServerImpl();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getScheme(Intent intent) {
|
|
|
+ Uri getIntentUri = null;
|
|
|
+ if (intent != null) {
|
|
|
+ //有intent或者scheme
|
|
|
+ if (Consts.getUmengChannel().equals(ChannelCodeEnum.BAIDU.getChannelCode())) {
|
|
|
+ //判断是百度渠道
|
|
|
+ if (intent != null && intent.hasExtra(MemberSdkConstants.BOTAPP_OPEN_PARAMS_ACTIVE_INFO)) {
|
|
|
+ String infoData = intent.getStringExtra(MemberSdkConstants.BOTAPP_OPEN_PARAMS_ACTIVE_INFO);
|
|
|
+ MemberSdkManager.getInstance().setShowParameter(infoData);
|
|
|
+ }
|
|
|
+ if (intent.getStringExtra("url") != null && !intent.getStringExtra("url").equals("")) {
|
|
|
+ getIntentUri = Uri.parse(intent.getStringExtra("url"));
|
|
|
+ }
|
|
|
+ //efunbox://com.edufound.reader/splash?resid=11132
|
|
|
+ } else if (Consts.getUmengChannel().equals(ChannelCodeEnum.TMAIL.getChannelCode())) {
|
|
|
+ //天猫渠道
|
|
|
+ getIntentUri = intent.getData();
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //efunbox://com.edufound.reader/splash?exampleId=103126003&backModel=home&type=typeA (直接去朗读页面参数)
|
|
|
+ //efunbox://com.edufound.reader/splash?userReadId=1610706272358766&backModel=home&type=typeB (根据id把视频提前)
|
|
|
+ //efunbox://com.edufound.reader/splash?userReadId=1610706272358766&backModel=home&type=typeC (根据id把视频提前)
|
|
|
+// getIntentUri = Uri.parse("efunbox://com.edufound.reader/splash?exampleId=103126003&backModel=home&type=typeA");
|
|
|
+
|
|
|
+ //判断获取的uri是不是空的
|
|
|
+ if (getIntentUri != null) {
|
|
|
+ String type = getIntentUri.getQueryParameter("type");
|
|
|
+ if (getIntentUri.getQueryParameter("type") != null) {
|
|
|
+ ThroughUtil.mThroughTypeBean = new ThroughTypeBean();
|
|
|
+ if (type.equals(ThroughType.TYPEA.getTypeCode())) {
|
|
|
+ //typeA类型,直接进入朗读界面
|
|
|
+ Logger.e("进入了TypeA类型");
|
|
|
+ ThroughUtil.mThroughTypeBean.setmThroughType(ThroughType.TYPEA.getTypeCode());
|
|
|
+ ThroughUtil.mThroughTypeBean.setExampleId(getIntentUri.getQueryParameter("exampleId"));
|
|
|
+ //backModel只有app和home两个值,app是直接退出应用,home是返回首页
|
|
|
+ ThroughUtil.mThroughTypeBean.setBackModel(getIntentUri.getQueryParameter("backModel"));
|
|
|
+ Logger.e("getIntentUri.getQueryParameter(\"exampleId\"):" + getIntentUri.getQueryParameter("exampleId"));
|
|
|
+ Logger.e("getIntentUri.getQueryParameter(\"backModel\"):" + getIntentUri.getQueryParameter("backModel"));
|
|
|
+ //暂时还没处理defaultIndex
|
|
|
+// String defaultIndex = getIntentUri.getQueryParameter("backDefaultIndex");
|
|
|
+// if (!TextUtils.isEmpty(defaultIndex)) {
|
|
|
+// ThroughUtil.mThroughTypeBean.setBackDefaultIndex(getIntentUri.getQueryParameter("backDefaultIndex"));
|
|
|
+// } else {
|
|
|
+// ThroughUtil.mThroughTypeBean.setBackDefaultIndex("0");
|
|
|
+// }
|
|
|
+ ((BaseActivity) mView.getActivity()).toNextActivity(RecordActivity.class);
|
|
|
+
|
|
|
+ } else if (type.equals(ThroughType.TYPEB.getTypeCode())) {
|
|
|
+ Logger.e("进入了TypeB类型");
|
|
|
+ //把收到的ID视频提到第一个
|
|
|
+ ThroughUtil.mThroughTypeBean.setmThroughType(ThroughType.TYPEB.getTypeCode());
|
|
|
+ ThroughUtil.mThroughTypeBean.setUserReadId(getIntentUri.getQueryParameter("userReadId"));
|
|
|
+ } else if (type.equals(ThroughType.TYPEC.getTypeCode())) {
|
|
|
+ ThroughUtil.mThroughTypeBean.setmThroughType(ThroughType.TYPEC.getTypeCode());
|
|
|
+ ThroughUtil.mThroughTypeBean.setUserReadId(getIntentUri.getQueryParameter("userReadId"));
|
|
|
+ ThroughUtil.mThroughTypeBean.setBackModel(getIntentUri.getQueryParameter("backModel"));
|
|
|
+ ((BaseActivity) mView.getActivity()).toNextActivity(SmallFullVideoActivity.class);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ } else {
|
|
|
+ //如果什么都没有得到,就默认跳转首页
|
|
|
+ ((BaseActivity) mView.getActivity()).toNextActivity(MainActivity.class);
|
|
|
+ }
|
|
|
+ mView.getActivity().finish();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void getUserInfo(Intent intent) {
|
|
|
+ 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("300") || object.getInt("code") == 300) {
|
|
|
+ //没有用户数据
|
|
|
+ if (TextUtils.isEmpty(MMKVUtil.getInstance().decodeString(MMKVEncodeKey.USER_GRADE))) {
|
|
|
+ //没有选择过年纪,选择年纪
|
|
|
+ Logger.e("TextUtils.isEmpty(MMKVUtil.getInstance().decodeString(MMKVEncodeKey.USER_GRADE)");
|
|
|
+// showSelectGradeWindow();
|
|
|
+ } else {
|
|
|
+ Logger.e("TextUtils.isEmpty(MMKVUtil.getInstance().decodeString(MMKVEncodeKey.USER_GRADE)--else");
|
|
|
+ //选择过年纪。无处理
|
|
|
+ }
|
|
|
+// registerMobile("18655365222");
|
|
|
+ getYFVip();
|
|
|
+ } else {
|
|
|
+ HttpResultBean<UserBean> bean = info.getRetDetail(new TypeToken<HttpResultBean<UserBean>>() {
|
|
|
+ }.getType());
|
|
|
+ Consts.setUID(bean.getData().getUid());
|
|
|
+ //用户是否登录,登录了,创建Consts的userbean
|
|
|
+ Consts.setmConstsUserBean(bean.getData());
|
|
|
+ mUserApi.loginSign(mView.getActivity(), new Callback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(HttpInfo info) throws IOException {
|
|
|
+ try {
|
|
|
+ HttpResultBean<SignBean> bean = info.getRetDetail(new TypeToken<HttpResultBean<SignBean>>() {
|
|
|
+ }.getType());
|
|
|
+ if (bean.getData() != null) {
|
|
|
+ if (bean.getData().getIsSign()) {
|
|
|
+ CusToast.getInstance(mView.getActivity()).show("恭喜签到成功\n奖励" + bean.getData().getCount() + "朵小红花", 2000);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Logger.e("签到参数 isSign是空的");
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ getYFVip();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFailure(HttpInfo info) throws IOException {
|
|
|
+ Logger.e("info:" + info.getRetDetail());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+
|
|
|
+ //无论如何最后走判断
|
|
|
+ getScheme(intent);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFailure(HttpInfo info) throws IOException {
|
|
|
+ if (TextUtils.isEmpty(MMKVUtil.getInstance().decodeString(MMKVEncodeKey.USER_GRADE))) {
|
|
|
+ //没有选择过年纪,选择年纪
|
|
|
+// showSelectGradeWindow();
|
|
|
+ } else {
|
|
|
+ //选择过年纪。无处理
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void getYFVip() {
|
|
|
+
|
|
|
+ if (!Consts.getUmengChannel().equals(ChannelCodeEnum.BAIDU.getChannelCode())) {
|
|
|
+ //不是百度渠道,检查是否是义方VIP
|
|
|
+ if (Consts.getmConstsUserBean() != null) {
|
|
|
+ mOrderApi.getAuth(mView.getActivity(), 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFailure(HttpInfo info) throws IOException {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|