Skip to content

Commit

Permalink
Line/2024.2.14.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins committed Apr 30, 2024
1 parent f0b6535 commit ffd53c0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 53 deletions.
4 changes: 4 additions & 0 deletions Line/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2024.2.14.1
* Remove deprecated callbacks `onRewardedAdVideoStarted()` and `onRewardedAdVideoCompleted()`.
* Remove passing of `Activity` contexts into LINE APIs.

## 2024.2.14.0
* Certified with Line SDK 2.7.20240214.

Expand Down
4 changes: 3 additions & 1 deletion Line/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
private val versionMajor = 2024
private val versionMinor = 2
private val versionPatch = 14
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 All @@ -16,8 +16,10 @@ val libraryGroupId by extra("com.applovin.mediation")

var libraryVersions = rootProject.extra["versions"] as Map<*, *>

android.namespace = "com.applovin.mediation.adapters.line"
android.defaultConfig.versionCode = libraryVersionCode
android.defaultConfig.versionName = libraryVersionName
android.defaultConfig.minSdk = 19

dependencies {
implementation("com.linecorp.adsnetwork:fivead:${libraryVersions["line"]}")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.applovin.mediation.adapters;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
Expand Down Expand Up @@ -46,7 +45,6 @@
import com.five_corp.ad.NeedChildDirectedTreatment;
import com.five_corp.ad.NeedGdprNonPersonalizedAdsTreatment;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
Expand Down Expand Up @@ -114,10 +112,7 @@ public void initialize(final MaxAdapterInitializationParameters parameters, fina
config.needChildDirectedTreatment = isAgeRestrictedUser ? NeedChildDirectedTreatment.TRUE : NeedChildDirectedTreatment.FALSE;
}

// NOTE: `activity` can only be null in 11.1.0+, and `getApplicationContext()` is introduced in 11.1.0
Context context = ( activity != null ) ? activity.getApplicationContext() : getApplicationContext();

FiveAd.initialize( context, config );
FiveAd.initialize( getApplicationContext(), config );

onCompletionListener.onCompletion( InitializationStatus.INITIALIZED_UNKNOWN, null );
}
Expand Down Expand Up @@ -151,7 +146,7 @@ public void loadInterstitialAd(final MaxAdapterResponseParameters parameters, fi
String slotId = parameters.getThirdPartyAdPlacementId();
log( "Loading interstitial ad for slot id: " + slotId + "..." );

interstitialAd = new FiveAdInterstitial( activity, slotId );
interstitialAd = new FiveAdInterstitial( getApplicationContext(), slotId );

InterstitialListener interstitialListener = new InterstitialListener( listener );
interstitialAd.setLoadListener( interstitialListener );
Expand All @@ -174,7 +169,7 @@ public void loadRewardedAd(final MaxAdapterResponseParameters parameters, final
String slotId = parameters.getThirdPartyAdPlacementId();
log( "Loading rewarded ad for slot id: " + slotId + "..." );

rewardedAd = new FiveAdVideoReward( activity, slotId );
rewardedAd = new FiveAdVideoReward( getApplicationContext(), slotId );

RewardedListener rewardedListener = new RewardedListener( listener );
rewardedAd.setLoadListener( rewardedListener );
Expand Down Expand Up @@ -202,8 +197,8 @@ public void loadAdViewAd(final MaxAdapterResponseParameters parameters, final Ma

if ( isNative )
{
nativeAd = new FiveAdNative( activity, slotId, new DisplayMetrics().widthPixels );
NativeAdViewListener nativeAdViewListener = new NativeAdViewListener( listener, adFormat, parameters.getServerParameters(), activity );
nativeAd = new FiveAdNative( getApplicationContext(), slotId, new DisplayMetrics().widthPixels );
NativeAdViewListener nativeAdViewListener = new NativeAdViewListener( listener, adFormat, parameters.getServerParameters() );
nativeAd.setLoadListener( nativeAdViewListener );
nativeAd.setEventListener( nativeAdViewListener );

Expand All @@ -214,7 +209,7 @@ public void loadAdViewAd(final MaxAdapterResponseParameters parameters, final Ma
}
else
{
adView = new FiveAdCustomLayout( activity, slotId, new DisplayMetrics().widthPixels );
adView = new FiveAdCustomLayout( getApplicationContext(), slotId, new DisplayMetrics().widthPixels );
AdViewListener adViewListener = new AdViewListener( listener, adFormat );
adView.setLoadListener( adViewListener );
adView.setEventListener( adViewListener );
Expand All @@ -232,8 +227,8 @@ public void loadNativeAd(final MaxAdapterResponseParameters parameters, final Ac
String slotId = parameters.getThirdPartyAdPlacementId();
log( "Loading native ad for slot id: " + slotId + "..." );

nativeAd = new FiveAdNative( activity, slotId, new DisplayMetrics().widthPixels );
NativeAdListener nativeAdListener = new NativeAdListener( listener, parameters.getServerParameters(), activity );
nativeAd = new FiveAdNative( getApplicationContext(), slotId, new DisplayMetrics().widthPixels );
NativeAdListener nativeAdListener = new NativeAdListener( listener, parameters.getServerParameters() );
nativeAd.setLoadListener( nativeAdListener );
nativeAd.setEventListener( nativeAdListener );

Expand Down Expand Up @@ -417,8 +412,6 @@ public void onClick(final FiveAdVideoReward ad)
@Override
public void onFullScreenClose(final FiveAdVideoReward ad)
{
listener.onRewardedAdVideoCompleted();

if ( ad.getState() != FiveAdState.ERROR )
{
if ( hasGrantedReward || shouldAlwaysRewardUser() )
Expand All @@ -437,7 +430,6 @@ public void onFullScreenClose(final FiveAdVideoReward ad)
public void onFullScreenOpen(final FiveAdVideoReward ad)
{
log( "Rewarded ad shown for slot id: " + ad.getSlotId() + "..." );
listener.onRewardedAdVideoStarted();
}

@Override
Expand Down Expand Up @@ -547,14 +539,12 @@ private class NativeAdViewListener
private final MaxAdViewAdapterListener listener;
private final MaxAdFormat adFormat;
private final Bundle serverParameters;
private final WeakReference<Activity> activityRef;

NativeAdViewListener(final MaxAdViewAdapterListener listener, final MaxAdFormat adFormat, final Bundle serverParameters, final Activity activity)
NativeAdViewListener(final MaxAdViewAdapterListener listener, final MaxAdFormat adFormat, final Bundle serverParameters)
{
this.listener = listener;
this.adFormat = adFormat;
this.serverParameters = serverParameters;
this.activityRef = new WeakReference<>( activity );
}

@Override
Expand All @@ -569,7 +559,7 @@ public void onFiveAdLoad(final FiveAdInterface ad)
return;
}

renderCustomNativeBanner( ad.getSlotId(), activityRef.get() );
renderCustomNativeBanner( ad.getSlotId() );
}

@Override
Expand Down Expand Up @@ -627,7 +617,7 @@ public void onViewThrough(final FiveAdNative ad)
log( "Native " + adFormat.getLabel() + " ad completed for slot id: " + ad.getSlotId() + "..." );
}

private void renderCustomNativeBanner(final String slotId, final Activity activity)
private void renderCustomNativeBanner(final String slotId)
{
nativeAd.loadIconImageAsync( new FiveAdNative.LoadImageCallback()
{
Expand All @@ -652,7 +642,7 @@ public void run()
.setTitle( nativeAd.getAdTitle() )
.setBody( nativeAd.getDescriptionText() )
.setCallToAction( nativeAd.getButtonText() )
.setIcon( new MaxNativeAd.MaxNativeAdImage( new BitmapDrawable( activity.getResources(), bitmap ) ) )
.setIcon( new MaxNativeAd.MaxNativeAdImage( new BitmapDrawable( getApplicationContext().getResources(), bitmap ) ) )
.setMediaView( nativeAd.getAdMainView() )
.build();

Expand All @@ -668,26 +658,11 @@ public void run()
if ( templateName.equals( "vertical" ) )
{
String verticalTemplateName = ( adFormat == MaxAdFormat.LEADER ) ? "vertical_leader_template" : "vertical_media_banner_template";

if ( AppLovinSdk.VERSION_CODE >= 11010000 )
{
maxNativeAdView = new MaxNativeAdView( maxNativeAd, verticalTemplateName, getApplicationContext() );
}
else
{
maxNativeAdView = new MaxNativeAdView( maxNativeAd, verticalTemplateName, activity );
}
maxNativeAdView = new MaxNativeAdView( maxNativeAd, verticalTemplateName, getApplicationContext() );
}
else
{
if ( AppLovinSdk.VERSION_CODE >= 11010000 )
{
maxNativeAdView = new MaxNativeAdView( maxNativeAd, templateName, getApplicationContext() );
}
else
{
maxNativeAdView = new MaxNativeAdView( maxNativeAd, templateName, activity );
}
maxNativeAdView = new MaxNativeAdView( maxNativeAd, templateName, getApplicationContext() );
}

final List<View> clickableViews = new ArrayList<>( 5 );
Expand Down Expand Up @@ -728,13 +703,11 @@ private class NativeAdListener
{
private final MaxNativeAdAdapterListener listener;
private final Bundle serverParameters;
private final WeakReference<Activity> activityRef;

NativeAdListener(final MaxNativeAdAdapterListener listener, final Bundle serverParameters, final Activity activity)
NativeAdListener(final MaxNativeAdAdapterListener listener, final Bundle serverParameters)
{
this.listener = listener;
this.serverParameters = serverParameters;
this.activityRef = new WeakReference<>( activity );
}

@Override
Expand All @@ -751,15 +724,6 @@ public void onFiveAdLoad(final FiveAdInterface ad)
return;
}

final Activity activity = activityRef.get();
if ( activity == null )
{
log( "Native ad (" + ad.getSlotId() + ") failed to load: activity reference is null when ad is loaded" );
listener.onNativeAdLoadFailed( new MaxAdapterError( -5601, "Missing Activity" ) );

return;
}

String templateName = BundleUtils.getString( "template", "", serverParameters );
boolean isTemplateAd = AppLovinSdkUtils.isValidString( templateName );
if ( isTemplateAd && TextUtils.isEmpty( loadedNativeAd.getAdTitle() ) )
Expand Down Expand Up @@ -788,7 +752,7 @@ public void onImageLoad(final Bitmap bitmap)
.setAdvertiser( nativeAd.getAdvertiserName() )
.setBody( nativeAd.getDescriptionText() )
.setCallToAction( nativeAd.getButtonText() )
.setIcon( new MaxNativeAd.MaxNativeAdImage( new BitmapDrawable( activity.getResources(), bitmap ) ) )
.setIcon( new MaxNativeAd.MaxNativeAdImage( new BitmapDrawable( getApplicationContext().getResources(), bitmap ) ) )
.setMediaView( nativeAd.getAdMainView() );
MaxNativeAd maxNativeAd = new MaxLineNativeAd( builder );

Expand Down

0 comments on commit ffd53c0

Please sign in to comment.