|
|
@@ -95,7 +95,7 @@ public class AtmobAdHelper {
|
|
|
private long startTime;
|
|
|
|
|
|
@Override
|
|
|
- public void onShow() {
|
|
|
+ public void onRewardAdShow() {
|
|
|
AtmobLog.d(TAG, "showVideo(%d) onShow.", adFuncId);
|
|
|
adLoadingDialog.forceDismiss();
|
|
|
getVideoToken();
|
|
|
@@ -142,14 +142,14 @@ public class AtmobAdHelper {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onClose() {
|
|
|
+ public void onRewardAdClosed() {
|
|
|
AtmobLog.d(TAG, "showVideo(%d) onClose.", adFuncId);
|
|
|
dispose();
|
|
|
if (listener != null) {
|
|
|
if (isRewarded) {
|
|
|
listener.onRewarded(token);
|
|
|
}
|
|
|
- listener.onClose();
|
|
|
+ listener.onRewardAdClosed();
|
|
|
}
|
|
|
|
|
|
int duration = (int) ((System.currentTimeMillis() - startTime) / 1000);
|
|
|
@@ -157,20 +157,20 @@ public class AtmobAdHelper {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onFail(String s) {
|
|
|
- AtmobLog.e(TAG, "showVideo(%d) onFail: %s.", adFuncId, s);
|
|
|
+ public void onRewardAdShowFail(AdError adError) {
|
|
|
+ super.onRewardAdShowFail(adError);
|
|
|
+ AtmobLog.e(TAG, "showVideo(%d) onFail: %s.", adFuncId, adError);
|
|
|
dispose();
|
|
|
if (listener != null) {
|
|
|
- listener.onFail(s);
|
|
|
+ listener.onRewardAdShowFail(adError);
|
|
|
}
|
|
|
- adLoadingDialog.dismiss();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onClick() {
|
|
|
+ public void onRewardClick() {
|
|
|
AtmobLog.d(TAG, "showVideo(%d) onClick.", adFuncId);
|
|
|
if (listener != null) {
|
|
|
- listener.onClick();
|
|
|
+ listener.onRewardClick();
|
|
|
}
|
|
|
|
|
|
AtmobAdHelper.onAdClick(AdConstants.RewardVideo, atmobRewardAd.getEcpmInfo());
|
|
|
@@ -185,6 +185,16 @@ public class AtmobAdHelper {
|
|
|
AtmobAdHelper.onAdLoaded(AdConstants.RewardVideo, atmobRewardAd.getEcpmInfo());
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void onLoadFailed(AdError adError) {
|
|
|
+ super.onLoadFailed(adError);
|
|
|
+ AtmobLog.e(TAG, "showVideo(%d) onLoadFailed: %s.", adFuncId, adError);
|
|
|
+ adLoadingDialog.forceDismiss();
|
|
|
+ if (listener != null) {
|
|
|
+ listener.onLoadFailed(adError);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void dispose() {
|
|
|
if (showSkipButtonDisposable != null) {
|
|
|
showSkipButtonDisposable.dispose();
|
|
|
@@ -213,7 +223,8 @@ public class AtmobAdHelper {
|
|
|
AdLoadingDialog adLoadingDialog = new AdLoadingDialog(ActivityUtil.getTopActivity(), R.layout.dialog_simulate_ad, R.style.Theme_Common_Dialog);
|
|
|
adLoadingDialog.show();
|
|
|
if (listener != null) {
|
|
|
- listener.onShow();
|
|
|
+ listener.onAdLoaded();
|
|
|
+ listener.onRewardAdShow();
|
|
|
}
|
|
|
handler.postDelayed(() -> {
|
|
|
adLoadingDialog.dismiss();
|
|
|
@@ -221,7 +232,7 @@ public class AtmobAdHelper {
|
|
|
listener.onRewarded("");
|
|
|
}
|
|
|
if (listener != null) {
|
|
|
- listener.onClose();
|
|
|
+ listener.onRewardAdClosed();
|
|
|
}
|
|
|
}, 3000);
|
|
|
}
|
|
|
@@ -346,7 +357,7 @@ public class AtmobAdHelper {
|
|
|
View nativeView = atmobNativeAd.getNativeView();
|
|
|
if (nativeView != null) {
|
|
|
viewGroup.removeAllViews();
|
|
|
- viewGroup.addView(nativeView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
|
|
+ viewGroup.addView(nativeView, new ViewGroup.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
|
|
}
|
|
|
|
|
|
AtmobAdHelper.onAdLoaded(AdConstants.NativeUnified, atmobNativeAd.getEcpmInfo());
|
|
|
@@ -395,6 +406,9 @@ public class AtmobAdHelper {
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
+ if (viewGroup != null) {
|
|
|
+ viewGroup.removeAllViews();
|
|
|
+ }
|
|
|
Runnable showSplashRunnable = () -> {
|
|
|
AtmobSplashAd atmobSplashAd = new AtmobSplashAd(ActivityUtil.getTopActivity(), String.valueOf(adFuncId));
|
|
|
SplashListenerAdapter splashListenerAdapter = new SplashListenerAdapter() {
|
|
|
@@ -446,7 +460,14 @@ public class AtmobAdHelper {
|
|
|
public void onAdLoaded() {
|
|
|
super.onAdLoaded();
|
|
|
AtmobLog.d(TAG, "showSplash(%d) onAdLoaded.", adFuncId);
|
|
|
- atmobSplashAd.showSplashAd(viewGroup);
|
|
|
+ if (viewGroup != null) {
|
|
|
+ viewGroup.removeAllViews();
|
|
|
+ atmobSplashAd.showSplashAd(viewGroup);
|
|
|
+ } else {
|
|
|
+ if (listener != null) {
|
|
|
+ listener.action();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
AtmobAdHelper.onAdLoaded(AdConstants.Splash, atmobSplashAd.getEcpmInfo());
|
|
|
}
|