diff --git a/Android/Java/app/src/main/java/com/ironsource/ironsourcesdkdemo/DemoActivity.java b/Android/Java/app/src/main/java/com/ironsource/ironsourcesdkdemo/DemoActivity.java index 76a696e4..0684450e 100644 --- a/Android/Java/app/src/main/java/com/ironsource/ironsourcesdkdemo/DemoActivity.java +++ b/Android/Java/app/src/main/java/com/ironsource/ironsourcesdkdemo/DemoActivity.java @@ -14,16 +14,16 @@ import androidx.multidex.BuildConfig; import com.ironsource.mediationsdk.IronSource; import com.ironsource.mediationsdk.integration.IntegrationHelper; -import com.ironsource.mediationsdk.model.Placement; import com.ironsource.mediationsdk.utils.IronSourceUtils; import com.unity3d.mediation.LevelPlay; import com.unity3d.mediation.LevelPlayAdSize; import com.unity3d.mediation.LevelPlayInitRequest; import com.unity3d.mediation.banner.LevelPlayBannerAdView; import com.unity3d.mediation.interstitial.LevelPlayInterstitialAd; +import com.unity3d.mediation.rewarded.LevelPlayReward; +import com.unity3d.mediation.rewarded.LevelPlayRewardedAd; import java.util.Arrays; -import java.util.List; public class DemoActivity extends Activity implements DemoActivityListener { @@ -33,18 +33,21 @@ public class DemoActivity extends Activity implements DemoActivityListener { public static final String APP_KEY = "85460dcd"; // Replace with your ad unit ids as available in the LevelPlay dashboard - public static final String INTERSTITIAL_AD_UNIT_ID = "aeyqi3vqlv6o8sh9"; - public static final String BANNER_AD_UNIT_ID = "thnfvcsog13bhn08"; + public static final String INTERSTITIAL_AD_AD_UNIT_ID = "aeyqi3vqlv6o8sh9"; + public static final String REWARDED_AD_AD_UNIT_ID = "76yy3nay3ceui2a3"; + public static final String BANNER_AD_AD_UNIT_ID = "thnfvcsog13bhn08"; - private Button rewardedVideoShowButton; - private Placement rewardedVideoPlacementInfo; + private Button rewardedAdLoadButton; + private Button rewardedAdShowButton; + private LevelPlayRewardedAd rewardedAd; + private LevelPlayReward reward; - private Button interstitialLoadButton; - private Button interstitialShowButton; + private Button interstitialAdLoadButton; + private Button interstitialAdShowButton; private LevelPlayInterstitialAd interstitialAd; - private Button bannerLoadButton; - private FrameLayout bannerParentLayout; + private Button bannerAdLoadButton; + private FrameLayout bannerAdParentLayout; private LevelPlayBannerAdView bannerAd; //region Lifecycle Methods @@ -82,15 +85,16 @@ protected void onDestroy() { //region Initialization Methods private void setupUI() { - rewardedVideoShowButton = findViewById(R.id.rewarded_video_show_button); - interstitialLoadButton = findViewById(R.id.interstitial_load_button); - interstitialShowButton = findViewById(R.id.interstitial_show_button); - bannerLoadButton = findViewById(R.id.banner_load_button); + rewardedAdLoadButton = findViewById(R.id.rewarded_ad_load_button); + rewardedAdShowButton = findViewById(R.id.rewarded_ad_show_button); + interstitialAdLoadButton = findViewById(R.id.interstitial_ad_load_button); + interstitialAdShowButton = findViewById(R.id.interstitial_ad_show_button); + bannerAdLoadButton = findViewById(R.id.banner_ad_load_button); TextView versionTextView = findViewById(R.id.version_txt); versionTextView.setText(String.format("%s %s", getResources().getString(R.string.version), IronSourceUtils.getSDKVersion())); - bannerParentLayout = findViewById(R.id.banner_frame_layout); + bannerAdParentLayout = findViewById(R.id.banner_ad_frame_layout); } private void setupIronSourceSdk() { @@ -100,26 +104,12 @@ private void setupIronSourceSdk() { IntegrationHelper.validateIntegration(this); } - // Before initializing any of our legacy products (Rewarded video, Interstitial or Banner) you must set - // their listeners. Take a look at each of these listeners method and you will see that they each implement a product - // protocol. This is our way of letting you know what's going on, and if you don't set the listeners - // we will not be able to communicate with you. - // We're passing 'this' to our listeners because we want - // to be able to enable/disable buttons to match ad availability. - IronSource.setLevelPlayRewardedVideoListener(new DemoRewardedVideoAdListener(this)); + // Register a listener for all impressions within the current session IronSource.addImpressionDataListener(new DemoImpressionDataListener()); - // After setting the listeners you can go ahead and initialize the SDK. - // Once the initialization callback is returned you can start loading your ads - - // Init the SDK when implementing the Multiple Ad Units Interstitial and Banner API, and Rewarded using legacy APIs - List legacyAdFormats = Arrays.asList(LevelPlay.AdFormat.REWARDED); - LevelPlayInitRequest initRequest = new LevelPlayInitRequest.Builder(APP_KEY) - .withLegacyAdFormats(legacyAdFormats) .build(); - - log("init ironSource SDK with appKey: " + APP_KEY); + log("init levelPlay SDK with appKey: " + APP_KEY); LevelPlay.init(this, initRequest, new DemoInitializationListener(this)); // Scroll down the file to find out what happens when you tap a button... @@ -128,13 +118,13 @@ private void setupIronSourceSdk() { //region Interstitial Methods public void createInterstitialAd() { - interstitialAd = new LevelPlayInterstitialAd(INTERSTITIAL_AD_UNIT_ID); + interstitialAd = new LevelPlayInterstitialAd(INTERSTITIAL_AD_AD_UNIT_ID); interstitialAd.setListener(new DemoInterstitialAdListener(this)); - setEnablementForButton(DemoButtonIdentifiers.LOAD_INTERSTITIAL_BUTTON_IDENTIFIER, true); + setEnablementForButton(DemoButtonIdentifiers.LOAD_INTERSTITIAL_AD_BUTTON_IDENTIFIER, true); } - public void loadInterstitialButtonTapped(View view) { + public void loadInterstitialAdButtonTapped(View view) { // This will load an Interstitial ad if (interstitialAd != null) { log("loadAd for interstitial"); @@ -142,7 +132,7 @@ public void loadInterstitialButtonTapped(View view) { } } - public void showInterstitialButtonTapped(View view) { + public void showInterstitialAdButtonTapped(View view) { // It is advised to make sure there is available ad that isn't capped before attempting to show it if (interstitialAd != null && interstitialAd.isAdReady()) { // This will present the Interstitial. @@ -156,6 +146,56 @@ public void showInterstitialButtonTapped(View view) { } //endregion + //region Rewarded Methods + public void createRewardedAd() { + rewardedAd = new LevelPlayRewardedAd(REWARDED_AD_AD_UNIT_ID); + rewardedAd.setListener(new DemoRewardedAdListener(this)); + + setEnablementForButton(DemoButtonIdentifiers.LOAD_REWARDED_AD_BUTTON_IDENTIFIER, true); + } + + public void loadRewardedAdButtonTapped(View view) { + // This will load a Rewarded ad + if (rewardedAd != null) { + log("loadAd for rewarded"); + rewardedAd.loadAd(); + } + } + + public void showRewardedAdButtonTapped(View view) { + // It is advised to make sure there is available ad that isn't capped before attempting to show it + if (rewardedAd != null && rewardedAd.isAdReady()) { + + log("showAd for rewarded"); + rewardedAd.showAd(this); + } else { + // load a new ad before calling show + } + } + + @Override + public void setReward(LevelPlayReward reward) { + // Setting the reward, an object that contains the reward name and amount + this.reward = reward; + } + + @Override + public void showRewardDialog() { + // Showing a graphical indication of the reward name and amount after the user closed the rewarded video ad + if (this.reward != null) { + new AlertDialog.Builder(DemoActivity.this) + .setPositiveButton("ok", (dialog, id) -> dialog.dismiss()) + .setTitle(getResources().getString(R.string.rewarded_dialog_header)) + .setMessage(getResources().getString(R.string.rewarded_dialog_message) + " " + this.reward.getAmount() + " " + this.reward.getName()) + .setCancelable(false) + .create() + .show(); + + this.reward = null; + } + } + //endregion + //region Banner Methods public void createBannerAd() { // choose banner size @@ -171,7 +211,7 @@ public void createBannerAd() { // Create the banner view and set the ad unit id and ad size if (adSize != null) { - bannerAd = new LevelPlayBannerAdView(this, BANNER_AD_UNIT_ID); + bannerAd = new LevelPlayBannerAdView(this, BANNER_AD_AD_UNIT_ID); bannerAd.setAdSize(adSize); // set the banner listener @@ -179,15 +219,15 @@ public void createBannerAd() { // add LevelPlayBannerAdView to your container FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT); - bannerParentLayout.addView(bannerAd, 0, layoutParams); - setEnablementForButton(DemoButtonIdentifiers.LOAD_BANNER_BUTTON_IDENTIFIER, true); + bannerAdParentLayout.addView(bannerAd, 0, layoutParams); + setEnablementForButton(DemoButtonIdentifiers.LOAD_BANNER_AD_BUTTON_IDENTIFIER, true); } else { log( "Failed to create banner ad"); } } - public void loadBannerButtonTapped(View view) { + public void loadBannerAdButtonTapped(View view) { // Load a banner ad. If the "refresh" option is enabled in the LevelPlay dashboard settings, the banner will automatically refresh at the specified interval, // otherwise, the banner will remain static until manually destroyed if (bannerAd != null) { @@ -198,43 +238,7 @@ public void loadBannerButtonTapped(View view) { @Override public void setBannerViewVisibility(int visibility) { - this.bannerParentLayout.setVisibility(visibility); - } - //endregion - - //region Rewarded Video Methods - public void showRewardedVideoButtonTapped(View view) { - // It is advised to make sure there is available ad before attempting to show an ad - if (IronSource.isRewardedVideoAvailable()) { - // This will present the Rewarded Video. - - log("showRewardedVideo"); - IronSource.showRewardedVideo(); - } else { - // wait for the availability of rewarded video to change to true before calling show - } - } - - @Override - public void setPlacementInfo(Placement placementInfo) { - // Setting the rewarded video placement info, an object that contains the placement's reward name and amount - this.rewardedVideoPlacementInfo = placementInfo; - } - - @Override - public void showRewardDialog() { - // Showing a graphical indication of the reward name and amount after the user closed the rewarded video ad - if (this.rewardedVideoPlacementInfo != null) { - new AlertDialog.Builder(DemoActivity.this) - .setPositiveButton("ok", (dialog, id) -> dialog.dismiss()) - .setTitle(getResources().getString(R.string.rewarded_dialog_header)) - .setMessage(getResources().getString(R.string.rewarded_dialog_message) + " " + this.rewardedVideoPlacementInfo.getRewardAmount() + " " + this.rewardedVideoPlacementInfo.getRewardName()) - .setCancelable(false) - .create() - .show(); - - this.rewardedVideoPlacementInfo = null; - } + this.bannerAdParentLayout.setVisibility(visibility); } //endregion @@ -246,18 +250,20 @@ public void setEnablementForButton(DemoButtonIdentifiers identifier, boolean ena Button buttonToModify = null; switch (identifier) { - case SHOW_REWARDED_VIDEO_BUTTON_IDENTIFIER: - text = enable ? getResources().getString(R.string.show) : getResources().getString(R.string.initializing); - buttonToModify = rewardedVideoShowButton; + case LOAD_REWARDED_AD_BUTTON_IDENTIFIER: + buttonToModify = rewardedAdLoadButton; + break; + case SHOW_REWARDED_AD_BUTTON_IDENTIFIER: + buttonToModify = rewardedAdShowButton; break; - case LOAD_INTERSTITIAL_BUTTON_IDENTIFIER: - buttonToModify = interstitialLoadButton; + case LOAD_INTERSTITIAL_AD_BUTTON_IDENTIFIER: + buttonToModify = interstitialAdLoadButton; break; - case SHOW_INTERSTITIAL_BUTTON_IDENTIFIER: - buttonToModify = interstitialShowButton; + case SHOW_INTERSTITIAL_AD_BUTTON_IDENTIFIER: + buttonToModify = interstitialAdShowButton; break; - case LOAD_BANNER_BUTTON_IDENTIFIER: - buttonToModify = bannerLoadButton; + case LOAD_BANNER_AD_BUTTON_IDENTIFIER: + buttonToModify = bannerAdLoadButton; break; } diff --git a/Android/Java/app/src/main/java/com/ironsource/ironsourcesdkdemo/DemoActivityListener.java b/Android/Java/app/src/main/java/com/ironsource/ironsourcesdkdemo/DemoActivityListener.java index e57c6a15..a164f90b 100644 --- a/Android/Java/app/src/main/java/com/ironsource/ironsourcesdkdemo/DemoActivityListener.java +++ b/Android/Java/app/src/main/java/com/ironsource/ironsourcesdkdemo/DemoActivityListener.java @@ -1,13 +1,13 @@ package com.ironsource.ironsourcesdkdemo; -import com.ironsource.mediationsdk.model.Placement; +import com.unity3d.mediation.rewarded.LevelPlayReward; interface DemoActivityListener { void setEnablementForButton(DemoButtonIdentifiers buttonIdentifier, boolean enable); void setBannerViewVisibility(int visibility); - void setPlacementInfo(Placement placementInfo); + void setReward(LevelPlayReward reward); void showRewardDialog(); void createInterstitialAd(); void createBannerAd(); - + void createRewardedAd(); } \ No newline at end of file diff --git a/Android/Java/app/src/main/java/com/ironsource/ironsourcesdkdemo/DemoBannerAdListener.java b/Android/Java/app/src/main/java/com/ironsource/ironsourcesdkdemo/DemoBannerAdListener.java index 54c860b8..90b815d0 100644 --- a/Android/Java/app/src/main/java/com/ironsource/ironsourcesdkdemo/DemoBannerAdListener.java +++ b/Android/Java/app/src/main/java/com/ironsource/ironsourcesdkdemo/DemoBannerAdListener.java @@ -23,7 +23,7 @@ public DemoBannerAdListener(DemoActivityListener listener) { public void onAdLoaded(@NonNull LevelPlayAdInfo adInfo) { logCallbackName(TAG, "adInfo = " + adInfo); this.listener.setBannerViewVisibility(View.VISIBLE); - this.listener.setEnablementForButton(DemoButtonIdentifiers.LOAD_BANNER_BUTTON_IDENTIFIER, false); + this.listener.setEnablementForButton(DemoButtonIdentifiers.LOAD_BANNER_AD_BUTTON_IDENTIFIER, false); } /** diff --git a/Android/Java/app/src/main/java/com/ironsource/ironsourcesdkdemo/DemoButtonIdentifiers.java b/Android/Java/app/src/main/java/com/ironsource/ironsourcesdkdemo/DemoButtonIdentifiers.java index 5d43d650..2c9c3f4c 100644 --- a/Android/Java/app/src/main/java/com/ironsource/ironsourcesdkdemo/DemoButtonIdentifiers.java +++ b/Android/Java/app/src/main/java/com/ironsource/ironsourcesdkdemo/DemoButtonIdentifiers.java @@ -1,8 +1,9 @@ package com.ironsource.ironsourcesdkdemo; enum DemoButtonIdentifiers { - SHOW_REWARDED_VIDEO_BUTTON_IDENTIFIER, - LOAD_INTERSTITIAL_BUTTON_IDENTIFIER, - SHOW_INTERSTITIAL_BUTTON_IDENTIFIER, - LOAD_BANNER_BUTTON_IDENTIFIER + LOAD_REWARDED_AD_BUTTON_IDENTIFIER, + SHOW_REWARDED_AD_BUTTON_IDENTIFIER, + LOAD_INTERSTITIAL_AD_BUTTON_IDENTIFIER, + SHOW_INTERSTITIAL_AD_BUTTON_IDENTIFIER, + LOAD_BANNER_AD_BUTTON_IDENTIFIER } diff --git a/Android/Java/app/src/main/java/com/ironsource/ironsourcesdkdemo/DemoInitializationListener.java b/Android/Java/app/src/main/java/com/ironsource/ironsourcesdkdemo/DemoInitializationListener.java index 7a09fb38..38249f0f 100644 --- a/Android/Java/app/src/main/java/com/ironsource/ironsourcesdkdemo/DemoInitializationListener.java +++ b/Android/Java/app/src/main/java/com/ironsource/ironsourcesdkdemo/DemoInitializationListener.java @@ -15,14 +15,14 @@ public DemoInitializationListener(DemoActivityListener listener) { this.listener = listener; } - /** triggered when the initialization is completed successfully. After you receive this indication, ads can be loaded @param configuration The configuration */ @Override - public void onInitSuccess(LevelPlayConfiguration configuration) { + public void onInitSuccess(@NonNull LevelPlayConfiguration configuration) { logCallbackName(TAG, ""); + this.listener.createRewardedAd(); this.listener.createInterstitialAd(); this.listener.createBannerAd(); } @@ -34,7 +34,6 @@ the configuration was not retrieved successfully and ads cannot be loaded. It is @Override public void onInitFailed(@NonNull LevelPlayInitError error) { logCallbackName(TAG, "error = " + error); - } } diff --git a/Android/Java/app/src/main/java/com/ironsource/ironsourcesdkdemo/DemoInterstitialAdListener.java b/Android/Java/app/src/main/java/com/ironsource/ironsourcesdkdemo/DemoInterstitialAdListener.java index 77241e13..1364992e 100644 --- a/Android/Java/app/src/main/java/com/ironsource/ironsourcesdkdemo/DemoInterstitialAdListener.java +++ b/Android/Java/app/src/main/java/com/ironsource/ironsourcesdkdemo/DemoInterstitialAdListener.java @@ -23,7 +23,7 @@ public DemoInterstitialAdListener(DemoActivityListener listener) { @Override public void onAdLoaded(@NonNull LevelPlayAdInfo adInfo) { logCallbackName(TAG, "adInfo = " + adInfo); - this.listener.setEnablementForButton(DemoButtonIdentifiers.SHOW_INTERSTITIAL_BUTTON_IDENTIFIER, true); + this.listener.setEnablementForButton(DemoButtonIdentifiers.SHOW_INTERSTITIAL_AD_BUTTON_IDENTIFIER, true); } @@ -34,7 +34,7 @@ public void onAdLoaded(@NonNull LevelPlayAdInfo adInfo) { @Override public void onAdLoadFailed(@NonNull LevelPlayAdError error) { logCallbackName(TAG, "error = " + error); - this.listener.setEnablementForButton(DemoButtonIdentifiers.SHOW_INTERSTITIAL_BUTTON_IDENTIFIER, false); + this.listener.setEnablementForButton(DemoButtonIdentifiers.SHOW_INTERSTITIAL_AD_BUTTON_IDENTIFIER, false); } /** @@ -45,7 +45,7 @@ public void onAdLoadFailed(@NonNull LevelPlayAdError error) { @Override public void onAdDisplayed(@NonNull LevelPlayAdInfo adInfo) { logCallbackName(TAG, "adInfo = " + adInfo); - this.listener.setEnablementForButton(DemoButtonIdentifiers.SHOW_INTERSTITIAL_BUTTON_IDENTIFIER, false); + this.listener.setEnablementForButton(DemoButtonIdentifiers.SHOW_INTERSTITIAL_AD_BUTTON_IDENTIFIER, false); } /** diff --git a/Android/Java/app/src/main/java/com/ironsource/ironsourcesdkdemo/DemoRewardedAdListener.java b/Android/Java/app/src/main/java/com/ironsource/ironsourcesdkdemo/DemoRewardedAdListener.java new file mode 100644 index 00000000..9b52e1a5 --- /dev/null +++ b/Android/Java/app/src/main/java/com/ironsource/ironsourcesdkdemo/DemoRewardedAdListener.java @@ -0,0 +1,98 @@ +package com.ironsource.ironsourcesdkdemo; + +import static com.ironsource.ironsourcesdkdemo.DemoActivity.logCallbackName; + +import androidx.annotation.NonNull; +import com.unity3d.mediation.LevelPlayAdError; +import com.unity3d.mediation.LevelPlayAdInfo; +import com.unity3d.mediation.rewarded.LevelPlayReward; +import com.unity3d.mediation.rewarded.LevelPlayRewardedAdListener; + +public class DemoRewardedAdListener implements LevelPlayRewardedAdListener { + private final String TAG = DemoRewardedAdListener.class.getSimpleName(); + private final DemoActivityListener listener; + + public DemoRewardedAdListener(DemoActivityListener listener) { + this.listener = listener; + } + + /** + Called after a rewarded ad has been loaded + @param adInfo The info of the ad + */ + @Override + public void onAdLoaded(@NonNull LevelPlayAdInfo adInfo) { + logCallbackName(TAG, "adInfo = " + adInfo); + this.listener.setEnablementForButton(DemoButtonIdentifiers.SHOW_REWARDED_AD_BUTTON_IDENTIFIER, true); + } + + /** + Called after a rewarded ad has attempted to load but failed + @param error The reason for the error + */ + @Override + public void onAdLoadFailed(@NonNull LevelPlayAdError error) { + logCallbackName(TAG, "error = " + error); + this.listener.setEnablementForButton(DemoButtonIdentifiers.SHOW_REWARDED_AD_BUTTON_IDENTIFIER, false); + } + + /** + Called after the ad info is updated. Available when another rewarded ad has loaded, and includes a higher CPM/Rate + @param adInfo The info of the ad + */ + @Override + public void onAdInfoChanged(@NonNull LevelPlayAdInfo adInfo) { + logCallbackName(TAG, "adInfo = " + adInfo); + } + + /** + Called after a rewarded ad has been displayed + This is the indication for impression + @param adInfo The info of the ad + */ + @Override + public void onAdDisplayed(@NonNull LevelPlayAdInfo adInfo) { + logCallbackName(TAG, "adInfo = " + adInfo); + this.listener.setEnablementForButton(DemoButtonIdentifiers.SHOW_REWARDED_AD_BUTTON_IDENTIFIER, false); + } + + /** + Called after a rewarded ad has attempted to display but failed. + @param error The reason for the error. + @param adInfo The info of the ad. + */ + @Override + public void onAdDisplayFailed(@NonNull LevelPlayAdError error, @NonNull LevelPlayAdInfo adInfo) { + logCallbackName(TAG, "error = " + error + " | adInfo = " + adInfo); + } + + /** + Called after a rewarded video has been viewed completely and the user is eligible for a reward. + @param reward The reward info. + @param adInfo The info of the ad. + */ + @Override + public void onAdRewarded(@NonNull LevelPlayReward reward, @NonNull LevelPlayAdInfo adInfo) { + logCallbackName(TAG, "reward = " + reward + " | adInfo = " + adInfo); + this.listener.setReward(reward); + } + + /** + Called after a rewarded ad has been clicked. + @param adInfo The info of the ad. + */ + @Override + public void onAdClicked(@NonNull LevelPlayAdInfo adInfo) { + logCallbackName(TAG, "adInfo = " + adInfo); + } + + /** + Called after a rewarded ad has been closed. + @param adInfo The info of the ad. + */ + @Override + public void onAdClosed(@NonNull LevelPlayAdInfo adInfo) { + logCallbackName(TAG, "adInfo = " + adInfo); + this.listener.showRewardDialog(); + } +} diff --git a/Android/Java/app/src/main/java/com/ironsource/ironsourcesdkdemo/DemoRewardedVideoAdListener.java b/Android/Java/app/src/main/java/com/ironsource/ironsourcesdkdemo/DemoRewardedVideoAdListener.java deleted file mode 100644 index 390d5856..00000000 --- a/Android/Java/app/src/main/java/com/ironsource/ironsourcesdkdemo/DemoRewardedVideoAdListener.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.ironsource.ironsourcesdkdemo; - -import static com.ironsource.ironsourcesdkdemo.DemoActivity.logCallbackName; - -import com.ironsource.mediationsdk.adunit.adapter.utility.AdInfo; -import com.ironsource.mediationsdk.logger.IronSourceError; -import com.ironsource.mediationsdk.model.Placement; -import com.ironsource.mediationsdk.sdk.LevelPlayRewardedVideoListener; - -public class DemoRewardedVideoAdListener implements LevelPlayRewardedVideoListener { - private final String TAG = DemoRewardedVideoAdListener.class.getSimpleName(); - private final DemoActivityListener listener; - - public DemoRewardedVideoAdListener(DemoActivityListener listener) { - this.listener = listener; - } - - /** - Called after a rewarded video has changed its availability to true. - @param adInfo The info of the ad. - */ - @Override - public void onAdAvailable(AdInfo adInfo) { - logCallbackName(TAG, "adInfo = " + adInfo); - this.listener.setEnablementForButton(DemoButtonIdentifiers.SHOW_REWARDED_VIDEO_BUTTON_IDENTIFIER, true); - } - - /** - Called after a rewarded video has changed its availability to false. - */ - @Override - public void onAdUnavailable() { - logCallbackName(TAG, ""); - this.listener.setEnablementForButton(DemoButtonIdentifiers.SHOW_REWARDED_VIDEO_BUTTON_IDENTIFIER, false); - } - - /** - Called after a rewarded video has been opened. - @param adInfo The info of the ad. - */ - @Override - public void onAdOpened(AdInfo adInfo) { - logCallbackName(TAG, "adInfo = " + adInfo); - this.listener.setEnablementForButton(DemoButtonIdentifiers.SHOW_REWARDED_VIDEO_BUTTON_IDENTIFIER, false); - } - - /** - Called after a rewarded video has attempted to show but failed. - @param ironSourceError The reason for the error. - @param adInfo The info of the ad. - */ - @Override - public void onAdShowFailed(IronSourceError ironSourceError, AdInfo adInfo) { - logCallbackName(TAG, "error = " + ironSourceError + " | adInfo = " + adInfo); - } - - /** - Called after a rewarded video has been clicked. - This callback is not supported by all networks, and we recommend using it - only if it's supported by all networks you included in your build - @param placement An object that contains the placement's reward name and amount. - @param adInfo The info of the ad. - */ - @Override - public void onAdClicked(Placement placement, AdInfo adInfo) { - logCallbackName(TAG, "placement = " + placement + " | adInfo = " + adInfo); - } - - /** - Called after a rewarded video has been viewed completely and the user is eligible for a reward. - @param placement An object that contains the placement's reward name and amount. - @param adInfo The info of the ad. - */ - @Override - public void onAdRewarded(Placement placement, AdInfo adInfo) { - logCallbackName(TAG, "placement = " + placement + " | adInfo = " + adInfo); - this.listener.setPlacementInfo(placement); - } - - /** - Called after a rewarded video has been dismissed. - @param adInfo The info of the ad. - */ - @Override - public void onAdClosed(AdInfo adInfo) { - logCallbackName(TAG, "adInfo = " + adInfo); - this.listener.showRewardDialog(); - } -} diff --git a/Android/Java/app/src/main/res/layout/activity_demo.xml b/Android/Java/app/src/main/res/layout/activity_demo.xml index 5d67ab9f..8ddeadb4 100644 --- a/Android/Java/app/src/main/res/layout/activity_demo.xml +++ b/Android/Java/app/src/main/res/layout/activity_demo.xml @@ -39,17 +39,40 @@ android:textAppearance="?android:attr/textAppearanceMedium" android:text="@string/rewarded_video" /> -