feat: 广告管理相关优化—客户端 https://jira.shanqu.cc/browse/GHZS-3791

This commit is contained in:
叶子维
2023-12-13 09:31:58 +08:00
parent 3e38830480
commit 19afb7221d
25 changed files with 604 additions and 166 deletions

View File

@ -155,8 +155,8 @@ public class MainActivity extends BaseActivity {
public static final String SWITCH_TO_VIDEO = "switch_to_video";
public static final String SHOW_AD = "show_ad";
public static final int COUNTDOWN_AD = 100;
private static final int COUNTDOWN_MAX_COUNT = 3;
private int countdownCount = 0;
public static final int COUNTDOWN_MAX_COUNT = 3;
private int mCountdownCount = 0;
private static final String CURRENT_PAGE = "current_page";
@ -177,7 +177,6 @@ public class MainActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
mShouldShowAd = getIntent().getBooleanExtra(SHOW_AD, false) && savedInstanceState == null;
HaloApp.getInstance().isAlreadyUpAndRunning = true;
mMainWrapperViewModel = new ViewModelProvider(this, new MainWrapperViewModel.Factory(HaloApp.getInstance()))
@ -510,7 +509,7 @@ public class MainActivity extends BaseActivity {
* 显示开屏广告
*/
private void showSplashAd() {
if (AdDelegateHelper.INSTANCE.shouldShowStartUpAd()) {
if (AdDelegateHelper.INSTANCE.shouldShowStartUpAd(false)) {
ViewGroup startAdContainer = findViewById(R.id.startAdContainer);
ViewGroup sdkStartAdContainer = findViewById(R.id.sdkStartAdContainer);
FrameLayout adsFl = findViewById(R.id.adsFl);
@ -532,6 +531,7 @@ public class MainActivity extends BaseActivity {
sdkStartAdContainer,
adsFl,
(BaseHandler) mBaseHandler,
false,
() -> {
hideSplashAd();
return null;
@ -546,12 +546,13 @@ public class MainActivity extends BaseActivity {
protected void handleMessage(Message msg) {
super.handleMessage(msg);
if (msg.what == COUNTDOWN_AD) {
countdownCount++;
TextView jumpBtn = findViewById(R.id.jumpBtn);
jumpBtn.setText(String.format(Locale.CHINA, "跳过 %d", COUNTDOWN_MAX_COUNT - countdownCount));
if (COUNTDOWN_MAX_COUNT < countdownCount) {
mCountdownCount++;
if (COUNTDOWN_MAX_COUNT < mCountdownCount) {
AdDelegateHelper.INSTANCE.setShowingSplashAd(false);
hideSplashAd();
} else {
TextView jumpBtn = findViewById(R.id.jumpBtn);
jumpBtn.setText(String.format(Locale.CHINA, "跳过 %d", COUNTDOWN_MAX_COUNT - mCountdownCount));
mBaseHandler.sendEmptyMessageDelayed(COUNTDOWN_AD, 1000);
}
}