Browse Source

1.修改小米切换用户出现的问题
2.修改小米渠道切换用户选项

FailedToRead 2 years ago
parent
commit
88a51ef5e6

+ 1 - 1
.idea/misc.xml

@@ -179,7 +179,7 @@
         <entry key="..\:/Work_Space/Android_Space/efunboxReader/efunboxReader-android-master/app/src/main/res/layout/cusview_model_view_g.xml" value="0.28284671532846717" />
         <entry key="..\:/Work_Space/Android_Space/efunboxReader/efunboxReader-android-master/app/src/main/res/layout/fragment_main_character.xml" value="0.2615571776155718" />
         <entry key="..\:/Work_Space/Android_Space/efunboxReader/efunboxReader-android-master/app/src/main/res/layout/fragment_main_event.xml" value="0.16" />
-        <entry key="..\:/Work_Space/Android_Space/efunboxReader/efunboxReader-android-master/app/src/main/res/layout/fragment_main_user.xml" value="0.16" />
+        <entry key="..\:/Work_Space/Android_Space/efunboxReader/efunboxReader-android-master/app/src/main/res/layout/fragment_main_user.xml" value="0.25" />
         <entry key="..\:/Work_Space/Android_Space/efunboxReader/efunboxReader-android-master/app/src/main/res/layout/player_controller.xml" value="0.25790754257907544" />
         <entry key="..\:/Work_Space/Android_Space/efunboxReader/efunboxReader-android-master/app/src/main/res/layout/popupwindow_exit_app.xml" value="0.2402676399026764" />
         <entry key="..\:/Work_Space/Android_Space/efunboxReader/efunboxReader-android-master/app/src/main/res/layout/popupwindow_mi_sound_qrcode_layout.xml" value="0.18" />

+ 23 - 0
app/src/main/java/com/edufound/reader/activity/UserInfoSettingActivity.java

@@ -138,6 +138,7 @@ public class UserInfoSettingActivity extends BaseMvpActivity<UserInfoSettingPres
             mBindPhoneNumLayout.setVisibility(View.GONE);
         } else if (Consts.getUmengChannel().equals(ChannelCodeEnum.MISOUND.getChannelCode())) {
             mBindWeChat.setVisibility(View.GONE);
+            mSwitchLayout.setVisibility(View.GONE);
             mBindPhoneNumLayout.setVisibility(View.VISIBLE);
             addUiClickListener(mBindPhoneNumLayout, o -> {
                 if (hasBindPhone) {
@@ -149,6 +150,11 @@ public class UserInfoSettingActivity extends BaseMvpActivity<UserInfoSettingPres
                             Logger.e("绑定成功返回了!!!!!!!!!!!!!!!!!!!");
                             hasBindPhone = true;
                         }
+
+                        @Override
+                        public void closeWindow() {
+                            Logger.e("closeWindow");
+                        }
                     });
                 }
             });
@@ -204,6 +210,23 @@ public class UserInfoSettingActivity extends BaseMvpActivity<UserInfoSettingPres
                 mNickName.clearFocus();
                 return;
             }
+            if (Consts.getUmengChannel().equals(ChannelCodeEnum.MISOUND.getChannelCode())) {
+                //小米的特殊处理
+
+                PopWindowUtil.miSoundLoginWindow(mActivity, getRootView(), MiSoundSDKUtil.MI_SOUND_QRCODE_UPDATE_USER, new PopWindowPresneter.MISoundLoginCallBack() {
+                    @Override
+                    public void success() {
+
+                    }
+
+                    @Override
+                    public void closeWindow() {
+                        Logger.e("closeWindow");
+                        mPresenter.checkLogin();
+                    }
+                });
+                return;
+            }
             EfunboxUtil.userLogin(getActivity(), getRootView());
         });
 

+ 2 - 2
app/src/main/java/com/edufound/reader/adapter/SlideVideoAdapter.java

