use of com.google.android.gms.ads.rewarded.RewardItem in project mopub-android-mediation by mopub.
the class GooglePlayServicesRewardedVideo method show.
@Override
protected void show() {
MoPubLog.log(getAdNetworkId(), SHOW_ATTEMPTED, ADAPTER_NAME);
if (mRewardedAd != null) {
if (mContext instanceof Activity) {
mRewardedAd.show((Activity) mContext, new OnUserEarnedRewardListener() {
@Override
public void onUserEarnedReward(@NonNull RewardItem rewardItem) {
Preconditions.checkNotNull(rewardItem);
MoPubLog.log(getAdNetworkId(), SHOULD_REWARD, ADAPTER_NAME, rewardItem.getAmount(), rewardItem.getType());
if (mInteractionListener != null) {
mInteractionListener.onAdComplete(MoPubReward.success(rewardItem.getType(), rewardItem.getAmount()));
}
}
});
} else {
MoPubLog.log(getAdNetworkId(), SHOW_FAILED, ADAPTER_NAME, MoPubErrorCode.FULLSCREEN_SHOW_ERROR.getIntCode(), MoPubErrorCode.FULLSCREEN_SHOW_ERROR);
if (mInteractionListener != null) {
mInteractionListener.onAdFailed(MoPubErrorCode.FULLSCREEN_SHOW_ERROR);
}
}
} else {
MoPubLog.log(getAdNetworkId(), CUSTOM, ADAPTER_NAME, "Failed to show " + "Google rewarded video because it wasn't ready yet.");
MoPubLog.log(getAdNetworkId(), SHOW_FAILED, ADAPTER_NAME, MoPubErrorCode.FULLSCREEN_SHOW_ERROR.getIntCode(), MoPubErrorCode.FULLSCREEN_SHOW_ERROR);
if (mInteractionListener != null) {
mInteractionListener.onAdFailed(MoPubErrorCode.FULLSCREEN_SHOW_ERROR);
}
}
}
use of com.google.android.gms.ads.rewarded.RewardItem in project prebid-mobile-android by prebid.
the class RubiconRewardedVideoGamDemoActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_demo);
PrebidMobile.setPrebidServerHost(Host.RUBICON);
PrebidMobile.setPrebidServerAccountId(Constants.PBS_ACCOUNT_ID_RUBICON);
PrebidMobile.setStoredAuctionResponse(Constants.PBS_STORED_RESPONSE_VAST_RUBICON);
VideoBaseAdUnit.Parameters parameters = new VideoBaseAdUnit.Parameters();
parameters.setMimes(Arrays.asList("video/mp4"));
parameters.setProtocols(Arrays.asList(Signals.Protocols.VAST_2_0));
// parameters.setProtocols(Arrays.asList(new Signals.Protocols(2)));
parameters.setPlaybackMethod(Arrays.asList(Signals.PlaybackMethod.AutoPlaySoundOff));
// parameters.setPlaybackMethod(Arrays.asList(new Signals.PlaybackMethod(2)));
RewardedVideoAdUnit adUnit = new RewardedVideoAdUnit("1001-1");
adUnit.setParameters(parameters);
this.adUnit = adUnit;
final AdManagerAdRequest.Builder builder = new AdManagerAdRequest.Builder();
adUnit.fetchDemand(builder, new OnCompleteListener() {
@Override
public void onComplete(ResultCode resultCode) {
AdManagerAdRequest request = builder.build();
RewardedAd.load(RubiconRewardedVideoGamDemoActivity.this, Constants.DFP_REWARDED_ADUNIT_ID_RUBICON, request, new RewardedAdLoadCallback() {
@Override
public void onAdLoaded(@NonNull RewardedAd rewardedAd) {
super.onAdLoaded(rewardedAd);
rewardedAd.show(RubiconRewardedVideoGamDemoActivity.this, new OnUserEarnedRewardListener() {
@Override
public void onUserEarnedReward(@NonNull RewardItem rewardItem) {
}
});
}
@Override
public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
super.onAdFailedToLoad(loadAdError);
}
});
}
});
}
Aggregations