update: 优化 Banner 刷新逻辑

deeplink
胡宇飞 2024-04-17 21:43:58 +08:00
parent caffa7f5fe
commit 98010b4b95
1 changed files with 19 additions and 12 deletions

View File

@ -140,19 +140,13 @@ namespace Guru
{
if (paused)
{
if (IsBannerVisible)
{
_isBannerSetToShow = true;
HideBanner();
}
_isBannerSetToShow = true;
if(IsBannerVisible) SetBannerAutoRefresh(false);
}
else
{
if (_isBannerSetToShow)
{
_isBannerSetToShow = false;
if(!IsBannerVisible) ShowBanner();
}
_isBannerSetToShow = false;
if(IsBannerVisible) SetBannerAutoRefresh(true);
}
}
@ -294,6 +288,19 @@ namespace Guru
_badsloadStartTime = Time.realtimeSinceStartup;
OnBannerLoaded?.Invoke();
}
public virtual void SetBannerAutoRefresh(bool value = true, string adUnitId = "")
{
if(string.IsNullOrEmpty(adUnitId)) adUnitId = GetBannerID();
if (value)
{
MaxSdk.StartBannerAutoRefresh(adUnitId);
}
else
{
MaxSdk.StopBannerAutoRefresh(adUnitId);
}
}
/// <summary>
/// 显示 Banner
@ -306,7 +313,7 @@ namespace Guru
MaxSdk.ShowBanner(adUnitId);
MaxSdk.SetBannerBackgroundColor(adUnitId, _backColor);
OnBannerImpEvent(adUnitId);
MaxSdk.StartBannerAutoRefresh(adUnitId);
SetBannerAutoRefresh(true, adUnitId);
_bannerVisible = true;
}
@ -316,7 +323,7 @@ namespace Guru
public virtual void HideBanner()
{
MaxSdk.HideBanner(GetBannerID());
MaxSdk.StopBannerAutoRefresh(GetBannerID());
SetBannerAutoRefresh(true, GetBannerID());
_bannerVisible = false;
}