update: 优化 Banner 刷新逻辑
parent
caffa7f5fe
commit
98010b4b95
|
|
@ -139,20 +139,14 @@ namespace Guru
|
|||
public void OnAppPaused(bool paused)
|
||||
{
|
||||
if (paused)
|
||||
{
|
||||
if (IsBannerVisible)
|
||||
{
|
||||
_isBannerSetToShow = true;
|
||||
HideBanner();
|
||||
}
|
||||
if(IsBannerVisible) SetBannerAutoRefresh(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_isBannerSetToShow)
|
||||
{
|
||||
_isBannerSetToShow = false;
|
||||
if(!IsBannerVisible) ShowBanner();
|
||||
}
|
||||
if(IsBannerVisible) SetBannerAutoRefresh(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -295,6 +289,19 @@ namespace Guru
|
|||
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
|
||||
/// </summary>
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue