From 97c93ea1080f76770b91c6c9a1841e6bd9501061 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Mon, 28 Oct 2024 14:29:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=90=AF=E5=8A=A8APP?= =?UTF-8?q?=E6=97=B6=E8=8E=B7=E5=8F=96=E5=8A=A8=E6=80=81=E5=9F=9F=E5=90=8D?= =?UTF-8?q?=E5=88=A4=E6=96=AD=20=E6=96=B0=E5=A2=9E=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E6=9C=8DURL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../phonelive/activity/LauncherActivity.java | 100 +++++++++++++----- .../com/yunbao/common/CommonAppConfig.java | 2 +- .../com/yunbao/common/bean/DomainUrl.java | 17 +++ .../main/java/com/yunbao/common/http/API.java | 3 + .../com/yunbao/common/http/HttpClient.java | 1 + .../com/yunbao/common/http/PDLiveApi.java | 6 ++ .../common/http/live/LiveNetManager.java | 21 +++- config.gradle | 2 +- package_config.gradle | 4 + 9 files changed, 124 insertions(+), 32 deletions(-) create mode 100644 common/src/main/java/com/yunbao/common/bean/DomainUrl.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 3e053fb47..6f9cc04ff 100644 --- a/app/src/main/java/com/shayu/phonelive/activity/LauncherActivity.java +++ b/app/src/main/java/com/shayu/phonelive/activity/LauncherActivity.java @@ -29,6 +29,7 @@ import androidx.core.app.NotificationManagerCompat; import com.alibaba.android.arouter.facade.annotation.Route; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.blankj.utilcode.util.LogUtils; import com.shayu.phonelive.AppContext; import com.tencent.rtmp.ITXLivePlayListener; import com.tencent.rtmp.TXLiveBase; @@ -40,12 +41,16 @@ import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; import com.yunbao.common.bean.AdBean; import com.yunbao.common.bean.ConfigBean; +import com.yunbao.common.bean.DomainUrl; import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.custom.CircleProgress; import com.yunbao.common.event.DataUserInfoEvent; import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.http.API; import com.yunbao.common.http.CommonHttpConsts; import com.yunbao.common.http.CommonHttpUtil; +import com.yunbao.common.http.base.HttpCallback; +import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.manager.imrongcloud.RongcloudIMManager; @@ -223,8 +228,7 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL playAD(obj.getIntValue("type") == 0); } else { releaseVideo(); - LauncherActivity.this.startActivity(new Intent(LauncherActivity.this, EntryActivity.class)); - LauncherActivity.this.finish(); + forwardEntryActivity(); } } else { checkUidAndToken(); @@ -267,8 +271,7 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL IMLoginManager.get(this).upDataUserInfo(); } else { releaseVideo(); - this.startActivity(new Intent(this, EntryActivity.class)); - this.finish(); + forwardEntryActivity(); } } @@ -279,35 +282,75 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL * 跳转到首页 */ private void forwardMainActivity() { - releaseVideo(); - Intent intent = new Intent( - LauncherActivity.this, MainActivity.class); - intent.putExtra(Constants.SHOW_INVITE, false); + checkHomeUrl(() -> { + releaseVideo(); + Intent intent = new Intent( + LauncherActivity.this, MainActivity.class); + intent.putExtra(Constants.SHOW_INVITE, false); - if (getIntent().getStringExtra("liveid") != null) { - intent.putExtra("liveid", getIntent().getStringExtra("liveid")); - } - if (getIntent().getStringExtra("type") != null) { - intent.putExtra("type", getIntent().getStringExtra("type")); - } + if (getIntent().getStringExtra("liveid") != null) { + intent.putExtra("liveid", getIntent().getStringExtra("liveid")); + } + if (getIntent().getStringExtra("type") != null) { + intent.putExtra("type", getIntent().getStringExtra("type")); + } - if (getIntent().getStringExtra("activityUrl") != null) { - intent.putExtra("activityUrl", getIntent().getStringExtra("activityUrl")); - } - if (mImageViewList != null && mImageViewList.size() > 0) { - Log.i(TAG, "forwardMainActivity: " + mImageViewList.size()); - AdBean bean = mAdList.get(0); - if (bean != null && bean.getAnimation() == 1) { - intent.putExtra("ad_url", mAdList.get(0).getUrl()); - Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(LauncherActivity.this, mImageViewList.get(0), "ad_img_0").toBundle(); - LauncherActivity.this.startActivity(intent, bundle); + if (getIntent().getStringExtra("activityUrl") != null) { + intent.putExtra("activityUrl", getIntent().getStringExtra("activityUrl")); + } + if (mImageViewList != null && mImageViewList.size() > 0) { + Log.i(TAG, "forwardMainActivity: " + mImageViewList.size()); + AdBean bean = mAdList.get(0); + if (bean != null && bean.getAnimation() == 1) { + intent.putExtra("ad_url", mAdList.get(0).getUrl()); + Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(LauncherActivity.this, mImageViewList.get(0), "ad_img_0").toBundle(); + LauncherActivity.this.startActivity(intent, bundle); + } else { + LauncherActivity.this.startActivity(intent); + } } else { LauncherActivity.this.startActivity(intent); } - } else { - LauncherActivity.this.startActivity(intent); + finish(); + }); + } + + private void forwardEntryActivity() { + checkHomeUrl(() -> { + this.startActivity(new Intent(this, EntryActivity.class)); + this.finish(); + }); + + } + + /** + * 检查域名,链接包才需要动态替换域名 + * + * @param runnable 处理完成后调用runnable.run() + */ + private void checkHomeUrl(Runnable runnable) { + if (CommonAppConfig.IS_GOOGLE_PLAY != 0) { + runnable.run(); + return; } - finish(); + LiveNetManager.get(mContext) + .getDomainName(new HttpCallback() { + @Override + public void onSuccess(DomainUrl data) { + if (data != null) { + CommonAppConfig.HOST = data.getDomain_url(); + API.get().reloadUrl(); + } + runnable.run(); + } + + @Override + public void onError(String error) { + LogUtils.e(error); + runnable.run(); + } + }); + } @Override @@ -588,8 +631,7 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL forwardMainActivity(); } else { releaseVideo(); - this.startActivity(new Intent(this, EntryActivity.class)); - this.finish(); + forwardEntryActivity(); } } } diff --git a/common/src/main/java/com/yunbao/common/CommonAppConfig.java b/common/src/main/java/com/yunbao/common/CommonAppConfig.java index ddc9390bd..754af8683 100644 --- a/common/src/main/java/com/yunbao/common/CommonAppConfig.java +++ b/common/src/main/java/com/yunbao/common/CommonAppConfig.java @@ -30,7 +30,7 @@ import java.util.Map; */ public class CommonAppConfig { //域名 - public static final String HOST = getMetaDataString("SERVER_HOST"); + public static String HOST = getMetaDataString("SERVER_HOST"); //是否使用谷歌支付 public static final int IS_GOOGLE_PLAY = getMetaDataInt("IS_GOOGLE_PLAY"); //是否开启上报错误日志功能 diff --git a/common/src/main/java/com/yunbao/common/bean/DomainUrl.java b/common/src/main/java/com/yunbao/common/bean/DomainUrl.java new file mode 100644 index 000000000..281560e64 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/DomainUrl.java @@ -0,0 +1,17 @@ +package com.yunbao.common.bean; + +import com.alibaba.fastjson.annotation.JSONField; + +public class DomainUrl extends BaseModel{ + @SuppressWarnings("domain_url") + @JSONField(name = "domain_url") + String domain_url; + + public String getDomain_url() { + return domain_url; + } + + public void setDomain_url(String domain_url) { + this.domain_url = domain_url; + } +} diff --git a/common/src/main/java/com/yunbao/common/http/API.java b/common/src/main/java/com/yunbao/common/http/API.java index 48b662f75..acb71c0f7 100644 --- a/common/src/main/java/com/yunbao/common/http/API.java +++ b/common/src/main/java/com/yunbao/common/http/API.java @@ -48,6 +48,9 @@ public class API extends BaseApi { } return pdLiveApi; } + public void reloadUrl(){ + pdLiveApi=null; + } /** * 创建新的PDLiveApi,兼容部分接口需要控制是否添加UID参数 diff --git a/common/src/main/java/com/yunbao/common/http/HttpClient.java b/common/src/main/java/com/yunbao/common/http/HttpClient.java index 853ee5ac8..26851fe5b 100644 --- a/common/src/main/java/com/yunbao/common/http/HttpClient.java +++ b/common/src/main/java/com/yunbao/common/http/HttpClient.java @@ -45,6 +45,7 @@ public class HttpClient { } } } + sInstance.mUrl = CommonAppConfig.HOST + "/"; return sInstance; } diff --git a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java index da3e5976b..30777810a 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -19,6 +19,7 @@ import com.yunbao.common.bean.CoolConfig; import com.yunbao.common.bean.CreateSudRoomModel; import com.yunbao.common.bean.CustomSidebarInfoModel; import com.yunbao.common.bean.DiscountsModel; +import com.yunbao.common.bean.DomainUrl; import com.yunbao.common.bean.EnterRoomNewModel; import com.yunbao.common.bean.FaceBookUpModel; import com.yunbao.common.bean.FansCheckRed; @@ -112,6 +113,11 @@ import retrofit2.http.QueryMap; * PDLive网络接口访问 */ public interface PDLiveApi { + /** + * 主域名 + */ + @GET("/tongguoiphuoquyuming") + Observable> getDomainName(); /** * 用户手机号登录 * diff --git a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java index 7631dc829..252131e25 100644 --- a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java +++ b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java @@ -23,6 +23,7 @@ import com.yunbao.common.bean.CoolConfig; import com.yunbao.common.bean.CreateSudRoomModel; import com.yunbao.common.bean.CustomSidebarInfoModel; import com.yunbao.common.bean.DiscountsModel; +import com.yunbao.common.bean.DomainUrl; import com.yunbao.common.bean.EnterRoomNewModel; import com.yunbao.common.bean.FansCheckRed; import com.yunbao.common.bean.FansGroupGiftPack; @@ -135,7 +136,25 @@ public class LiveNetManager { } return manager; } - + public void getDomainName(HttpCallback callback) { + API.get().pdLiveApi(mContext) + .getDomainName() + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(listResponseModel -> { + if (callback != null) { + callback.onSuccess(listResponseModel.getData().getInfo()); + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + throwable.printStackTrace(); + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } /** * 获取用户贵族喇叭的数量 * diff --git a/config.gradle b/config.gradle index b7a23263f..8c47dfd65 100644 --- a/config.gradle +++ b/config.gradle @@ -13,7 +13,7 @@ ext { serverHost : "https://api.poyoshow.com", buildTime : new Date().format("MM-dd HH:mm", TimeZone.getTimeZone("GMT+8")), - testServerHost : "https://api.poyoshow.com", + testServerHost : "https://ceshi.poyoshow.com", //百度语音识别 diff --git a/package_config.gradle b/package_config.gradle index 092fb7480..aff561c31 100644 --- a/package_config.gradle +++ b/package_config.gradle @@ -14,6 +14,7 @@ android { serverHost : rootProject.ext.manifestPlaceholders.testServerHost, isGooglePlay : 0, isUploadLog : true, + swReleaseModel: false, isPluginModel: rootProject.ext.manifestPlaceholders.isPluginModel ] } @@ -32,6 +33,7 @@ android { serverHost : rootProject.ext.manifestPlaceholders.testServerHost, isGooglePlay : 3, isUploadLog : true, + swReleaseModel: false, isPluginModel: rootProject.ext.manifestPlaceholders.isPluginModel, facebook_app_id : "938330614686044", facebook_client_token : "b1b574a2cdf0ced1ae5df7274636f65d", @@ -59,6 +61,7 @@ android { serverHost : rootProject.ext.manifestPlaceholders.testServerHost, isGooglePlay : 1, isUploadLog : true, + swReleaseModel: false, isPluginModel: rootProject.ext.manifestPlaceholders.isPluginModel, facebook_app_id : "938330614686044", facebook_client_token : "b1b574a2cdf0ced1ae5df7274636f65d", @@ -86,6 +89,7 @@ android { serverHost : rootProject.ext.manifestPlaceholders.testServerHost, isGooglePlay : 2, isUploadLog : true, + swReleaseModel: false, isPluginModel: rootProject.ext.manifestPlaceholders.isPluginModel ] }