新增启动APP时获取动态域名判断

新增测试服URL
This commit is contained in:
zlzw 2024-10-28 14:29:22 +08:00
parent 7b256ff3c4
commit 97c93ea108
9 changed files with 124 additions and 32 deletions

View File

@ -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<DomainUrl>() {
@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();
}
}
}

View File

@ -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");
//是否开启上报错误日志功能

View File

@ -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;
}
}

View File

@ -48,6 +48,9 @@ public class API extends BaseApi {
}
return pdLiveApi;
}
public void reloadUrl(){
pdLiveApi=null;
}
/**
* 创建新的PDLiveApi兼容部分接口需要控制是否添加UID参数

View File

@ -45,6 +45,7 @@ public class HttpClient {
}
}
}
sInstance.mUrl = CommonAppConfig.HOST + "/";
return sInstance;
}

View File

@ -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<ResponseModel<DomainUrl>> getDomainName();
/**
* 用户手机号登录
*

View File

@ -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<DomainUrl> callback) {
API.get().pdLiveApi(mContext)
.getDomainName()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(listResponseModel -> {
if (callback != null) {
callback.onSuccess(listResponseModel.getData().getInfo());
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
throwable.printStackTrace();
if (callback != null) {
callback.onError(mContext.getString(R.string.net_error));
}
}
}).isDisposed();
}
/**
* 获取用户贵族喇叭的数量
*

View File

@ -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",
//

View File

@ -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
]
}