Skip to content

Commit

Permalink
fix/npe_when_showing_banner_before_it_is_created (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasmso authored Dec 13, 2023
1 parent 7f5d09f commit e5f2ffc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Versions

## x.x.x
* Fix NPE if the integration attempts to show a banner before it is created.
## 1.1.2
* Fix `destroyMRec` API by adding the missing argument.
## 1.1.1
Expand Down
9 changes: 7 additions & 2 deletions plugin/src/android/AppLovinMAX.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
import java.util.List;
import java.util.Map;

import androidx.annotation.Nullable;

import static org.apache.cordova.PluginResult.Status.ERROR;
import static org.apache.cordova.PluginResult.Status.OK;

Expand Down Expand Up @@ -975,7 +977,7 @@ private void updateAdViewPosition(final String adUnitId, final String adViewPosi
} );
}

private void showAdView(final String adUnitId, final MaxAdFormat adFormat, final CallbackContext callbackContext)
private void showAdView(final String adUnitId, final MaxAdFormat adFormat, @Nullable final CallbackContext callbackContext)
{
getCurrentActivity().runOnUiThread( () -> {

Expand All @@ -994,7 +996,10 @@ private void showAdView(final String adUnitId, final MaxAdFormat adFormat, final
adView.setVisibility( View.VISIBLE );
adView.startAutoRefresh();

callbackContext.success();
if ( callbackContext != null )
{
callbackContext.success();
}
} );
}

Expand Down

0 comments on commit e5f2ffc

Please sign in to comment.