@@ -115,8 +115,8 @@ public class SlideVideoAdapter extends RecyclerView.Adapter<VideoHolder> {
                     holder.mEventFrame.setOnClickListener(new View.OnClickListener() {
                         @Override
                         public void onClick(View v) {
-                            Logger.e("mListData.get(position).getUserRead().getActivityType():" + mListData.get(position).getUserRead().getActivityType());
-                            EfunboxUtil.toWebFlowerActivity(mContext, mListData.get(position).getUserRead().getActivityUrl(), null);
+                            Logger.e("mListData.get(position).getUserRead().getActivityId():" + mListData.get(position).getUserRead().getActivityId());
+                            EfunboxUtil.toWebFlowerActivity(mContext, mListData.get(position).getUserRead().getActivityUrl(), mListData.get(position).getUserRead().getActivityId());
                         }
                     });
                     break;

+ 4 - 0
app/src/main/java/com/edufound/reader/apiserver/UserApiServerImpl.java

@@ -12,6 +12,7 @@ import com.edufound.reader.util.OkHttpClient;
 import com.google.gson.Gson;
 import com.okhttplib.HttpInfo;
 import com.okhttplib.callback.Callback;
+import com.orhanobut.logger.Logger;
 
 public class UserApiServerImpl implements userApiServer {
     private String API = Consts.getFinalApi();
@@ -148,6 +149,7 @@ public class UserApiServerImpl implements userApiServer {
      */
     @Override
     public void getLoginQRCode(Callback callback) {
+        Logger.e("deviceCode:" + DeviceUuidFactory.getUuid());
         OkHttpClient.doGetAsync(HttpInfo.Builder().addParam("channelCode", Consts.getUmengChannel()).addParam("deviceCode", DeviceUuidFactory.getUuid()).setUrl(API + "/user/qrCode"), callback);
     }
 
@@ -271,4 +273,6 @@ interface userApiServer {
      * 获取排行榜
      */
     void getRankList(String id, Callback callback);
+
+
 }

+ 3 - 6
app/src/main/java/com/edufound/reader/application/EApplication.java

@@ -13,17 +13,16 @@ import android.os.Handler;
 import android.os.Looper;
 import android.widget.Toast;
 
+import androidx.annotation.RequiresApi;
+
 import com.baidu.duer.botsdk.BotSdk;
 import com.baidu.duer.botsdk.util.HeartBeatReporter;
-import com.edufound.reader.BuildConfig;
-import com.edufound.reader.R;
 import com.edufound.reader.activity.CrashDialogActivity;
 import com.edufound.reader.activity.MainActivity;
 import com.edufound.reader.bean.ChannelCodeEnum;
 import com.edufound.reader.botsdk.BotConstants;
 import com.edufound.reader.botsdk.BotMessageListener;
 import com.edufound.reader.botsdk.BotSDKUtils;
-import com.edufound.reader.cusview.CusToast;
 import com.edufound.reader.support.CrashLog;
 import com.edufound.reader.support.DebugSafeModeTipActivity;
 import com.edufound.reader.support.DebugSafeModeUI;
@@ -47,8 +46,6 @@ import org.xmlpull.v1.XmlPullParserFactory;
 import java.util.ArrayList;
 import java.util.List;
 
-import androidx.annotation.RequiresApi;
-
 public class EApplication extends Application {
 
     private int activityAount = 0;
@@ -60,7 +57,7 @@ public class EApplication extends Application {
     public void onCreate() {
         super.onCreate();
         try {
-            Consts.setIsDebug(true);
+            Consts.setIsDebug(false);
             Consts.setmApplicAtion(this);
 
             //初始化异常监听

+ 11 - 0
app/src/main/java/com/edufound/reader/bean/UserRecordBean.java

@@ -83,6 +83,8 @@ public class UserRecordBean {
 
         private String activityUrl;
 
+        private String activityId;
+
         private String audioPath;
 
         private String channel;
@@ -164,6 +166,15 @@ public class UserRecordBean {
             this.activityUrl = activityUrl;
         }
 
+
+        public String getActivityId() {
+            return activityId;
+        }
+
+        public void setActivityId(String activityId) {
+            this.activityId = activityId;
+        }
+
         public String getReadAmount() {
             return readAmount;
         }

+ 2 - 0
app/src/main/java/com/edufound/reader/contract/UserInfoSettingContract.java

@@ -43,5 +43,7 @@ public interface UserInfoSettingContract {
         void registerMobile(String phone);
 
         void userCancellation();
+
+        void checkLogin();
     }
 }

+ 8 - 0
app/src/main/java/com/edufound/reader/interfaces/EfunboxInterfaces.java

@@ -0,0 +1,8 @@
+package com.edufound.reader.interfaces;
+
+public class EfunboxInterfaces {
+    public interface getYFVipInterfaces {
+        void success();
+        void error();
+    }
+}

+ 1 - 0
app/src/main/java/com/edufound/reader/miutil/MiSoundSDKUtil.java

@@ -49,6 +49,7 @@ import java.util.Map;
 public class MiSoundSDKUtil {
     private static Gson mGson;
     public static final int MI_SOUND_QRCODE_TYPE = 0x19181;
+    public static final int MI_SOUND_QRCODE_UPDATE_USER=0x19184;
     public static final int MI_SOUND_BIND_PHONENUM = 0x19182;
     public static final int MI_SOUND_SHOW_BINDPHONENUM = 0x19183;
 

+ 9 - 1
app/src/main/java/com/edufound/reader/popwindow/PopWindowUtil.java

@@ -443,8 +443,8 @@ public class PopWindowUtil {
         mBindPhoneNumLayout.setVisibility(View.GONE);
 
         switch (type) {
+            case MiSoundSDKUtil.MI_SOUND_QRCODE_UPDATE_USER:
             case MiSoundSDKUtil.MI_SOUND_QRCODE_TYPE:
-                Logger.e("显示qrcodelayout");
                 mQRLoginLayout.setVisibility(View.VISIBLE);
                 break;
             case MiSoundSDKUtil.MI_SOUND_BIND_PHONENUM:
@@ -458,6 +458,9 @@ public class PopWindowUtil {
 
         ImageView close = dialog_view.findViewById(R.id.popupwindow_mi_sound_qrcode_layout_close);
         setClickListener(close, o -> {
+            if (callBack != null) {
+                callBack.closeWindow();
+            }
             mPresenter.getPopHandler().removeMessages(0x1313);
             mPopupWindow.dismiss();
         });
@@ -471,6 +474,11 @@ public class PopWindowUtil {
                 }
                 mPopupWindow.dismiss();
             }
+
+            @Override
+            public void closeWindow() {
+                
+            }
         });
         newPopupWindow(parent, true);
     }

+ 12 - 29
app/src/main/java/com/edufound/reader/presenter/LoginAlertPresenter.java

@@ -23,6 +23,7 @@ import com.edufound.reader.bean.ChannelCodeEnum;
 import com.edufound.reader.bean.HttpResultBean;
 import com.edufound.reader.bean.UserBean;
 import com.edufound.reader.contract.LoginAlertContract;
+import com.edufound.reader.interfaces.EfunboxInterfaces;
 import com.edufound.reader.model.LoginAlertModel;
 import com.edufound.reader.util.Consts;
 import com.edufound.reader.util.DeviceUuidFactory;
@@ -167,7 +168,17 @@ public class LoginAlertPresenter extends BasePresenter<LoginAlertContract.View>
                         Consts.setUID(bean.getData().getUid());
                         //用户是否登录,登录了,创建Consts的userbean
                         Consts.setmConstsUserBean(bean.getData());
-                        getYFVip();
+                        EfunboxUtil.getYFVip(mView.getActivity(), new EfunboxInterfaces.getYFVipInterfaces() {
+                            @Override
+                            public void success() {
+                                mView.getActivity().finish();
+                            }
+
+                            @Override
+                            public void error() {
+                                mView.getActivity().finish();
+                            }
+                        });
                         //检查活动
                         EfunboxUtil.checkEvents(mView.getActivity());
 
@@ -193,34 +204,6 @@ public class LoginAlertPresenter extends BasePresenter<LoginAlertContract.View>
         }
     }
 
-    private void getYFVip() {
-
-        if (!Consts.getUmengChannel().equals(ChannelCodeEnum.BAIDU.getChannelCode())) {
-            //不是百度渠道,检查是否是义方VIP
-            if (Consts.getmConstsUserBean() != null) {
-                OrderApiServerImpl api = new OrderApiServerImpl();
-                api.getAuth(mView.getActivity(), new Callback() {
-                    @Override
-                    public void onSuccess(HttpInfo info) throws IOException {
-                        HttpResultBean<String> bean = info.getRetDetail(new TypeToken<HttpResultBean<String>>() {
-                        }.getType());
-                        Logger.e("info.getRetDetail():" + info.getRetDetail());
-                        Logger.e("bean.getData():" + bean.getData());
-                        Consts.setIsYFVip(true);
-                        mView.getActivity().finish();
-                    }
-
-                    @Override
-                    public void onFailure(HttpInfo info) throws IOException {
-//                        Toast.makeText(mView.getActivity(),"")
-                        mView.getActivity().finish();
-                    }
-                });
-            }
-        } else {
-            mView.getActivity().finish();
-        }
-    }
 
     @Override
     public void activityDestory() {

+ 6 - 1
app/src/main/java/com/edufound/reader/presenter/PopWindowPresneter.java

@@ -471,6 +471,7 @@ public class PopWindowPresneter {
     public void initMiSoundLoginWindow(Context context, View dialog_view, int type, MISoundLoginCallBack callBack) {
         miSoundLoginCallback = callBack;
         switch (type) {
+            case MiSoundSDKUtil.MI_SOUND_QRCODE_UPDATE_USER:
             case MiSoundSDKUtil.MI_SOUND_QRCODE_TYPE:
                 ImageView qrcode = dialog_view.findViewById(R.id.popupwindow_mi_sound_qrcode);
                 userApi.getLoginQRCode(new Callback() {
@@ -484,7 +485,9 @@ public class PopWindowPresneter {
                             Logger.e("加载二维码");
                             GlideUtils.loadImageSizeKipMemoryCache(context, bean.getData(), qrcode);
                             loginSuccess = false;
-                            handler.sendEmptyMessageDelayed(0x1313, 1000);
+                            if (type == MiSoundSDKUtil.MI_SOUND_QRCODE_TYPE) {
+                                handler.sendEmptyMessageDelayed(0x1313, 1000);
+                            }
                         } else {
                             Logger.e("加载二维码失败");
                         }
@@ -737,6 +740,8 @@ public class PopWindowPresneter {
 
     public interface MISoundLoginCallBack {
         void success();
+
+        void closeWindow();
     }
 }
 

+ 11 - 24
app/src/main/java/com/edufound/reader/presenter/SplashPresenter.java

@@ -23,6 +23,7 @@ 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.interfaces.EfunboxInterfaces;
 import com.edufound.reader.listener.PopUtilClickListener;
 import com.edufound.reader.popwindow.PopWindowUtil;
 import com.edufound.reader.util.Consts;
@@ -137,6 +138,7 @@ public class SplashPresenter extends BasePresenter implements SplashContract.Pre
                     Logger.e("info:" + info.getRetDetail());
                     JSONObject object = new JSONObject(info.getRetDetail());
                     if (object.getString("code").equals("300") || object.getInt("code") == 300) {
+                        getScheme(intent);
                     } else {
                         HttpResultBean<UserBean> bean = info.getRetDetail(new TypeToken<HttpResultBean<UserBean>>() {
                         }.getType());
@@ -167,32 +169,17 @@ public class SplashPresenter extends BasePresenter implements SplashContract.Pre
 
 
     private void getYFVip(Intent intent) {
+        EfunboxUtil.getYFVip(mView.getActivity(), new EfunboxInterfaces.getYFVipInterfaces() {
+            @Override
+            public void success() {
+                getScheme(intent);
+            }
 
-        try {
-            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 {
-                        }
-                    });
-                }
+            @Override
+            public void error() {
+                getScheme(intent);
             }
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            getScheme(intent);
-        }
+        });
     }
 
 }

+ 39 - 0
app/src/main/java/com/edufound/reader/presenter/UserInfoSettingPresenter.java

@@ -24,6 +24,8 @@ import com.okhttplib.HttpInfo;
 import com.okhttplib.callback.Callback;
 import com.orhanobut.logger.Logger;
 
+import org.json.JSONException;
+
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
@@ -49,6 +51,7 @@ public class UserInfoSettingPresenter extends BasePresenter<UserInfoSettingContr
                 Logger.e("info:" + info.getRetDetail());
                 HttpResultBean<MyInfoBean> bean = info.getRetDetail(new TypeToken<HttpResultBean<MyInfoBean>>() {
                 }.getType());
+                Consts.setmConstsUserBean(bean.getData().getUser());
                 mView.getUserInfoSuccess(bean.getData().getUser());
                 mGradeEnum = bean.getData().getUser().getGrade();
             }
@@ -181,4 +184,40 @@ public class UserInfoSettingPresenter extends BasePresenter<UserInfoSettingContr
             }
         });
     }
+
+    @Override
+    public void checkLogin() {
+        mUserApi.isLogin(mView.getActivity(), DeviceUuidFactory.getUuid(), new Callback() {
+            @Override
+            public void onSuccess(HttpInfo info) throws IOException {
+                try {
+                    Logger.e("info:" + info.getRetDetail());
+                    org.json.JSONObject object = new org.json.JSONObject(info.getRetDetail());
+                    if (object.getString("code").equals("300") || object.getInt("code") == 300) {
+                    } else {
+                        HttpResultBean<UserBean> bean = info.getRetDetail(new TypeToken<HttpResultBean<UserBean>>() {
+                        }.getType());
+                        Consts.setUID(bean.getData().getUid());
+                        //用户是否登录,登录了,创建Consts的userbean
+                        Consts.setmConstsUserBean(bean.getData());
+
+                    }
+                } catch (JSONException e) {
+                    e.printStackTrace();
+                } finally {
+                    //无论如何最后走判断
+                    //获取是否是vip
+                    EfunboxUtil.getYFVip(mView.getActivity(), null);
+
+                }
+
+
+            }
+
+            @Override
+            public void onFailure(HttpInfo info) throws IOException {
+                EfunboxUtil.getYFVip(mView.getActivity(), null);
+            }
+        });
+    }
 }

+ 3 - 3
app/src/main/java/com/edufound/reader/presenter/WebPresenter.java

@@ -162,15 +162,15 @@ public class WebPresenter extends BasePresenter<WebContract.View> implements Web
         webview.addJavascriptInterface(mJsInterfaces, "efunboxJS");
 
         //加载地址
-        String url = intent.getStringExtra("loadUrl").trim() + "?";
+        String url = intent.getStringExtra("loadUrl").trim();
         Gson gson = new Gson();
         StringBuffer buffer = new StringBuffer();
         if (!TextUtils.isEmpty(intent.getStringExtra("paramsJson"))) {
             WebParams params = gson.fromJson(intent.getStringExtra("paramsJson"), WebParams.class);
             if (!TextUtils.isEmpty(params.channelCode)) {
-                buffer.append("channelCode=" + params.channelCode);
+                buffer.append("&channelCode=" + params.channelCode);
             } else {
-                buffer.append("a=a");
+                buffer.append("&a=a");
             }
             if (!TextUtils.isEmpty(params.uid)) {
                 buffer.append("&uid=" + params.uid);

+ 42 - 0
app/src/main/java/com/edufound/reader/util/EfunboxUtil.java

@@ -12,11 +12,13 @@ import com.edufound.reader.activity.PayActivity;
 import com.edufound.reader.activity.TmailPayActivity;
 import com.edufound.reader.activity.WebActivity;
 import com.edufound.reader.apiserver.ActivityEventServerImpl;
+import com.edufound.reader.apiserver.OrderApiServerImpl;
 import com.edufound.reader.bean.ActivityEventBean;
 import com.edufound.reader.bean.ChannelCodeEnum;
 import com.edufound.reader.bean.EventListBean;
 import com.edufound.reader.bean.HttpResultBean;
 import com.edufound.reader.botsdk.BotRegisterListener;
+import com.edufound.reader.interfaces.EfunboxInterfaces;
 import com.edufound.reader.listener.PopUtilClickListener;
 import com.edufound.reader.miutil.MiSoundSDKUtil;
 import com.edufound.reader.popwindow.PopWindowUtil;
@@ -212,6 +214,46 @@ public class EfunboxUtil {
         }
     }
 
+    /**
+     * 判断是否是vip
+     */
+    public static void getYFVip(Context context, EfunboxInterfaces.getYFVipInterfaces callback) {
+
+        if (!Consts.getUmengChannel().equals(ChannelCodeEnum.BAIDU.getChannelCode())) {
+            //不是百度渠道,检查是否是义方VIP
+            if (Consts.getmConstsUserBean() != null) {
+                OrderApiServerImpl api = new OrderApiServerImpl();
+                api.getAuth(null, new Callback() {
+                    @Override
+                    public void onSuccess(HttpInfo info) throws IOException {
+                        HttpResultBean<String> bean = info.getRetDetail(new TypeToken<HttpResultBean<String>>() {
+                        }.getType());
+                        Logger.e("info.getRetDetail():" + info.getRetDetail());
+                        Logger.e("bean.getData():" + bean.getData());
+                        Consts.setIsYFVip(true);
+                        if (callback != null) {
+                            callback.success();
+                        }
+                    }
+
+                    @Override
+                    public void onFailure(HttpInfo info) throws IOException {
+//                        Toast.makeText(mView.getActivity(),"")
+                        Consts.setIsYFVip(false);
+                        if (callback != null) {
+                            callback.error();
+                        }
+
+                    }
+                });
+            }
+        } else {
+            if (callback != null) {
+                callback.error();
+            }
+        }
+    }
+
 
     public static String checkNum10000(String num) {
         if (Float.valueOf(num) > 10000f) {