react-native-applovin-max 6.5.0 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/android/build.gradle +46 -100
  2. package/android/gradle.properties +4 -4
  3. package/android/src/main/AndroidManifest.xml +2 -2
  4. package/android/src/main/AndroidManifestNew.xml +2 -0
  5. package/android/src/main/java/com/applovin/reactnative/AppLovinMAXAdView.java +123 -163
  6. package/android/src/main/java/com/applovin/reactnative/AppLovinMAXAdViewManager.java +24 -17
  7. package/android/src/main/java/com/applovin/reactnative/AppLovinMAXAdViewUiComponent.java +239 -0
  8. package/android/src/main/java/com/applovin/reactnative/AppLovinMAXModule.java +297 -336
  9. package/android/src/main/java/com/applovin/reactnative/AppLovinMAXNativeAdView.java +13 -12
  10. package/android/src/main/java/com/applovin/reactnative/AppLovinMAXNativeAdViewManager.java +11 -14
  11. package/android/src/main/java/com/applovin/reactnative/AppLovinMAXPackage.java +3 -3
  12. package/ios/AppLovinMAX.h +1 -1
  13. package/ios/AppLovinMAX.m +62 -12
  14. package/ios/AppLovinMAXAdView.h +12 -0
  15. package/ios/AppLovinMAXAdView.m +120 -142
  16. package/ios/AppLovinMAXAdViewUIComponent.h +27 -0
  17. package/ios/AppLovinMAXAdViewUIComponent.m +199 -0
  18. package/package.json +94 -21
  19. package/react-native-applovin-max.podspec +29 -5
  20. package/src/AdView.tsx +83 -26
  21. package/src/AppLovinMAX.ts +1 -1
  22. package/src/InterstitialAd.ts +1 -3
  23. package/src/MRecAd.ts +2 -8
  24. package/src/TargetingData.ts +2 -15
  25. package/src/index.ts +9 -10
  26. package/src/nativeAd/NativeAdView.tsx +33 -49
  27. package/src/nativeAd/NativeAdViewComponents.tsx +22 -31
  28. package/src/types/AdViewProps.ts +29 -1
  29. package/android/.project +0 -17
  30. package/android/.settings/org.eclipse.buildship.core.prefs +0 -13
  31. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  32. package/android/gradle/wrapper/gradle-wrapper.properties +0 -6
  33. package/android/gradlew +0 -172
  34. package/android/gradlew.bat +0 -84
  35. package/ios/AppLovinMAX.xcodeproj/project.pbxproj +0 -368
  36. package/ios/AppLovinMAX.xcodeproj/xcshareddata/xcschemes/AppLovinMAX.xcscheme +0 -67
  37. package/ios/AppLovinMAX.xcworkspace/contents.xcworkspacedata +0 -10
  38. package/ios/AppLovinMAX.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  39. package/ios/Podfile +0 -40
  40. package/ios/Podfile.lock +0 -373
@@ -58,13 +58,13 @@ import com.facebook.react.bridge.WritableArray;
58
58
  import com.facebook.react.bridge.WritableMap;
59
59
 
60
60
  import java.util.ArrayList;
61
- import java.util.Collections;
62
61
  import java.util.HashMap;
63
62
  import java.util.HashSet;
64
63
  import java.util.List;
65
64
  import java.util.Map;
66
65
  import java.util.Set;
67
66
 
67
+ import androidx.annotation.NonNull;
68
68
  import androidx.annotation.Nullable;
69
69
 
70
70
  import static com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter;
@@ -73,9 +73,9 @@ import static com.facebook.react.modules.core.DeviceEventManagerModule.RCTDevice
73
73
  * Created by Thomas So on July 11 2020
74
74
  */
75
75
  public class AppLovinMAXModule
