Merge branch 'feat/GHZSCY-5594-pr' into 'dev'
feat:启动广告图相关优化—客户端 https://jira.shanqu.cc/browse/GHZSCY-5594 See merge request halo/android/assistant-android!1776
This commit is contained in:
@ -43,6 +43,7 @@ import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.lifecycle.ViewModelProviders;
|
||||
|
||||
import com.gh.ad.AdDelegateHelper;
|
||||
import com.gh.ad.SplashAdVideoView;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.filter.RegionSettingHelper;
|
||||
import com.gh.common.history.HistoryDatabase;
|
||||
@ -129,7 +130,6 @@ import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.SingleSource;
|
||||
@ -148,7 +148,7 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
public static final String SHOW_AD = "show_ad";
|
||||
public static final int COUNTDOWN_AD = 100;
|
||||
public static final int COUNTDOWN_MAX_COUNT = 3;
|
||||
private int mCountdownMaxCount = 3;
|
||||
private int mCountdownCount = 0;
|
||||
|
||||
private static final String CURRENT_PAGE = "current_page";
|
||||
@ -508,6 +508,7 @@ public class MainActivity extends BaseActivity {
|
||||
float screenHeightInDp = DisplayUtils.px2dip(this, screenHeightInPx);
|
||||
|
||||
if (startAdContainer != null && sdkStartAdContainer != null && adsFl != null) {
|
||||
mCountdownMaxCount = AdDelegateHelper.INSTANCE.getSplashAdDisplayInterval();
|
||||
AdDelegateHelper.requestSplashAd(
|
||||
this,
|
||||
screenWidthInPx,
|
||||
@ -537,7 +538,7 @@ public class MainActivity extends BaseActivity {
|
||||
super.handleMessage(msg);
|
||||
if (msg.what == COUNTDOWN_AD) {
|
||||
mCountdownCount++;
|
||||
if (COUNTDOWN_MAX_COUNT < mCountdownCount) {
|
||||
if (mCountdownMaxCount < mCountdownCount) {
|
||||
AdDelegateHelper.INSTANCE.setShowingSplashAd(false);
|
||||
hideSplashAd();
|
||||
|
||||
@ -557,7 +558,7 @@ public class MainActivity extends BaseActivity {
|
||||
}
|
||||
} else {
|
||||
TextView jumpBtn = findViewById(R.id.jumpBtn);
|
||||
jumpBtn.setText(String.format(Locale.CHINA, "跳过 %d", COUNTDOWN_MAX_COUNT - mCountdownCount));
|
||||
jumpBtn.setText(getString(R.string.splash_jump, mCountdownMaxCount - mCountdownCount));
|
||||
Message newMsg = Message.obtain();
|
||||
newMsg.what = COUNTDOWN_AD;
|
||||
newMsg.obj = msg.obj;
|
||||
@ -585,6 +586,11 @@ public class MainActivity extends BaseActivity {
|
||||
getIntent().putExtra(SHOW_AD, false);
|
||||
View startAdContainer = findViewById(R.id.startAdContainer);
|
||||
if (startAdContainer != null) {
|
||||
// 如果有播放开屏视频广告,需要及时释放
|
||||
SplashAdVideoView adVideoView = startAdContainer.findViewById(R.id.ad_video);
|
||||
if (adVideoView != null) {
|
||||
adVideoView.clearAll();
|
||||
}
|
||||
startAdContainer.setVisibility(View.GONE);
|
||||
ExtensionsKt.removeFromParent(startAdContainer, true);
|
||||
}
|
||||
@ -800,7 +806,7 @@ public class MainActivity extends BaseActivity {
|
||||
public void onFailure(@Nullable HttpException e) {
|
||||
super.onFailure(e);
|
||||
try {
|
||||
ErrorHelper.handleErrorWithCustomizedHandler(MainActivity.this, e.response().errorBody().string(), false, "", "", "内容实名", null, null, code -> {
|
||||
ErrorHelper.handleErrorWithCustomizedHandler(MainActivity.this, e.response().errorBody().string(), false, "", "", "内容实名", null, null, code -> {
|
||||
if (code == 404001) {
|
||||
if (mShouldShowAd) {
|
||||
AppExecutor.getUiExecutor().executeWithDelay(() -> {
|
||||
|
||||
Reference in New Issue
Block a user