@Override public void initialize(Context context, MediationAdRequest adRequest, String unused, MediationRewardedVideoAdListener listener, Bundle serverParameters, Bundle networkExtras) { try { AdapterParametersParser.Config config = AdapterParametersParser.parse(networkExtras, serverParameters); mMediationRewardedVideoAdListener = listener; mVungleManager = VungleManager.getInstance(config.getAppId(), config.getAllPlacements()); mVungleManager.addListener(mId, mVungleListener); if (mVungleManager.isInitialized()) { mInitialized = true; mMediationRewardedVideoAdListener.onInitializationSucceeded(VungleAdapter.this); } else { mVungleListener.setWaitingInit(true); mVungleManager.init(context); } } catch (IllegalArgumentException e) { if (listener != null) { listener.onInitializationFailed(VungleAdapter.this, AdRequest.ERROR_CODE_INVALID_REQUEST); } } }
/*************** * MediationRewardedVideoAdapter methods ***************/ @Override public void initialize(Context context, MediationAdRequest mediationAdRequest, String userId, MediationRewardedVideoAdListener mediationRewardedVideoAdListener, Bundle serverParams, Bundle networkExtras) { this._mediationRewardedVideoAdListener = mediationRewardedVideoAdListener; _adColonyRewardedInterstitialListener = new AdColonyAdListener(this, mediationRewardedVideoAdListener); boolean success = AdColonyManager.getInstance() .configureAdColony(context, serverParams, mediationAdRequest, networkExtras); if (success) { AdColonyManager.getInstance().rewardedAdsConfigured = true; this._mediationRewardedVideoAdListener.onInitializationSucceeded(this); } else { this._mediationRewardedVideoAdListener .onInitializationFailed(this, AdRequest.ERROR_CODE_INVALID_REQUEST); } }
@Override public void initialize(Context context, MediationAdRequest adRequest, String unused, MediationRewardedVideoAdListener adListener, Bundle serverParameters, Bundle mediationExtras) { if (!(context instanceof Activity)) { Log.e(TAG, "Requires an Activity context to initialize!"); adListener.onInitializationFailed( NendRewardedAdapter.this, AdRequest.ERROR_CODE_INVALID_REQUEST); return; } Activity activity = (Activity) context; mRewardedVideoEventForwarder = new NendMediationRewardedVideoEventForwarder(activity, NendRewardedAdapter.this, serverParameters, adListener); if (isInitialized()) { adListener.onInitializationSucceeded(this); } else { adListener.onInitializationFailed(this, AdRequest.ERROR_CODE_INTERNAL_ERROR); } }
NendMediationRewardedVideoEventForwarder(Activity activity, NendRewardedAdapter nendAdapter, Bundle serverParameters, MediationRewardedVideoAdListener listener) { this.mMediationRewardedVideoAdListener = listener; this.mNendAdapter = nendAdapter; this.mActivityWeakReference = new WeakReference<>(activity); String apiKey = serverParameters.getString("apiKey"); int spotId = Integer.parseInt(serverParameters.getString("spotId")); if (!isValidSpotIdAndKey(spotId, apiKey)) { Log.e(NendRewardedAdapter.TAG, "Failed to initialize! It may spotId or apiKey is " + "invalid."); mMediationRewardedVideoAdListener .onInitializationFailed(nendAdapter, AdRequest.ERROR_CODE_INTERNAL_ERROR); return; } mNendAdRewardedVideo = new NendAdRewardedVideo(activity, spotId, apiKey); mNendAdRewardedVideo.setAdListener(this); mNendAdRewardedVideo.setMediationName("AdMob"); mIsInitialized = true; }
@Override public void initialize(Context context, MediationAdRequest mediationAdRequest, String unused, MediationRewardedVideoAdListener mediationRewardedVideoAdListener, Bundle serverParameters, Bundle networkExtras) { mRewardedListener = mediationRewardedVideoAdListener; if (!isValidRequestParameters(context, serverParameters)) { mRewardedListener.onAdFailedToLoad(this, AdRequest.ERROR_CODE_INVALID_REQUEST); return; } String placementId = serverParameters.getString(PLACEMENT_PARAMETER); mRewardedVideoAd = new RewardedVideoAd(context, placementId); mRewardedVideoAd.setAdListener(new RewardedVideoListener()); mIsInitialized = true; mRewardedListener.onInitializationSucceeded(this); }
@Override public void initialize(Context context, MediationAdRequest adRequest, String userId, MediationRewardedVideoAdListener listener, Bundle serverParameters, Bundle networkExtras) { if (!(context instanceof Activity)) { listener.onAdFailedToLoad(this, AdRequest.ERROR_CODE_INVALID_REQUEST); return; } MaioAds.setAdTestMode(adRequest.isTesting()); this.mMediationRewardedVideoAdListener = listener; mIsRewardedVideoInitialized = true; loadServerParameters(serverParameters); if (!isInitialized()) { //maio sdk initialization MaioEventForwarder.initialize((Activity) context, this.mMediaId); } }
@Override public void initialize(Context context, MediationAdRequest mediationAdRequest, String userId, MediationRewardedVideoAdListener mediationRewardedVideoAdListener, Bundle serverParameters, Bundle networkExtras) { mMediationRewardedVideoAdListener = mediationRewardedVideoAdListener; mChartboostParams = createChartboostParams(serverParameters, networkExtras); if (!isValidChartboostParams(mChartboostParams)) { // Invalid server parameters, send initialization failed event. if (mMediationRewardedVideoAdListener != null) { mMediationRewardedVideoAdListener.onInitializationFailed(ChartboostAdapter.this, AdRequest.ERROR_CODE_INVALID_REQUEST); } return; } if (!ChartboostSingleton.startChartboostRewardedVideo(context, mChartboostRewardedVideoDelegate)) { // Chartboost initialization failed, send initialization failed event. if (mMediationRewardedVideoAdListener != null) { mMediationRewardedVideoAdListener.onInitializationFailed(ChartboostAdapter.this, AdRequest.ERROR_CODE_INVALID_REQUEST); } } }
private void _showVideo(String zoneId, MediationRewardedVideoAdAdapter adapter, MediationRewardedVideoAdListener listener) { MaioAds.show(zoneId); this.mRewardedAdapter = adapter; this.mMediationRewardedVideoAdListener = listener; mAdType = AdType.VIDEO; }
@Override public void initialize(Context context, MediationAdRequest mediationAdRequest, String userId, MediationRewardedVideoAdListener mediationRewardedVideoAdListener, Bundle serverParameters, Bundle networkExtras) { mMediationRewardedVideoAdListener = mediationRewardedVideoAdListener; String gameId = serverParameters.getString(KEY_GAME_ID); mPlacementId = serverParameters.getString(KEY_PLACEMENT_ID); if (!isValidIds(gameId, mPlacementId)) { if (mMediationRewardedVideoAdListener != null) { mMediationRewardedVideoAdListener.onInitializationFailed(UnityAdapter.this, AdRequest.ERROR_CODE_INVALID_REQUEST); } return; } if (!isValidContext(context)) { return; } // Check if the Unity Ads initialized. if (!UnitySingleton.initializeUnityAds(mUnityAdapterDelegate, (Activity) context, gameId)) { if (mMediationRewardedVideoAdListener != null) { mMediationRewardedVideoAdListener.onInitializationFailed(UnityAdapter.this, AdRequest.ERROR_CODE_INVALID_REQUEST); } return; } // Storing a weak reference to the Activity. mActivityWeakReference = new WeakReference<>((Activity) context); mIsRewardedVideoAdAdapterInitialized = true; mMediationRewardedVideoAdListener.onInitializationSucceeded(this); }
@Override public void initialize(final Context context, final MediationAdRequest adRequest, final String userId, final MediationRewardedVideoAdListener listener, final Bundle serverParameters, final Bundle networkExtras) { if (!validateContext(context)) { log(ERROR, "Unable to request AppLovin rewarded video. Invalid context provided."); listener.onInitializationFailed(this, AdRequest.ERROR_CODE_INVALID_REQUEST); return; } log(DEBUG, "Initializing AppLovin rewarded video..."); this.mContext = context; mRewardedAdMobListener = listener; this.mServerParameters = serverParameters; if (!mInitialized) { mRewardedSdk = sdkInstance(context); mInitialized = true; mRewardedAd = AppLovinIncentivizedInterstitial.create(mRewardedSdk); mAppLovinAdListener = new AppLovinAdListener(this, mRewardedAdMobListener); } mRewardedAdMobListener.onInitializationSucceeded(this); }
@Override public void initialize(final Context context, final MediationAdRequest adRequest, final String userId, final MediationRewardedVideoAdListener listener, final Bundle serverParameters, final Bundle networkExtras) { // SDK versions BELOW 7.2.0 require a instance of an Activity to be passed in as the context if ( AppLovinSdk.VERSION_CODE < 720 && !( context instanceof Activity ) ) { log( ERROR, "Unable to request AppLovin rewarded video. Invalid context provided." ); listener.onInitializationFailed( this, AdRequest.ERROR_CODE_INVALID_REQUEST ); return; } log( DEBUG, "Initializing AppLovin rewarded video..." ); this.context = context; this.listener = listener; if ( !initialized ) { AppLovinSdk.initializeSdk( context ); AppLovinSdk.getInstance( context ).setPluginVersion( "AdMob-2.0" ); initialized = true; } listener.onInitializationSucceeded( this ); }
@Override public void initialize(Context context, MediationAdRequest mediationAdRequest, String serverJSON, MediationRewardedVideoAdListener mediationRewardedVideoAdListener, Bundle serverParameters, Bundle mediationExtras) { this.mediationRewardedVideoAdListener = mediationRewardedVideoAdListener; int slotId; try { String adUnit = serverParameters.getString( MediationRewardedVideoAdAdapter.CUSTOM_EVENT_SERVER_PARAMETER_FIELD); JSONObject param = new JSONObject(adUnit); slotId = param.getInt(SLOT_ID_KEY); } catch (JSONException e) { Log.i(TAG, "Unable to get slotId from parameter json. Probably Admob mediation " + "misconfiguration."); mediationRewardedVideoAdListener.onAdFailedToLoad( com.my.target.ads.mediation.MyTargetAdmobCustomEventRewarded.this, AdRequest.ERROR_CODE_INTERNAL_ERROR); return; } interstitial = new InterstitialAd(slotId, context); interstitial.getCustomParams().setCustomParam("mediation", "1"); if (mediationAdRequest != null) { interstitial.getCustomParams().setGender(mediationAdRequest.getGender()); Date date = mediationAdRequest.getBirthday(); if (date != null && date.getTime() != -1) { GregorianCalendar calendar = new GregorianCalendar(); GregorianCalendar calendarNow = new GregorianCalendar(); calendar.setTimeInMillis(date.getTime()); int a = calendarNow.get(GregorianCalendar.YEAR) - calendar.get(GregorianCalendar.YEAR); if (a >= 0) { interstitial.getCustomParams().setAge(a); } } } interstitial.setListener(interstitialAdListener); mediationRewardedVideoAdListener .onInitializationSucceeded(com.my.target.ads.mediation.MyTargetAdmobCustomEventRewarded.this); }
@Override public void initialize(Context context, MediationAdRequest mediationAdRequest, String unUsed, MediationRewardedVideoAdListener listener, Bundle serverParameters, Bundle mediationExtras) { // In this method you should initialize your SDK. // The sample SDK requires activity context to initialize, so check that the context // provided by the app is an activity context before initializing. if (!(context instanceof Activity)) { // Context not an Activity context, log the reason for failure and fail the // initialization. Log.d(TAG, "Sample SDK requires an Activity context to initialize"); listener.onInitializationFailed( SampleAdapter.this, AdRequest.ERROR_CODE_INVALID_REQUEST); return; } /** * Get the Ad Unit ID for the Sample SDK from serverParameters bundle using the pre * configured keys. * * For custom events, there is a single parameter that can be accessed via * * String serverParameter = serverParameters.getString( * MediationRewardedVideoAdAdapter.CUSTOM_EVENT_SERVER_PARAMETER_FIELD); */ String adUnit = serverParameters.getString(SAMPLE_AD_UNIT_KEY); if (TextUtils.isEmpty(adUnit)) { listener.onAdFailedToLoad(this, AdRequest.ERROR_CODE_INVALID_REQUEST); return; } // Create a rewarded video event forwarder to forward the events from the Sample SDK to // the Google Mobile Ads SDK. mRewardedVideoEventForwarder = new SampleMediationRewardedVideoEventForwarder(listener, SampleAdapter.this); // Initialize the Sample SDK. SampleRewardedVideo.initialize((Activity) context, adUnit, mRewardedVideoEventForwarder); }
AdColonyAdListener(AdColonyAdapter adapter, MediationRewardedVideoAdListener listener) { _mediationRewardedVideoAdListener = listener; _adapter = adapter; _rewarded = true; }
@Override public void initialize(Context context, MediationAdRequest mediationAdRequest, String unused, MediationRewardedVideoAdListener mediationRewardedVideoAdListener, Bundle serverParameters, Bundle networkExtras) { this.mediationRewardedVideoAdListener = mediationRewardedVideoAdListener; if (mediationRewardedVideoAdListener == null) { Log.i(TAG, "Did not receive MediationRewardedVideoAdListener from AdMob"); return; } if (!checkParams(context, serverParameters, RequestType.VIDEO)) { this.mediationRewardedVideoAdListener .onInitializationFailed(this, AdRequest.ERROR_CODE_INVALID_REQUEST); return; } if (!Tapjoy.isConnected()) { Hashtable<String, Object> connectFlags = new Hashtable<String, Object>(); if (networkExtras != null) { if (networkExtras.containsKey(TapjoyExtrasBundleBuilder.DEBUG)) { connectFlags.put("TJC_OPTION_ENABLE_LOGGING", networkExtras.getBoolean(TapjoyExtrasBundleBuilder.DEBUG, false)); } } Log.i(TAG, "Connecting to Tapjoy for Tapjoy-AdMob adapter"); Tapjoy.connect(context, sdkKey, connectFlags, new TJConnectListener() { @Override public void onConnectSuccess() { TapjoyAdapter.this.mediationRewardedVideoAdListener .onInitializationSucceeded(TapjoyAdapter.this); } @Override public void onConnectFailure() { Log.d(TAG, "Tapjoy failed to connect"); TapjoyAdapter.this.mediationRewardedVideoAdListener.onInitializationFailed( TapjoyAdapter.this, AdRequest.ERROR_CODE_INVALID_REQUEST); } }); } else { mediationRewardedVideoAdListener.onInitializationSucceeded(this); } }
@Override public void initialize(Context context, MediationAdRequest mediationAdRequest, String serverJSON, MediationRewardedVideoAdListener mediationRewardedVideoAdListener, Bundle serverParameters, Bundle mediationExtras) { mListener = mediationRewardedVideoAdListener; int slotId = MyTargetTools.checkAndGetSlotId(context, serverParameters); Log.d(TAG, "Requesting rewarded mediation, slotId: " + slotId); if (slotId < 0) { if (mediationRewardedVideoAdListener != null) { mediationRewardedVideoAdListener.onInitializationFailed( MyTargetRewardedAdapter.this, AdRequest.ERROR_CODE_INVALID_REQUEST); } return; } if (mInterstitial != null) { mInitialized = false; mInterstitial.destroy(); } mInterstitial = new InterstitialAd(slotId, context); CustomParams params = mInterstitial.getCustomParams(); params.setCustomParam( MyTargetTools.PARAM_MEDIATION_KEY, MyTargetTools.PARAM_MEDIATION_VALUE); if (mediationAdRequest != null) { int gender = mediationAdRequest.getGender(); Log.d(TAG, "Set gender to " + gender); params.setGender(gender); Date date = mediationAdRequest.getBirthday(); if (date != null && date.getTime() != -1) { GregorianCalendar calendar = new GregorianCalendar(); GregorianCalendar calendarNow = new GregorianCalendar(); calendar.setTimeInMillis(date.getTime()); int age = calendarNow.get(GregorianCalendar.YEAR) - calendar.get(GregorianCalendar.YEAR); if (age >= 0) { Log.d(TAG, "Set age to " + age); params.setAge(age); } } } MyTargetInterstitialListener interstitialAdListener = null; if (mediationRewardedVideoAdListener != null) { interstitialAdListener = new MyTargetInterstitialListener(mediationRewardedVideoAdListener); } mInterstitial.setListener(interstitialAdListener); mInitialized = true; if (mediationRewardedVideoAdListener != null) { mediationRewardedVideoAdListener .onInitializationSucceeded(MyTargetRewardedAdapter.this); } Log.d(TAG, "Ad initialized "); }
MyTargetInterstitialListener(final @NonNull MediationRewardedVideoAdListener listener) { this.listener = listener; }
public static void showVideo(String zoneId, MediationRewardedVideoAdAdapter adapter, MediationRewardedVideoAdListener listener) { sInstance._showVideo(zoneId, adapter, listener); }
AppLovinAdListener(ApplovinAdapter adapter, MediationRewardedVideoAdListener listener) { this.mAdapter = adapter; mRewardedListener = listener; mIsRewarded = true; mAdType = "Rewarded video"; }
/** * Creates a new {@link SampleMediationRewardedVideoEventForwarder}. * * @param listener An AdMob Mediation {@link MediationRewardedVideoAdListener} that should * receive forwarded events. * @param sampleAdapter A {@link SampleAdapter} mediation adapter. */ public SampleMediationRewardedVideoEventForwarder(MediationRewardedVideoAdListener listener, SampleAdapter sampleAdapter) { this.mMediationRewardedVideoAdListener = listener; this.mSampleAdapter = sampleAdapter; }