76
- extends ReactContextBaseJavaModule
77
- implements LifecycleEventListener,
78
- MaxAdListener, MaxAdViewAdListener, MaxRewardedAdListener, MaxAdRevenueListener
76
+ extends ReactContextBaseJavaModule
77
+ implements LifecycleEventListener,
78
+ MaxAdListener, MaxAdViewAdListener, MaxRewardedAdListener, MaxAdRevenueListener
79
79
  {
80
80
  private static final String SDK_TAG = "AppLovinSdk";
81
81
  private static final String TAG = "AppLovinMAXModule";
@@ -123,6 +123,9 @@ public class AppLovinMAXModule
123
123
  private static final String ON_APPOPEN_AD_HIDDEN_EVENT = "OnAppOpenAdHiddenEvent";
124
124
  private static final String ON_APPOPEN_AD_REVENUE_PAID = "OnAppOpenAdRevenuePaid";
125
125
 
126
+ private static final String ON_NATIVE_UI_COMPONENT_ADVIEW_AD_LOADED_EVENT = "OnNativeUIComponentAdviewAdLoadedEvent";
127
+ private static final String ON_NATIVE_UI_COMPONENT_ADVIEW_AD_LOAD_FAILED_EVENT = "OnNativeUIComponentAdviewAdLoadFailedEvent";
128
+
126
129
  private static final String TOP_CENTER = "top_center";
127
130
  private static final String TOP_LEFT = "top_left";
128
131
  private static final String TOP_RIGHT = "top_right";
@@ -137,7 +140,7 @@ public class AppLovinMAXModule
137
140
 
138
141
  public static AppLovinMAXModule instance;
139
142
  @Nullable
140
- private static Activity sCurrentActivity;
143
+ private static Activity currentActivity;
141
144
 
142
145
  // Parent Fields
143
146
  private AppLovinSdk sdk;
@@ -172,21 +175,18 @@ public class AppLovinMAXModule
172
175
  private List targetingInterestsToSet;
173
176
 
174
177
  // Fullscreen Ad Fields
175
- private final Map<String, MaxInterstitialAd> mInterstitials = new HashMap<>( 2 );
176
- private final Map<String, MaxRewardedAd> mRewardedAds = new HashMap<>( 2 );
177
- private final Map<String, MaxAppOpenAd> mAppOpenAds = new HashMap<>( 2 );
178
+ private final Map<String, MaxInterstitialAd> interstitials = new HashMap<>( 2 );
179
+ private final Map<String, MaxRewardedAd> rewardedAds = new HashMap<>( 2 );
180
+ private final Map<String, MaxAppOpenAd> appOpenAds = new HashMap<>( 2 );
178
181
 
179
182
  // Banner Fields
180
- private final Map<String, MaxAdView> mAdViews = new HashMap<>( 2 );
181
- private final Map<String, MaxAdFormat> mAdViewAdFormats = new HashMap<>( 2 );
182
- private final Map<String, String> mAdViewPositions = new HashMap<>( 2 );
183
- private final Map<String, Point> mAdViewOffsets = new HashMap<>( 2 );
184
- private final Map<String, Integer> mAdViewWidths = new HashMap<>( 2 );
185
- private final List<String> mAdUnitIdsToShowAfterCreate = new ArrayList<>( 2 );
186
- private final Set<String> mDisabledAdaptiveBannerAdUnitIds = new HashSet<>( 2 );
187
-
188
- // TODO: Remove when v11.0.0 SDKs are released
189
- public final static Map<String, MaxAdView> sAdViewsToRemove = Collections.synchronizedMap( new HashMap<>() );
183
+ private final Map<String, MaxAdView> adViews = new HashMap<>( 2 );
184
+ private final Map<String, MaxAdFormat> adViewAdFormats = new HashMap<>( 2 );
185
+ private final Map<String, String> adViewPositions = new HashMap<>( 2 );
186
+ private final Map<String, Point> adViewOffsets = new HashMap<>( 2 );
187
+ private final Map<String, Integer> adViewWidths = new HashMap<>( 2 );
188
+ private final List<String> adUnitIdsToShowAfterCreate = new ArrayList<>( 2 );
189
+ private final Set<String> disabledAdaptiveBannerAdUnitIds = new HashSet<>( 2 );
190
190
 
191
191
  public static AppLovinMAXModule getInstance()
192
192
  {
@@ -203,12 +203,13 @@ public class AppLovinMAXModule
203
203
  super( reactContext );
204
204
 
205
205
  instance = this;
206
- sCurrentActivity = reactContext.getCurrentActivity();
206
+ currentActivity = reactContext.getCurrentActivity();
207
207
 
208
208
  // Listening to Lifecycle Events
209
209
  reactContext.addLifecycleEventListener( this );
210
210
  }
211
211
 
212
+ @NonNull
212
213
  @Override
213
214
  public String getName()
214
215
  {
@@ -222,10 +223,10 @@ public class AppLovinMAXModule
222
223
  // To alleviate the issue - we will store as a static reference (WeakReference unfortunately did not suffice)
223
224
  if ( getReactApplicationContext().hasCurrentActivity() )
224
225
  {
225
- sCurrentActivity = getReactApplicationContext().getCurrentActivity();
226
+ currentActivity = getReactApplicationContext().getCurrentActivity();
226
227
  }
227
228
 
228
- return sCurrentActivity;
229
+ return currentActivity;
229
230
  }
230
231
 
231
232
  @ReactMethod
@@ -418,7 +419,7 @@ public class AppLovinMAXModule
418
419
  if ( newRotation != lastRotation )
419
420
  {
420
421
  lastRotation = newRotation;
421
- for ( final Map.Entry<String, MaxAdFormat> adUnitFormats : mAdViewAdFormats.entrySet() )
422
+ for ( final Map.Entry<String, MaxAdFormat> adUnitFormats : adViewAdFormats.entrySet() )
422
423
  {
423
424
  positionAdView( adUnitFormats.getKey(), adUnitFormats.getValue() );
424
425
  }
@@ -847,7 +848,7 @@ public class AppLovinMAXModule
847
848
  {
848
849
  if ( sdk == null )
849
850
  {
850
- if ( targetingKeywordsToSet == null || targetingKeywordsToSet.size() == 0 )
851
+ if ( targetingKeywordsToSet == null || targetingKeywordsToSet.isEmpty() )
851
852
  {
852
853
  promise.resolve( null );
853
854
  }
@@ -860,7 +861,7 @@ public class AppLovinMAXModule
860
861
 
861
862
  List<String> keywords = sdk.getTargetingData().getKeywords();
862
863
 
863
- if ( keywords == null || keywords.size() == 0 )
864
+ if ( keywords == null || keywords.isEmpty() )
864
865
  {
865
866
  promise.resolve( null );
866
867
  }
@@ -887,7 +888,7 @@ public class AppLovinMAXModule
887
888
  {
888
889
  if ( sdk == null )
889
890
  {
890
- if ( targetingInterestsToSet == null || targetingInterestsToSet.size() == 0 )
891
+ if ( targetingInterestsToSet == null || targetingInterestsToSet.isEmpty() )
891
892
  {
892
893
  promise.resolve( null );
893
894
  }
@@ -900,7 +901,7 @@ public class AppLovinMAXModule
900
901
 
901
902
  List<String> interests = sdk.getTargetingData().getInterests();
902
903
 
903
- if ( interests == null || interests.size() == 0 )
904
+ if ( interests == null || interests.isEmpty() )
904
905
  {
905
906
  promise.resolve( null );
906
907
  }
@@ -1056,7 +1057,7 @@ public class AppLovinMAXModule
1056
1057
  return;
1057
1058
  }
1058
1059
 
1059
- updateAdViewPosition( adUnitId, mAdViewPositions.get( adUnitId ), getOffsetPixels( x, y, getReactApplicationContext() ), getDeviceSpecificBannerAdViewAdFormat() );
1060
+ updateAdViewPosition( adUnitId, adViewPositions.get( adUnitId ), getOffsetPixels( x, y, getReactApplicationContext() ), getDeviceSpecificBannerAdViewAdFormat() );
1060
1061
  }
1061
1062
 
1062
1063
  @ReactMethod
@@ -1512,6 +1513,40 @@ public class AppLovinMAXModule
1512
1513
  appOpenAd.setLocalExtraParameter( entry.getKey(), entry.getValue() );
1513
1514
  }
1514
1515
 
1516
+ // ADVIEW PRELOADING
1517
+
1518
+ @ReactMethod
1519
+ public void preloadNativeUIComponentAdView(final String adUnitId, final String adFormatStr, final String placement, final String customData, final ReadableMap extraParameterMap, final ReadableMap localExtraParameterMap, final Promise promise)
1520
+ {
1521
+ MaxAdFormat adFormat;
1522
+
1523
+ if ( MaxAdFormat.BANNER.getLabel().equals( adFormatStr ) )
1524
+ {
1525
+ adFormat = getDeviceSpecificBannerAdViewAdFormat();
1526
+ }
1527
+ else if ( MaxAdFormat.MREC.getLabel().equals( adFormatStr ) )
1528
+ {
1529
+ adFormat = MaxAdFormat.MREC;
1530
+ }
1531
+ else
1532
+ {
1533
+ promise.reject( new IllegalStateException( "invalid ad format: " + adFormatStr ) );
1534
+ return;
1535
+ }
1536
+
1537
+ final MaxAdFormat finalAdFormat = adFormat;
1538
+ final Map<String, Object> extraParameters = ( extraParameterMap != null ) ? extraParameterMap.toHashMap() : null;
1539
+ final Map<String, Object> localExtraParameters = ( localExtraParameterMap != null ) ? localExtraParameterMap.toHashMap() : null;
1540
+
1541
+ getReactApplicationContext().runOnUiQueueThread( () -> AppLovinMAXAdView.preloadNativeUIComponentAdView( adUnitId, finalAdFormat, placement, customData, extraParameters, localExtraParameters, promise, getReactApplicationContext() ) );
1542
+ }
1543
+
1544
+ @ReactMethod
1545
+ public void destroyNativeUIComponentAdView(final String adUnitId, final Promise promise)
1546
+ {
1547
+ getReactApplicationContext().runOnUiQueueThread( () -> AppLovinMAXAdView.destroyNativeUIComponentAdView( adUnitId, promise ) );
1548
+ }
1549
+
1515
1550
  // AD CALLBACKS
1516
1551
 
1517
1552
  @Override
@@ -1523,7 +1558,7 @@ public class AppLovinMAXModule
1523
1558
  {
1524
1559
  name = ( MaxAdFormat.MREC == adFormat ) ? ON_MREC_AD_LOADED_EVENT : ON_BANNER_AD_LOADED_EVENT;
1525
1560
 
1526
- String adViewPosition = mAdViewPositions.get( ad.getAdUnitId() );
1561
+ String adViewPosition = adViewPositions.get( ad.getAdUnitId() );
1527
1562
  if ( AppLovinSdkUtils.isValidString( adViewPosition ) )
1528
1563
  {
1529
1564
  // Only position ad if not native UI component
@@ -1560,7 +1595,7 @@ public class AppLovinMAXModule
1560
1595
  }
1561
1596
 
1562
1597
  @Override
1563
- public void onAdLoadFailed(final String adUnitId, final MaxError error)
1598
+ public void onAdLoadFailed(@NonNull final String adUnitId, @NonNull final MaxError error)
1564
1599
  {
1565
1600
  if ( TextUtils.isEmpty( adUnitId ) )
1566
1601
  {
@@ -1569,19 +1604,19 @@ public class AppLovinMAXModule
1569
1604
  }
1570
1605
 
1571
1606
  String name;
1572
- if ( mAdViews.containsKey( adUnitId ) )
1607
+ if ( adViews.containsKey( adUnitId ) )
1573
1608
  {
1574
- name = ( MaxAdFormat.MREC == mAdViewAdFormats.get( adUnitId ) ) ? ON_MREC_AD_LOAD_FAILED_EVENT : ON_BANNER_AD_LOAD_FAILED_EVENT;
1609
+ name = ( MaxAdFormat.MREC == adViewAdFormats.get( adUnitId ) ) ? ON_MREC_AD_LOAD_FAILED_EVENT : ON_BANNER_AD_LOAD_FAILED_EVENT;
1575
1610
  }
1576
- else if ( mInterstitials.containsKey( adUnitId ) )
1611
+ else if ( interstitials.containsKey( adUnitId ) )
1577
1612
  {
1578
1613
  name = ON_INTERSTITIAL_LOAD_FAILED_EVENT;
1579
1614
  }
1580
- else if ( mRewardedAds.containsKey( adUnitId ) )
1615
+ else if ( rewardedAds.containsKey( adUnitId ) )
1581
1616
  {
1582
1617
  name = ON_REWARDED_AD_LOAD_FAILED_EVENT;
1583
1618
  }
1584
- else if ( mAppOpenAds.containsKey( adUnitId ) )
1619
+ else if ( appOpenAds.containsKey( adUnitId ) )
1585
1620
  {
1586
1621
  name = ON_APPOPEN_AD_LOAD_FAILED_EVENT;
1587
1622
  }
@@ -1658,7 +1693,7 @@ public class AppLovinMAXModule
1658
1693
  }
1659
1694
 
1660
1695
  @Override
1661
- public void onAdDisplayFailed(final MaxAd ad, final MaxError error)
1696
+ public void onAdDisplayFailed(final MaxAd ad, @NonNull final MaxError error)
1662
1697
  {
1663
1698
  // BMLs do not support [DISPLAY] events
1664
1699
  final MaxAdFormat adFormat = ad.getFormat();
@@ -1766,19 +1801,19 @@ public class AppLovinMAXModule
1766
1801
  }
1767
1802
 
1768
1803
  @Override
1769
- public void onRewardedVideoCompleted(final MaxAd ad)
1804
+ public void onRewardedVideoCompleted(@NonNull final MaxAd ad)
1770
1805
  {
1771
1806
  // This event is not forwarded
1772
1807
  }
1773
1808
 
1774
1809
  @Override
1775
- public void onRewardedVideoStarted(final MaxAd ad)
1810
+ public void onRewardedVideoStarted(@NonNull final MaxAd ad)
1776
1811
  {
1777
1812
  // This event is not forwarded
1778
1813
  }
1779
1814
 
1780
1815
  @Override
1781
- public void onUserRewarded(final MaxAd ad, final MaxReward reward)
1816
+ public void onUserRewarded(final MaxAd ad, @NonNull final MaxReward reward)
1782
1817
  {
1783
1818
  final MaxAdFormat adFormat = ad.getFormat();
1784
1819
  if ( adFormat != MaxAdFormat.REWARDED )
@@ -1787,8 +1822,8 @@ public class AppLovinMAXModule
1787
1822
  return;
1788
1823
  }
1789
1824
 
1790
- final String rewardLabel = reward != null ? reward.getLabel() : "";
1791
- final int rewardAmount = reward != null ? reward.getAmount() : 0;
1825
+ final String rewardLabel = reward.getLabel();
1826
+ final int rewardAmount = reward.getAmount();
1792
1827
 
1793
1828
  WritableMap params = getAdInfo( ad );
1794
1829
  params.putString( "rewardLabel", rewardLabel );
@@ -1801,353 +1836,301 @@ public class AppLovinMAXModule
1801
1836
  private void createAdView(final String adUnitId, final MaxAdFormat adFormat, final String adViewPosition, final Point adViewOffsetPixels)
1802
1837
  {
1803
1838
  // Run on main thread to ensure there are no concurrency issues with other ad view methods
1804
- getReactApplicationContext().runOnUiQueueThread( new Runnable()
1805
- {
1806
- @Override
1807
- public void run()
1808
- {
1809
- d( "Creating " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\", position: \"" + adViewPosition + "\", and offset: " + adViewOffsetPixels );
1839
+ getReactApplicationContext().runOnUiQueueThread( () -> {
1810
1840
 
1811
- // Retrieve ad view from the map
1812
- final MaxAdView adView = retrieveAdView( adUnitId, adFormat, adViewPosition, adViewOffsetPixels );
1813
- if ( adView == null )
1814
- {
1815
- e( adFormat.getLabel() + " does not exist" );
1816
- return;
1817
- }
1841
+ d( "Creating " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\", position: \"" + adViewPosition + "\", and offset: " + adViewOffsetPixels );
1842
+
1843
+ // Retrieve ad view from the map
1844
+ final MaxAdView adView = retrieveAdView( adUnitId, adFormat, adViewPosition, adViewOffsetPixels );
1845
+ if ( adView == null )
1846
+ {
1847
+ e( adFormat.getLabel() + " does not exist" );
1848
+ return;
1849
+ }
1818
1850
 
1819
- adView.setVisibility( View.GONE );
1851
+ adView.setVisibility( View.GONE );
1820
1852
 
1821
- if ( adView.getParent() == null )
1822
- {
1823
- maybeAttachToCurrentActivity( adView );
1853
+ if ( adView.getParent() == null )
1854
+ {
1855
+ maybeAttachToCurrentActivity( adView );
1824
1856
 
1825
- // Position ad view immediately so if publisher sets color before ad loads, it will not be the size of the screen
1826
- mAdViewAdFormats.put( adUnitId, adFormat );
1827
- positionAdView( adUnitId, adFormat );
1828
- }
1857
+ // Position ad view immediately so if publisher sets color before ad loads, it will not be the size of the screen
1858
+ adViewAdFormats.put( adUnitId, adFormat );
1859
+ positionAdView( adUnitId, adFormat );
1860
+ }
1829
1861
 
1830
- adView.loadAd();
1862
+ adView.loadAd();
1831
1863
 
1832
- // The publisher may have requested to show the banner before it was created. Now that the banner is created, show it.
1833
- if ( mAdUnitIdsToShowAfterCreate.contains( adUnitId ) )
1834
- {
1835
- showAdView( adUnitId, adFormat );
1836
- mAdUnitIdsToShowAfterCreate.remove( adUnitId );
1837
- }
1864
+ // The publisher may have requested to show the banner before it was created. Now that the banner is created, show it.
1865
+ if ( adUnitIdsToShowAfterCreate.contains( adUnitId ) )
1866
+ {
1867
+ showAdView( adUnitId, adFormat );
1868
+ adUnitIdsToShowAfterCreate.remove( adUnitId );
1838
1869
  }
1839
1870
  } );
1840
1871
  }
1841
1872
 
1842
1873
  private void setAdViewPlacement(final String adUnitId, final MaxAdFormat adFormat, final String placement)
1843
1874
  {
1844
- getReactApplicationContext().runOnUiQueueThread( new Runnable()
1845
- {
1846
- @Override
1847
- public void run()
1848
- {
1849
- d( "Setting placement \"" + placement + "\" for " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\"" );
1875
+ getReactApplicationContext().runOnUiQueueThread( () -> {
1850
1876
 
1851
- final MaxAdView adView = retrieveAdView( adUnitId, adFormat, "", DEFAULT_AD_VIEW_OFFSET );
1852
- if ( adView == null )
1853
- {
1854
- e( adFormat.getLabel() + " does not exist" );
1855
- return;
1856
- }
1877
+ d( "Setting placement \"" + placement + "\" for " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\"" );
1857
1878
 
1858
- adView.setPlacement( placement );
1879
+ final MaxAdView adView = retrieveAdView( adUnitId, adFormat, "", DEFAULT_AD_VIEW_OFFSET );
1880
+ if ( adView == null )
1881
+ {
1882
+ e( adFormat.getLabel() + " does not exist" );
1883
+ return;
1859
1884
  }
1885
+
1886
+ adView.setPlacement( placement );
1860
1887
  } );
1861
1888
  }
1862
1889
 
1863
1890
  private void setAdViewCustomData(final String adUnitId, final MaxAdFormat adFormat, final String customData)
1864
1891
  {
1865
- getReactApplicationContext().runOnUiQueueThread( new Runnable()
1866
- {
1867
- @Override
1868
- public void run()
1869
- {
1870
- d( "Setting custom data \"" + customData + "\" for " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\"" );
1892
+ getReactApplicationContext().runOnUiQueueThread( () -> {
1871
1893
 
1872
- final MaxAdView adView = retrieveAdView( adUnitId, adFormat, "", DEFAULT_AD_VIEW_OFFSET );
1873
- if ( adView == null )
1874
- {
1875
- e( adFormat.getLabel() + " does not exist" );
1876
- return;
1877
- }
1894
+ d( "Setting custom data \"" + customData + "\" for " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\"" );
1878
1895
 
1879
- adView.setCustomData( customData );
1896
+ final MaxAdView adView = retrieveAdView( adUnitId, adFormat, "", DEFAULT_AD_VIEW_OFFSET );
1897
+ if ( adView == null )
1898
+ {
1899
+ e( adFormat.getLabel() + " does not exist" );
1900
+ return;
1880
1901
  }
1902
+
1903
+ adView.setCustomData( customData );
1881
1904
  } );
1882
1905
  }
1883
1906
 
1884
1907
  private void setAdViewWidth(final String adUnitId, final int widthDp, final MaxAdFormat adFormat)
1885
1908
  {
1886
- getReactApplicationContext().runOnUiQueueThread( new Runnable()
1887
- {
1888
- @Override
1889
- public void run()
1890
- {
1891
- d( "Setting width " + widthDp + " for \"" + adFormat + "\" with ad unit identifier \"" + adUnitId + "\"" );
1909
+ getReactApplicationContext().runOnUiQueueThread( () -> {
1892
1910
 
1893
- int minWidthDp = adFormat.getSize().getWidth();
1894
- if ( widthDp < minWidthDp )
1895
- {
1896
- e( "The provided width: " + widthDp + "dp is smaller than the minimum required width: " + minWidthDp + "dp for ad format: " + adFormat + ". Please set the width higher than the minimum required." );
1897
- }
1911
+ d( "Setting width " + widthDp + " for \"" + adFormat + "\" with ad unit identifier \"" + adUnitId + "\"" );
1898
1912
 
1899
- mAdViewWidths.put( adUnitId, widthDp );
1900
- positionAdView( adUnitId, adFormat );
1913
+ int minWidthDp = adFormat.getSize().getWidth();
1914
+ if ( widthDp < minWidthDp )
1915
+ {
1916
+ e( "The provided width: " + widthDp + "dp is smaller than the minimum required width: " + minWidthDp + "dp for ad format: " + adFormat + ". Please set the width higher than the minimum required." );
1901
1917
  }
1918
+
1919
+ adViewWidths.put( adUnitId, widthDp );
1920
+ positionAdView( adUnitId, adFormat );
1902
1921
  } );
1903
1922
  }
1904
1923
 
1905
1924
  private void updateAdViewPosition(final String adUnitId, final String adViewPosition, final Point offsetPixels, final MaxAdFormat adFormat)
1906
1925
  {
1907
- getReactApplicationContext().runOnUiQueueThread( new Runnable()
1908
- {
1909
- @Override
1910
- public void run()
1911
- {
1912
- d( "Updating " + adFormat.getLabel() + " position to \"" + adViewPosition + "\" for ad unit id \"" + adUnitId + "\"" );
1926
+ getReactApplicationContext().runOnUiQueueThread( () -> {
1913
1927
 
1914
- // Retrieve ad view from the map
1915
- final MaxAdView adView = retrieveAdView( adUnitId, adFormat );
1916
- if ( adView == null )
1917
- {
1918
- e( adFormat.getLabel() + " does not exist" );
1919
- return;
1920
- }
1928
+ d( "Updating " + adFormat.getLabel() + " position to \"" + adViewPosition + "\" for ad unit id \"" + adUnitId + "\"" );
1921
1929
 
1922
- mAdViewPositions.put( adUnitId, adViewPosition );
1923
- mAdViewOffsets.put( adUnitId, offsetPixels );
1924
- positionAdView( adUnitId, adFormat );
1930
+ // Retrieve ad view from the map
1931
+ final MaxAdView adView = retrieveAdView( adUnitId, adFormat );
1932
+ if ( adView == null )
1933
+ {
1934
+ e( adFormat.getLabel() + " does not exist" );
1935
+ return;
1925
1936
  }
1937
+
1938
+ adViewPositions.put( adUnitId, adViewPosition );
1939
+ adViewOffsets.put( adUnitId, offsetPixels );
1940
+ positionAdView( adUnitId, adFormat );
1926
1941
  } );
1927
1942
  }
1928
1943
 
1929
1944
  private void showAdView(final String adUnitId, final MaxAdFormat adFormat)
1930
1945
  {
1931
- getReactApplicationContext().runOnUiQueueThread( new Runnable()
1932
- {
1933
- @Override
1934
- public void run()
1935
- {
1936
- d( "Showing " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\"" );
1937
-
1938
- final MaxAdView adView = retrieveAdView( adUnitId, adFormat );
1939
- if ( adView == null )
1940
- {
1941
- e( adFormat.getLabel() + " does not exist for ad unit id " + adUnitId );
1946
+ getReactApplicationContext().runOnUiQueueThread( () -> {
1942
1947
 
1943
- // The adView has not yet been created. Store the ad unit ID, so that it can be displayed once the banner has been created.
1944
- mAdUnitIdsToShowAfterCreate.add( adUnitId );
1945
- return;
1946
- }
1948
+ d( "Showing " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\"" );
1947
1949
 
1948
- maybeAttachToCurrentActivity( adView );
1950
+ final MaxAdView adView = retrieveAdView( adUnitId, adFormat );
1951
+ if ( adView == null )
1952
+ {
1953
+ e( adFormat.getLabel() + " does not exist for ad unit id " + adUnitId );
1949
1954
 
1950
- adView.setVisibility( View.VISIBLE );
1951
- adView.startAutoRefresh();
1955
+ // The adView has not yet been created. Store the ad unit ID, so that it can be displayed once the banner has been created.
1956
+ adUnitIdsToShowAfterCreate.add( adUnitId );
1957
+ return;
1952
1958
  }
1959
+
1960
+ maybeAttachToCurrentActivity( adView );
1961
+
1962
+ adView.setVisibility( View.VISIBLE );
1963
+ adView.startAutoRefresh();
1953
1964
  } );
1954
1965
  }
1955
1966
 
1956
1967
  private void hideAdView(final String adUnitId, final MaxAdFormat adFormat)
1957
1968
  {
1958
- getReactApplicationContext().runOnUiQueueThread( new Runnable()
1959
- {
1960
- @Override
1961
- public void run()
1962
- {
1963
- d( "Hiding " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\"" );
1964
- mAdUnitIdsToShowAfterCreate.remove( adUnitId );
1969
+ getReactApplicationContext().runOnUiQueueThread( () -> {
1965
1970
 
1966
- final MaxAdView adView = retrieveAdView( adUnitId, adFormat );
1967
- if ( adView == null )
1968
- {
1969
- e( adFormat.getLabel() + " does not exist" );
1970
- return;
1971
- }
1971
+ d( "Hiding " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\"" );
1972
+ adUnitIdsToShowAfterCreate.remove( adUnitId );
1972
1973
 
1973
- adView.setVisibility( View.GONE );
1974
- adView.stopAutoRefresh();
1974
+ final MaxAdView adView = retrieveAdView( adUnitId, adFormat );
1975
+ if ( adView == null )
1976
+ {
1977
+ e( adFormat.getLabel() + " does not exist" );
1978
+ return;
1975
1979
  }
1980
+
1981
+ adView.setVisibility( View.GONE );
1982
+ adView.stopAutoRefresh();
1976
1983
  } );
1977
1984
  }
1978
1985
 
1979
1986
  private void destroyAdView(final String adUnitId, final MaxAdFormat adFormat)
1980
1987
  {
1981
- getReactApplicationContext().runOnUiQueueThread( new Runnable()
1982
- {
1983
- @Override
1984
- public void run()
1985
- {
1986
- d( "Destroying " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\"" );
1987
-
1988
- final MaxAdView adView = retrieveAdView( adUnitId, adFormat );
1989
- if ( adView == null )
1990
- {
1991
- e( adFormat.getLabel() + " does not exist" );
1992
- return;
1993
- }
1988
+ getReactApplicationContext().runOnUiQueueThread( () -> {
1994
1989
 
1995
- final ViewParent parent = adView.getParent();
1996
- if ( parent instanceof ViewGroup )
1997
- {
1998
- ( (ViewGroup) parent ).removeView( adView );
1999
- }
1990
+ d( "Destroying " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\"" );
2000
1991
 
2001
- adView.setListener( null );
2002
- adView.setRevenueListener( null );
2003
- adView.destroy();
1992
+ final MaxAdView adView = retrieveAdView( adUnitId, adFormat );
1993
+ if ( adView == null )
1994
+ {
1995
+ e( adFormat.getLabel() + " does not exist" );
1996
+ return;
1997
+ }
2004
1998
 
2005
- mAdViews.remove( adUnitId );
2006
- mAdViewAdFormats.remove( adUnitId );
2007
- mAdViewPositions.remove( adUnitId );
2008
- mAdViewOffsets.remove( adUnitId );
2009
- mAdViewWidths.remove( adUnitId );
1999
+ final ViewParent parent = adView.getParent();
2000
+ if ( parent instanceof ViewGroup )
2001
+ {
2002
+ ( (ViewGroup) parent ).removeView( adView );
2010
2003
  }
2004
+
2005
+ adView.setListener( null );
2006
+ adView.setRevenueListener( null );
2007
+ adView.destroy();
2008
+
2009
+ adViews.remove( adUnitId );
2010
+ adViewAdFormats.remove( adUnitId );
2011
+ adViewPositions.remove( adUnitId );
2012
+ adViewOffsets.remove( adUnitId );
2013
+ adViewWidths.remove( adUnitId );
2011
2014
  } );
2012
2015
  }
2013
2016
 
2014
2017
  private void setAdViewBackgroundColor(final String adUnitId, final MaxAdFormat adFormat, final String hexColorCode)
2015
2018
  {
2016
- getReactApplicationContext().runOnUiQueueThread( new Runnable()
2017
- {
2018
- @Override
2019
- public void run()
2020
- {
2021
- d( "Setting " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\" to color: " + hexColorCode );
2019
+ getReactApplicationContext().runOnUiQueueThread( () -> {
2022
2020
 
2023
- final MaxAdView adView = retrieveAdView( adUnitId, adFormat );
2024
- if ( adView == null )
2025
- {
2026
- e( adFormat.getLabel() + " does not exist" );
2027
- return;
2028
- }
2021
+ d( "Setting " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\" to color: " + hexColorCode );
2029
2022
 
2030
- adView.setBackgroundColor( Color.parseColor( hexColorCode ) );
2023
+ final MaxAdView adView = retrieveAdView( adUnitId, adFormat );
2024
+ if ( adView == null )
2025
+ {
2026
+ e( adFormat.getLabel() + " does not exist" );
2027
+ return;
2031
2028
  }
2029
+
2030
+ adView.setBackgroundColor( Color.parseColor( hexColorCode ) );
2032
2031
  } );
2033
2032
  }
2034
2033
 
2035
2034
  private void setAdViewExtraParameters(final String adUnitId, final MaxAdFormat adFormat, final String key, final String value)
2036
2035
  {
2037
- getReactApplicationContext().runOnUiQueueThread( new Runnable()
2038
- {
2039
- @Override
2040
- public void run()
2041
- {
2042
- d( "Setting " + adFormat.getLabel() + " extra with key: \"" + key + "\" value: " + value );
2036
+ getReactApplicationContext().runOnUiQueueThread( () -> {
2043
2037
 
2044
- // Retrieve ad view from the map
2045
- final MaxAdView adView = retrieveAdView( adUnitId, adFormat );
2046
- if ( adView == null )
2047
- {
2048
- e( adFormat.getLabel() + " does not exist" );
2049
- return;
2050
- }
2038
+ d( "Setting " + adFormat.getLabel() + " extra with key: \"" + key + "\" value: " + value );
2051
2039
 
2052
- adView.setExtraParameter( key, value );
2040
+ // Retrieve ad view from the map
2041
+ final MaxAdView adView = retrieveAdView( adUnitId, adFormat );
2042
+ if ( adView == null )
2043
+ {
2044
+ e( adFormat.getLabel() + " does not exist" );
2045
+ return;
2046
+ }
2053
2047
 
2054
- // Handle local changes as needed
2055
- if ( "force_banner".equalsIgnoreCase( key ) && MaxAdFormat.MREC != adFormat )
2056
- {
2057
- final MaxAdFormat forcedAdFormat;
2048
+ adView.setExtraParameter( key, value );
2058
2049
 
2059
- boolean shouldForceBanner = Boolean.parseBoolean( value );
2060
- if ( shouldForceBanner )
2061
- {
2062
- forcedAdFormat = MaxAdFormat.BANNER;
2063
- }
2064
- else
2065
- {
2066
- forcedAdFormat = getDeviceSpecificBannerAdViewAdFormat();
2067
- }
2050
+ // Handle local changes as needed
2051
+ if ( "force_banner".equalsIgnoreCase( key ) && MaxAdFormat.MREC != adFormat )
2052
+ {
2053
+ final MaxAdFormat forcedAdFormat;
2068
2054
 
2069
- mAdViewAdFormats.put( adUnitId, forcedAdFormat );
2070
- positionAdView( adUnitId, forcedAdFormat );
2055
+ boolean shouldForceBanner = Boolean.parseBoolean( value );
2056
+ if ( shouldForceBanner )
2057
+ {
2058
+ forcedAdFormat = MaxAdFormat.BANNER;
2071
2059
  }
2072
- else if ( "adaptive_banner".equalsIgnoreCase( key ) )
2060
+ else
2073
2061
  {
2074
- boolean useAdaptiveBannerAdSize = Boolean.parseBoolean( value );
2075
- if ( useAdaptiveBannerAdSize )
2076
- {
2077
- mDisabledAdaptiveBannerAdUnitIds.remove( adUnitId );
2078
- }
2079
- else
2080
- {
2081
- mDisabledAdaptiveBannerAdUnitIds.add( adUnitId );
2082
- }
2062
+ forcedAdFormat = getDeviceSpecificBannerAdViewAdFormat();
2063
+ }
2083
2064
 
2084
- positionAdView( adUnitId, adFormat );
2065
+ adViewAdFormats.put( adUnitId, forcedAdFormat );
2066
+ positionAdView( adUnitId, forcedAdFormat );
2067
+ }
2068
+ else if ( "adaptive_banner".equalsIgnoreCase( key ) )
2069
+ {
2070
+ boolean useAdaptiveBannerAdSize = Boolean.parseBoolean( value );
2071
+ if ( useAdaptiveBannerAdSize )
2072
+ {
2073
+ disabledAdaptiveBannerAdUnitIds.remove( adUnitId );
2074
+ }
2075
+ else
2076
+ {
2077
+ disabledAdaptiveBannerAdUnitIds.add( adUnitId );
2085
2078
  }
2079
+
2080
+ positionAdView( adUnitId, adFormat );
2086
2081
  }
2087
2082
  } );
2088
2083
  }
2089
2084
 
2090
2085
  private void setAdViewLocalExtraParameters(final String adUnitId, final MaxAdFormat adFormat, final String key, final Object value)
2091
2086
  {
2092
- getReactApplicationContext().runOnUiQueueThread( new Runnable()
2093
- {
2094
- @Override
2095
- public void run()
2096
- {
2097
- d( "Setting " + adFormat.getLabel() + " local extra with key: \"" + key + "\" value: " + value );
2087
+ getReactApplicationContext().runOnUiQueueThread( () -> {
2098
2088
 
2099
- // Retrieve ad view from the map
2100
- final MaxAdView adView = retrieveAdView( adUnitId, adFormat );
2101
- if ( adView == null )
2102
- {
2103
- e( adFormat.getLabel() + " does not exist" );
2104
- return;
2105
- }
2089
+ d( "Setting " + adFormat.getLabel() + " local extra with key: \"" + key + "\" value: " + value );
2106
2090
 
2107
- adView.setLocalExtraParameter( key, value );
2091
+ // Retrieve ad view from the map
2092
+ final MaxAdView adView = retrieveAdView( adUnitId, adFormat );
2093
+ if ( adView == null )
2094
+ {
2095
+ e( adFormat.getLabel() + " does not exist" );
2096
+ return;
2108
2097
  }
2098
+
2099
+ adView.setLocalExtraParameter( key, value );
2109
2100
  } );
2110
2101
  }
2111
2102
 
2112
2103
  private void startAutoRefresh(final String adUnitId, final MaxAdFormat adFormat)
2113
2104
  {
2114
- getReactApplicationContext().runOnUiQueueThread( new Runnable()
2115
- {
2116
- @Override
2117
- public void run()
2118
- {
2119
- d( "Starting auto refresh " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\"" );
2105
+ getReactApplicationContext().runOnUiQueueThread( () -> {
2120
2106
 
2121
- final MaxAdView adView = retrieveAdView( adUnitId, adFormat );
2122
- if ( adView == null )
2123
- {
2124
- e( adFormat.getLabel() + " does not exist" );
2125
- return;
2126
- }
2107
+ d( "Starting auto refresh " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\"" );
2127
2108
 
2128
- adView.startAutoRefresh();
2109
+ final MaxAdView adView = retrieveAdView( adUnitId, adFormat );
2110
+ if ( adView == null )
2111
+ {
2112
+ e( adFormat.getLabel() + " does not exist" );
2113
+ return;
2129
2114
  }
2115
+
2116
+ adView.startAutoRefresh();
2130
2117
  } );
2131
2118
  }
2132
2119
 
2133
2120
  private void stopAutoRefresh(final String adUnitId, final MaxAdFormat adFormat)
2134
2121
  {
2135
- getReactApplicationContext().runOnUiQueueThread( new Runnable()
2136
- {
2137
- @Override
2138
- public void run()
2139
- {
2140
- d( "Stopping auto refresh " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\"" );
2122
+ getReactApplicationContext().runOnUiQueueThread( () -> {
2141
2123
 
2142
- final MaxAdView adView = retrieveAdView( adUnitId, adFormat );
2143
- if ( adView == null )
2144
- {
2145
- e( adFormat.getLabel() + " does not exist" );
2146
- return;
2147
- }
2124
+ d( "Stopping auto refresh " + adFormat.getLabel() + " with ad unit id \"" + adUnitId + "\"" );
2148
2125
 
2149
- adView.stopAutoRefresh();
2126
+ final MaxAdView adView = retrieveAdView( adUnitId, adFormat );
2127
+ if ( adView == null )
2128
+ {
2129
+ e( adFormat.getLabel() + " does not exist" );
2130
+ return;
2150
2131
  }
2132
+
2133
+ adView.stopAutoRefresh();
2151
2134
  } );
2152
2135
  }
2153
2136
 
@@ -2177,14 +2160,14 @@ public class AppLovinMAXModule
2177
2160
  return null;
2178
2161
  }
2179
2162
 
2180
- MaxInterstitialAd result = mInterstitials.get( adUnitId );
2163
+ MaxInterstitialAd result = interstitials.get( adUnitId );
2181
2164
  if ( result == null )
2182
2165
  {
2183
2166
  result = new MaxInterstitialAd( adUnitId, sdk, currentActivity );
2184
2167
  result.setListener( this );
2185
2168
  result.setRevenueListener( this );
2186
2169
 
2187
- mInterstitials.put( adUnitId, result );
2170
+ interstitials.put( adUnitId, result );
2188
2171
  }
2189
2172
 
2190
2173
  return result;
@@ -2200,14 +2183,14 @@ public class AppLovinMAXModule
2200
2183
  return null;
2201
2184
  }
2202
2185
 
2203
- MaxRewardedAd result = mRewardedAds.get( adUnitId );
2186
+ MaxRewardedAd result = rewardedAds.get( adUnitId );
2204
2187
  if ( result == null )
2205
2188
  {
2206
2189
  result = MaxRewardedAd.getInstance( adUnitId, sdk, currentActivity );
2207
2190
  result.setListener( this );
2208
2191
  result.setRevenueListener( this );
2209
2192
 
2210
- mRewardedAds.put( adUnitId, result );
2193
+ rewardedAds.put( adUnitId, result );
2211
2194
  }
2212
2195
 
2213
2196
  return result;
@@ -2215,14 +2198,14 @@ public class AppLovinMAXModule
2215
2198
 
2216
2199
  private MaxAppOpenAd retrieveAppOpenAd(final String adUnitId)
2217
2200
  {
2218
- MaxAppOpenAd result = mAppOpenAds.get( adUnitId );
2201
+ MaxAppOpenAd result = appOpenAds.get( adUnitId );
2219
2202
  if ( result == null )
2220
2203
  {
2221
2204
  result = new MaxAppOpenAd( adUnitId, sdk );
2222
2205
  result.setListener( this );
2223
2206
  result.setRevenueListener( this );
2224
2207
 
2225
- mAppOpenAds.put( adUnitId, result );
2208
+ appOpenAds.put( adUnitId, result );
2226
2209
  }
2227
2210
 
2228
2211
  return result;
@@ -2235,7 +2218,7 @@ public class AppLovinMAXModule
2235
2218
 
2236
2219
  private MaxAdView retrieveAdView(String adUnitId, MaxAdFormat adFormat, String adViewPosition, Point adViewOffsetPixels)
2237
2220
  {
2238
- MaxAdView result = mAdViews.get( adUnitId );
2221
+ MaxAdView result = adViews.get( adUnitId );
2239
2222
  if ( result == null && adViewPosition != null && adViewOffsetPixels != null )
2240
2223
  {
2241
2224
  result = new MaxAdView( adUnitId, adFormat, sdk, getReactApplicationContext() );
@@ -2245,9 +2228,9 @@ public class AppLovinMAXModule
2245
2228
  // Set this extra parameter to work around a SDK bug that ignores calls to stopAutoRefresh()
2246
2229
  result.setExtraParameter( "allow_pause_auto_refresh_immediately", "true" );
2247
2230
 
2248
- mAdViews.put( adUnitId, result );
2249
- mAdViewPositions.put( adUnitId, adViewPosition );
2250
- mAdViewOffsets.put( adUnitId, adViewOffsetPixels );
2231
+ adViews.put( adUnitId, result );
2232
+ adViewPositions.put( adUnitId, adViewPosition );
2233
+ adViewOffsets.put( adUnitId, adViewOffsetPixels );
2251
2234
  }
2252
2235
 
2253
2236
  return result;
@@ -2267,17 +2250,20 @@ public class AppLovinMAXModule
2267
2250
  return;
2268
2251
  }
2269
2252
 
2270
- final ViewParent parent = adView.getParent();
2271
- if ( !( parent instanceof RelativeLayout ) ) return;
2253
+ final RelativeLayout relativeLayout = (RelativeLayout) adView.getParent();
2254
+ if ( relativeLayout == null )
2255
+ {
2256
+ e( adFormat.getLabel() + "'s parent does not exist" );
2257
+ return;
2258
+ }
2272
2259
 
2273
- final RelativeLayout relativeLayout = (RelativeLayout) parent;
2274
2260
  final Rect windowRect = new Rect();
2275
2261
  relativeLayout.getWindowVisibleDisplayFrame( windowRect );
2276
2262
 
2277
- final String adViewPosition = mAdViewPositions.get( adUnitId );
2278
- final Point adViewOffset = mAdViewOffsets.get( adUnitId );
2279
- final boolean isAdaptiveBannerDisabled = mDisabledAdaptiveBannerAdUnitIds.contains( adUnitId );
2280
- final boolean isWidthDpOverridden = mAdViewWidths.containsKey( adUnitId );
2263
+ final String adViewPosition = adViewPositions.get( adUnitId );
2264
+ final Point adViewOffset = adViewOffsets.get( adUnitId );
2265
+ final boolean isAdaptiveBannerDisabled = disabledAdaptiveBannerAdUnitIds.contains( adUnitId );
2266
+ final boolean isWidthDpOverridden = adViewWidths.containsKey( adUnitId );
2281
2267
 
2282
2268
  //
2283
2269
  // Determine ad width
@@ -2287,7 +2273,7 @@ public class AppLovinMAXModule
2287
2273
  // Check if publisher has overridden width as dp
2288
2274
  if ( isWidthDpOverridden )
2289
2275
  {
2290
- adViewWidthDp = mAdViewWidths.get( adUnitId );
2276
+ adViewWidthDp = adViewWidths.get( adUnitId );
2291
2277
  }
2292
2278
  // Top center / bottom center stretches full screen
2293
2279
  else if ( TOP_CENTER.equalsIgnoreCase( adViewPosition ) || BOTTOM_CENTER.equalsIgnoreCase( adViewPosition ) )
@@ -2390,7 +2376,7 @@ public class AppLovinMAXModule
2390
2376
 
2391
2377
  private void setPendingExtraParametersIfNeeded(final AppLovinSdkSettings settings)
2392
2378
  {
2393
- if ( extraParametersToSet.size() <= 0 ) return;
2379
+ if ( extraParametersToSet.isEmpty() ) return;
2394
2380
 
2395
2381
  for ( final String key : extraParametersToSet.keySet() )
2396
2382
  {
@@ -2458,38 +2444,6 @@ public class AppLovinMAXModule
2458
2444
  return AppLovinSdkUtils.isTablet( context ) ? MaxAdFormat.LEADER : MaxAdFormat.BANNER;
2459
2445
  }
2460
2446
 
2461
- protected static class AdViewSize
2462
- {
2463
- public final int widthDp;
2464
- public final int heightDp;
2465
-
2466
- private AdViewSize(final int widthDp, final int heightDp)
2467
- {
2468
- this.widthDp = widthDp;
2469
- this.heightDp = heightDp;
2470
- }
2471
- }
2472
-
2473
- public static AdViewSize getAdViewSize(final MaxAdFormat format)
2474
- {
2475
- if ( MaxAdFormat.LEADER == format )
2476
- {
2477
- return new AdViewSize( 728, 90 );
2478
- }
2479
- else if ( MaxAdFormat.BANNER == format )
2480
- {
2481
- return new AdViewSize( 320, 50 );
2482
- }
2483
- else if ( MaxAdFormat.MREC == format )
2484
- {
2485
- return new AdViewSize( 300, 250 );
2486
- }
2487
- else
2488
- {
2489
- throw new IllegalArgumentException( "Invalid ad format" );
2490
- }
2491
- }
2492
-
2493
2447
  private static Point getOffsetPixels(final float xDp, final float yDp, final Context context)
2494
2448
  {
2495
2449
  return new Point( AppLovinSdkUtils.dpToPx( context, (int) xDp ), AppLovinSdkUtils.dpToPx( context, (int) yDp ) );
@@ -2718,21 +2672,25 @@ public class AppLovinMAXModule
2718
2672
 
2719
2673
  // Amazon
2720
2674
 
2675
+ @SuppressWarnings("unused")
2721
2676
  public void setAmazonBannerResult(final Object result, final String adUnitId)
2722
2677
  {
2723
2678
  setAmazonResult( result, adUnitId, MaxAdFormat.BANNER );
2724
2679
  }
2725
2680
 
2681
+ @SuppressWarnings("unused")
2726
2682
  public void setAmazonMRecResult(final Object result, final String adUnitId)
2727
2683
  {
2728
2684
  setAmazonResult( result, adUnitId, MaxAdFormat.MREC );
2729
2685
  }
2730
2686
 
2687
+ @SuppressWarnings("unused")
2731
2688
  public void setAmazonInterstitialResult(final Object result, final String adUnitId)
2732
2689
  {
2733
2690
  setAmazonResult( result, adUnitId, MaxAdFormat.INTERSTITIAL );
2734
2691
  }
2735
2692
 
2693
+ @SuppressWarnings("unused")
2736
2694
  public void setAmazonRewardedResult(final Object result, final String adUnitId)
2737
2695
  {
2738
2696
  setAmazonResult( result, adUnitId, MaxAdFormat.REWARDED );
@@ -2813,24 +2771,24 @@ public class AppLovinMAXModule
2813
2771
  @Override
2814
2772
  public void onHostDestroy()
2815
2773
  {
2816
- // Make copy because `destroyAdView()` will remove from `mAdViews`
2817
- List<MaxAdView> adViews = new ArrayList<>( mAdViews.values() );
2818
- for ( MaxAdView adView : adViews )
2774
+ // Make copy because `destroyAdView()` will remove from `adViews`
2775
+ List<MaxAdView> adViewList = new ArrayList<>( adViews.values() );
2776
+ for ( MaxAdView adView : adViewList )
2819
2777
  {
2820
2778
  destroyAdView( adView.getAdUnitId(), adView.getAdFormat() );
2821
2779
  }
2822
2780
 
2823
- for ( MaxInterstitialAd interstitialAd : mInterstitials.values() )
2781
+ for ( MaxInterstitialAd interstitialAd : interstitials.values() )
2824
2782
  {
2825
2783
  interstitialAd.destroy();
2826
2784
  }
2827
- mInterstitials.clear();
2785
+ interstitials.clear();
2828
2786
 
2829
- for ( MaxRewardedAd rewardedAd : mRewardedAds.values() )
2787
+ for ( MaxRewardedAd rewardedAd : rewardedAds.values() )
2830
2788
  {
2831
2789
  rewardedAd.destroy();
2832
2790
  }
2833
- mRewardedAds.clear();
2791
+ rewardedAds.clear();
2834
2792
  }
2835
2793
 
2836
2794
  // Required methods introduced React Native 0.65
@@ -2847,11 +2805,11 @@ public class AppLovinMAXModule
2847
2805
 
2848
2806
  // React Native Bridge
2849
2807
 
2850
- private void sendReactNativeEvent(final String name, @Nullable final WritableMap params)
2808
+ public void sendReactNativeEvent(final String name, @Nullable final WritableMap params)
2851
2809
  {
2852
2810
  getReactApplicationContext()
2853
- .getJSModule( RCTDeviceEventEmitter.class )
2854
- .emit( name, params );
2811
+ .getJSModule( RCTDeviceEventEmitter.class )
2812
+ .emit( name, params );
2855
2813
  }
2856
2814
 
2857
2815
  @Override
@@ -2899,6 +2857,9 @@ public class AppLovinMAXModule
2899
2857
  constants.put( "ON_APPOPEN_AD_HIDDEN_EVENT", ON_APPOPEN_AD_HIDDEN_EVENT );
2900
2858
  constants.put( "ON_APPOPEN_AD_REVENUE_PAID", ON_APPOPEN_AD_REVENUE_PAID );
2901
2859
 
2860
+ constants.put( "ON_NATIVE_UI_COMPONENT_ADVIEW_AD_LOADED_EVENT", ON_NATIVE_UI_COMPONENT_ADVIEW_AD_LOADED_EVENT );
2861
+ constants.put( "ON_NATIVE_UI_COMPONENT_ADVIEW_AD_LOAD_FAILED_EVENT", ON_NATIVE_UI_COMPONENT_ADVIEW_AD_LOAD_FAILED_EVENT );
2862
+
2902
2863
  constants.put( "TOP_CENTER_POSITION", TOP_CENTER );
2903
2864
  constants.put( "TOP_LEFT_POSITION", TOP_LEFT );
2904
2865
  constants.put( "TOP_RIGHT_POSITION", TOP_RIGHT );