From 18aabb85a7a765b07d8bdd2641487f0b68cd456b Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Sat, 23 Jul 2022 10:05:15 +0800 Subject: [PATCH] 11111 --- .../phonelive/activity/LauncherActivity.java | 39 ++++++++++++++--- .../common/event/DataUserInfoEvent.java | 19 ++++++++ .../yunbao/common/manager/IMLoginManager.java | 43 +++++++++++++++++-- config.gradle | 4 +- .../com/yunbao/main/http/MainHttpUtil.java | 12 ++++-- 5 files changed, 101 insertions(+), 16 deletions(-) create mode 100644 common/src/main/java/com/yunbao/common/event/DataUserInfoEvent.java diff --git a/app/src/main/java/com/shayu/phonelive/activity/LauncherActivity.java b/app/src/main/java/com/shayu/phonelive/activity/LauncherActivity.java index 7bd0d57ff..06a335f69 100644 --- a/app/src/main/java/com/shayu/phonelive/activity/LauncherActivity.java +++ b/app/src/main/java/com/shayu/phonelive/activity/LauncherActivity.java @@ -6,10 +6,6 @@ import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Message; - -import androidx.annotation.Nullable; -import androidx.appcompat.app.AppCompatActivity; - import android.text.TextUtils; import android.util.Log; import android.view.Gravity; @@ -20,6 +16,9 @@ import android.view.WindowManager; import android.widget.FrameLayout; import android.widget.ImageView; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + import com.adjust.sdk.Adjust; import com.adjust.sdk.AdjustEvent; import com.alibaba.android.arouter.facade.annotation.Route; @@ -37,6 +36,7 @@ import com.yunbao.common.bean.ConfigBean; import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.bean.UserBean; import com.yunbao.common.custom.CircleProgress; +import com.yunbao.common.event.DataUserInfoEvent; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.CommonHttpConsts; import com.yunbao.common.http.CommonHttpUtil; @@ -56,6 +56,10 @@ import com.yunbao.main.activity.MainActivity; import com.yunbao.main.http.MainHttpConsts; import com.yunbao.main.http.MainHttpUtil; +import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + import java.io.File; import java.util.ArrayList; import java.util.List; @@ -98,6 +102,7 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); + EventBus.getDefault().register(this); setStatusBar(); setContentView(R.layout.activity_launcher); //开屏 @@ -237,9 +242,15 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL RongcloudIMManager.connectIM(this); forwardMainActivity(); } else { - releaseVideo(); - this.startActivity(new Intent(this, EntryActivity.class)); - this.finish(); + //兼容老版本 + if (IMLoginManager.get(this).checkOLd()) { + IMLoginManager.get(this).upDataUserInfo(); + } else { + releaseVideo(); + this.startActivity(new Intent(this, EntryActivity.class)); + this.finish(); + } + } } @@ -256,6 +267,7 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL @Override protected void onDestroy() { + EventBus.getDefault().unregister(this); if (mHandler != null) { mHandler.removeCallbacksAndMessages(null); mHandler = null; @@ -512,4 +524,17 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL }); mPlayer.startPlay(videoFile.getAbsolutePath(), TXLivePlayer.PLAY_TYPE_LOCAL_VIDEO); } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onDataUserInfoEvent(DataUserInfoEvent event) { + if (event.isUpDataSuccess()) { + //融云连接服务器 + RongcloudIMManager.connectIM(this); + forwardMainActivity(); + } else { + releaseVideo(); + this.startActivity(new Intent(this, EntryActivity.class)); + this.finish(); + } + } } diff --git a/common/src/main/java/com/yunbao/common/event/DataUserInfoEvent.java b/common/src/main/java/com/yunbao/common/event/DataUserInfoEvent.java new file mode 100644 index 000000000..77a5118fc --- /dev/null +++ b/common/src/main/java/com/yunbao/common/event/DataUserInfoEvent.java @@ -0,0 +1,19 @@ +package com.yunbao.common.event; + +import com.yunbao.common.bean.BaseModel; + +/** + * 更新用戶信息 成功 + */ +public class DataUserInfoEvent extends BaseModel { + private boolean upDataSuccess = false; + + public boolean isUpDataSuccess() { + return upDataSuccess; + } + + public DataUserInfoEvent setUpDataSuccess(boolean upDataSuccess) { + this.upDataSuccess = upDataSuccess; + return this; + } +} diff --git a/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java b/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java index fa5d990e0..c69a2ae99 100644 --- a/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java +++ b/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java @@ -2,21 +2,21 @@ package com.yunbao.common.manager; import android.content.Context; import android.os.Handler; -import android.util.Log; +import android.text.TextUtils; import androidx.annotation.NonNull; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.TypeReference; import com.google.gson.Gson; import com.yunbao.common.bean.IMLoginModel; +import com.yunbao.common.event.DataUserInfoEvent; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; import com.yunbao.common.manager.base.BaseCacheManager; import com.yunbao.common.manager.imrongcloud.MessageIMManager; import com.yunbao.common.manager.imrongcloud.RongcloudIMManager; +import com.yunbao.common.utils.SpUtil; -import java.util.Map; +import org.greenrobot.eventbus.EventBus; /** * 登录者信息管理 @@ -112,4 +112,39 @@ public class IMLoginManager extends BaseCacheManager { MessageIMManager.get(context).logout(); } + /** + * 檢查老版本信息是否純在 + * + * @return + */ + public boolean checkOLd() { + String[] uidAndToken = SpUtil.getInstance().getMultiStringValue(new String[]{SpUtil.UID, SpUtil.TOKEN}); + String uid = uidAndToken[0]; + String token = uidAndToken[1]; + return (!TextUtils.isEmpty(uid) && !TextUtils.isEmpty(token)); + } + + /** + * 更新用戶信息 + */ + public void upDataUserInfo() { + String[] uidAndToken = SpUtil.getInstance().getMultiStringValue(new String[]{SpUtil.UID, SpUtil.TOKEN}); + String uid = uidAndToken[0]; + String token = uidAndToken[1]; + HttpClient.getInstance().get("User.getBaseInfos", "getBaseInfo") + .params("uid", uid) + .params("token", token) + .execute(new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && info.length > 0) { + userInfo = new Gson().fromJson(info[0], IMLoginModel.class); + EventBus.getDefault().post(new DataUserInfoEvent().setUpDataSuccess(true)); + } else { + EventBus.getDefault().post(new DataUserInfoEvent().setUpDataSuccess(false)); + } + } + }); + } + } diff --git a/config.gradle b/config.gradle index 53e2161f5..eddca7244 100644 --- a/config.gradle +++ b/config.gradle @@ -9,9 +9,9 @@ ext { ] manifestPlaceholders = [ //正式 -// serverHost : "https://napi.yaoulive.com", + serverHost : "https://napi.yaoulive.com", //測試 - serverHost : "https://ceshi.yaoulive.com", +// serverHost : "https://ceshi.yaoulive.com", //腾讯地图 txMapAppKey : "EOZBZ-ASLCU-4XPV3-BDCHZ-4E3Q7-H4BWB", diff --git a/main/src/main/java/com/yunbao/main/http/MainHttpUtil.java b/main/src/main/java/com/yunbao/main/http/MainHttpUtil.java index b16a3e563..e81e5a5ae 100644 --- a/main/src/main/java/com/yunbao/main/http/MainHttpUtil.java +++ b/main/src/main/java/com/yunbao/main/http/MainHttpUtil.java @@ -275,6 +275,12 @@ public class MainHttpUtil { }); } + public static void getBaseInfos(String uid, String token, HttpCallback callback) { + HttpClient.getInstance().get("User.getBaseInfos", MainHttpConsts.GET_BASE_INFO) + .params("uid", uid) + .params("token", token) + .execute(callback); + } /** * 获取用户信息 @@ -289,7 +295,7 @@ public class MainHttpUtil { * 获取用户钱 */ public static void getBalance(HttpCallback callback) { - HttpClient.getInstance().get("User.getUserBalance","User.getUserBalance") + HttpClient.getInstance().get("User.getUserBalance", "User.getUserBalance") .params("uid", CommonAppConfig.getInstance().getUid()) .params("token", CommonAppConfig.getInstance().getToken()) .execute(callback); @@ -576,7 +582,7 @@ public class MainHttpUtil { /** * 手机注册接口---增加参数:推广码,手机唯一标识,国家代码 */ - public static void register(String invitecode,String user_login, String promo_code, String uuidDevice, int countryCode, String pass, String pass2, String code, HttpCallback callback) { + public static void register(String invitecode, String user_login, String promo_code, String uuidDevice, int countryCode, String pass, String pass2, String code, HttpCallback callback) { HttpClient.getInstance().get("Login.userReg", MainHttpConsts.REGISTER) .params("user_login", user_login) //增加参数:推广码 @@ -590,7 +596,7 @@ public class MainHttpUtil { .params("user_pass2", pass2) .params("code", code) .params("source", DEVICE) - .params("invitation_code",invitecode) + .params("invitation_code", invitecode) .execute(callback); }