Skip to content

Commit

Permalink
Mintegral/16.6.61.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins committed Mar 14, 2024
1 parent 36fbf39 commit 149b804
Show file tree
Hide file tree
Showing 3 changed files with 182 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Mintegral/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 16.6.61.1
* Add support for app open ads.

## 16.6.61.0
* Certified with Mintegral SDK 16.6.61.

Expand Down
9 changes: 8 additions & 1 deletion Mintegral/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
private val versionMajor = 16
private val versionMinor = 6
private val versionPatch = 61
private val versionAdapterPatch = 0
private val versionAdapterPatch = 1

val libraryVersionName by extra("${versionMajor}.${versionMinor}.${versionPatch}.${versionAdapterPatch}")
val libraryVersionCode by extra((versionMajor * 1000000) + (versionMinor * 10000) + (versionPatch * 100) + versionAdapterPatch)
Expand Down Expand Up @@ -37,6 +37,7 @@ dependencies {
implementation("com.mbridge.msdk.oversea:videojs:${libraryVersions["mintegral"]}")
implementation("com.mbridge.msdk.oversea:mbnative:${libraryVersions["mintegral"]}")
implementation("com.mbridge.msdk.oversea:dycreator:${libraryVersions["mintegral"]}")
implementation("com.mbridge.msdk.oversea:mbsplash:${libraryVersions["mintegral"]}")

implementation("androidx.recyclerview:recyclerview:${libraryVersions["recyclerView"]}")
}
Expand Down Expand Up @@ -139,6 +140,12 @@ publishing {
appendNode("version", libraryVersions["mintegral"])
appendNode("scope", "compile")
}
appendNode("dependency").apply {
appendNode("groupId", "com.mbridge.msdk.oversea")
appendNode("artifactId", "mbsplash")
appendNode("version", libraryVersions["mintegral"])
appendNode("scope", "compile")
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;

import com.applovin.impl.sdk.utils.BundleUtils;
import com.applovin.mediation.MaxAdFormat;
import com.applovin.mediation.adapter.MaxAdViewAdapter;
import com.applovin.mediation.adapter.MaxAdapterError;
import com.applovin.mediation.adapter.MaxAppOpenAdapter;
import com.applovin.mediation.adapter.MaxInterstitialAdapter;
import com.applovin.mediation.adapter.MaxNativeAdAdapter;
import com.applovin.mediation.adapter.MaxRewardedAdapter;
import com.applovin.mediation.adapter.MaxSignalProvider;
import com.applovin.mediation.adapter.listeners.MaxAdViewAdapterListener;
import com.applovin.mediation.adapter.listeners.MaxAppOpenAdapterListener;
import com.applovin.mediation.adapter.listeners.MaxInterstitialAdapterListener;
import com.applovin.mediation.adapter.listeners.MaxNativeAdAdapterListener;
import com.applovin.mediation.adapter.listeners.MaxRewardedAdapterListener;
Expand Down Expand Up @@ -47,6 +51,9 @@
import com.mbridge.msdk.out.MBBidRewardVideoHandler;
import com.mbridge.msdk.out.MBConfiguration;
import com.mbridge.msdk.out.MBRewardVideoHandler;
import com.mbridge.msdk.out.MBSplashHandler;
import com.mbridge.msdk.out.MBSplashLoadListener;
import com.mbridge.msdk.out.MBSplashShowListener;
import com.mbridge.msdk.out.MBridgeIds;
import com.mbridge.msdk.out.MBridgeSDKFactory;
import com.mbridge.msdk.out.NativeListener;
Expand All @@ -66,9 +73,11 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;

import androidx.annotation.Nullable;

public class MintegralMediationAdapter
extends MediationAdapterBase
implements MaxInterstitialAdapter, MaxRewardedAdapter, MaxAdViewAdapter, MaxSignalProvider /* MaxNativeAdAdapter */
implements MaxInterstitialAdapter, MaxAppOpenAdapter, MaxRewardedAdapter, MaxAdViewAdapter, MaxSignalProvider, MaxNativeAdAdapter
{
private static final MintegralMediationAdapterRouter router;
private static final AtomicBoolean initialized = new AtomicBoolean();
Expand Down Expand Up @@ -121,6 +130,7 @@ public class MintegralMediationAdapter
// Supports video, interactive, and banner ad formats
private MBInterstitialVideoHandler mbInterstitialVideoHandler;
private MBBidInterstitialVideoHandler mbBidInterstitialVideoHandler;
private MBSplashHandler mbSplashHandler;
private MBRewardVideoHandler mbRewardVideoHandler;
private MBBidRewardVideoHandler mbBidRewardVideoHandler;
private MBBannerView mbBannerView;
Expand Down Expand Up @@ -148,7 +158,7 @@ public void initialize(final MaxAdapterInitializationParameters parameters, fina
{
// Set the channel code/id so that logs generated by Mintegral SDK can be attributed to MAX.
setChannelCode();

final String appId = parameters.getServerParameters().getString( APP_ID_PARAMETER );
final String appKey = parameters.getServerParameters().getString( APP_KEY_PARAMETER );
log( "Initializing Mintegral SDK with app id: " + appId + " and app key: " + appKey + "..." );
Expand Down Expand Up @@ -221,6 +231,14 @@ public void onDestroy()
mbBidInterstitialVideoHandler = null;
}

if ( mbSplashHandler != null )
{
mbSplashHandler.onDestroy();
mbSplashHandler.setSplashLoadListener( null );
mbSplashHandler.setSplashShowListener( null );
mbSplashHandler = null;
}

if ( mbRewardVideoHandler != null )
{
mbRewardVideoHandler.setRewardVideoListener( null );
Expand Down Expand Up @@ -397,6 +415,61 @@ else if ( mbInterstitialVideoHandler != null && mbInterstitialVideoHandler.isRea
}
}

@Override
public void loadAppOpenAd(final MaxAdapterResponseParameters parameters, @Nullable final Activity activity, final MaxAppOpenAdapterListener listener)
{
mbUnitId = parameters.getThirdPartyAdPlacementId();
final String placementId = BundleUtils.getString( "placement_id", parameters.getServerParameters() );

if ( activity == null )
{
log( "App open ad \"" + placementId + "\" load failed: Activity is null" );
listener.onAppOpenAdLoadFailed( MaxAdapterError.MISSING_ACTIVITY );

return;
}

log( "Loading bidding app open ad for unit id: " + mbUnitId + " and placement id: " + placementId + "..." );

mbSplashHandler = new MBSplashHandler( activity, placementId, mbUnitId );
final AppOpenAdListener appOpenAdListener = new AppOpenAdListener( listener );
mbSplashHandler.setSplashLoadListener( appOpenAdListener );
mbSplashHandler.setSplashShowListener( appOpenAdListener );

mbSplashHandler.preLoadByToken( parameters.getBidResponse() );
}

@Override
public void showAppOpenAd(final MaxAdapterResponseParameters parameters, @Nullable final Activity activity, final MaxAppOpenAdapterListener listener)
{
final String bidResponse = parameters.getBidResponse();

if ( mbSplashHandler == null || !mbSplashHandler.isReady( bidResponse ) )
{
log( "Unable to show app open ad - no ad loaded..." );
listener.onAppOpenAdDisplayFailed( new MaxAdapterError( MaxAdapterError.AD_DISPLAY_FAILED, 0, "App open ad not ready" ) );

return;
}

if ( activity == null )
{
log( "App open ad \"" + mbUnitId + "\" display failed: Activity is null" );
listener.onAppOpenAdDisplayFailed( MaxAdapterError.MISSING_ACTIVITY );

return;
}

log( "Showing app open ad..." );

// Mintegral recommends to show from a container
final RelativeLayout container = new RelativeLayout( getContext( activity ) );
final ViewGroup contentViewGroup = activity.getWindow().getDecorView().findViewById( android.R.id.content );
contentViewGroup.addView( container );

mbSplashHandler.show( container, bidResponse );
}

@Override
public void loadRewardedAd(final MaxAdapterResponseParameters parameters, final Activity activity, final MaxRewardedAdapterListener listener)
{
Expand Down Expand Up @@ -1010,6 +1083,102 @@ RewardVideoListener getRewardedListener()
void initialize(final MaxAdapterInitializationParameters parameters, final Activity activity, final OnCompletionListener onCompletionListener) { }
}

private class AppOpenAdListener
implements MBSplashLoadListener, MBSplashShowListener
{
private final MaxAppOpenAdapterListener listener;

private AppOpenAdListener(final MaxAppOpenAdapterListener listener)
{
this.listener = listener;
}

//region MBSplashLoadListener

@Override
public void onLoadSuccessed(final MBridgeIds mBridgeIds, final int requestType)
{
log( "App open ad loaded for: " + mBridgeIds );

Bundle extraInfo = null;
final String creativeId = mbSplashHandler.getCreativeIdWithUnitId();
if ( AppLovinSdkUtils.isValidString( creativeId ) )
{
extraInfo = new Bundle( 1 );
extraInfo.putString( "creative_id", creativeId );
}

listener.onAppOpenAdLoaded( extraInfo );
}

@Override
public void onLoadFailed(final MBridgeIds mBridgeIds, final String errorMsg, final int requestType)
{
final MaxAdapterError adapterError = toMaxError( errorMsg );
log( "App open ad failed to load: " + adapterError );
listener.onAppOpenAdLoadFailed( adapterError );
}

@Override
public void isSupportZoomOut(final MBridgeIds mBridgeIds, final boolean supportsZoomOut)
{
log( "App open ad supports zoom out: " + supportsZoomOut );
}

//endregion

//region MBSplashShowListener

@Override
public void onShowSuccessed(final MBridgeIds mBridgeIds)
{
log( "App open ad displayed" );
listener.onAppOpenAdDisplayed();
}

@Override
public void onShowFailed(final MBridgeIds mBridgeIds, final String errorMsg)
{
final MaxAdapterError adapterError = new MaxAdapterError( -4205, "Ad Display Failed", 0, errorMsg );
log( "App open ad failed to show: " + adapterError );
listener.onAppOpenAdDisplayFailed( adapterError );
}

@Override
public void onAdClicked(final MBridgeIds mBridgeIds)
{
log( "App open ad clicked" );
listener.onAppOpenAdClicked();
}

@Override
public void onDismiss(final MBridgeIds mBridgeIds, final int dismissType)
{
log( "App open ad hidden" );
listener.onAppOpenAdHidden();
}

@Override
public void onAdTick(final MBridgeIds mBridgeIds, final long timeUntilFinishedMillis)
{
log( "App open ad ticked with " + timeUntilFinishedMillis + " ms remaining" );
}

@Override
public void onZoomOutPlayStart(final MBridgeIds mBridgeIds)
{
log( "App open ad zoom out started" );
}

@Override
public void onZoomOutPlayFinish(final MBridgeIds mBridgeIds)
{
log( "App open ad zoom out finished" );
}

//endregion
}

private class NativeAdViewListener
implements NativeListener.NativeAdListener, OnMBMediaViewListener
{
Expand Down

0 comments on commit 149b804

Please sign in to comment.