@@ -177,7 +177,6 @@ public void destroy(final long callbackDataPtr) {
177
177
completeBannerViewFutureCallback (callbackDataPtr ,
178
178
ConstantsHelper .CALLBACK_ERROR_NONE ,
179
179
ConstantsHelper .CALLBACK_ERROR_MESSAGE_NONE );
180
- mNotifyBoundingBoxListenerOnNextDraw .set (true );
181
180
}
182
181
183
182
/**
@@ -484,7 +483,7 @@ public class AdViewListener extends AdListener implements OnPaidEventListener {
484
483
@ Override
485
484
public void onAdClicked () {
486
485
synchronized (mBannerViewLock ) {
487
- if (mAdView != null ) {
486
+ if (mBannerViewInternalPtr != CPP_NULLPTR ) {
488
487
notifyAdClicked (mBannerViewInternalPtr );
489
488
}
490
489
}
@@ -494,7 +493,7 @@ public void onAdClicked() {
494
493
@ Override
495
494
public void onAdClosed () {
496
495
synchronized (mBannerViewLock ) {
497
- if (mAdView != null ) {
496
+ if (mBannerViewInternalPtr != CPP_NULLPTR ) {
498
497
notifyAdClosed (mBannerViewInternalPtr );
499
498
mNotifyBoundingBoxListenerOnNextDraw .set (true );
500
499
}
@@ -505,18 +504,18 @@ public void onAdClosed() {
505
504
@ Override
506
505
public void onAdFailedToLoad (LoadAdError loadAdError ) {
507
506
synchronized (mBannerViewLock ) {
508
- if (mAdView != null ) {
507
+ if (mLoadAdCallbackDataPtr != CPP_NULLPTR ) {
509
508
completeBannerViewLoadAdError (mLoadAdCallbackDataPtr , loadAdError , loadAdError .getCode (), loadAdError .getMessage ());
509
+ mLoadAdCallbackDataPtr = CPP_NULLPTR ;
510
510
}
511
- mLoadAdCallbackDataPtr = CPP_NULLPTR ;
512
511
}
513
512
super .onAdFailedToLoad (loadAdError );
514
513
}
515
514
516
515
@ Override
517
516
public void onAdImpression () {
518
517
synchronized (mBannerViewLock ) {
519
- if (mAdView != null ) {
518
+ if (mBannerViewInternalPtr != CPP_NULLPTR ) {
520
519
notifyAdImpression (mBannerViewInternalPtr );
521
520
}
522
521
}
@@ -528,13 +527,15 @@ public void onAdLoaded() {
528
527
synchronized (mBannerViewLock ) {
529
528
if (mAdView != null ) {
530
529
mAdViewContainsAd = true ;
530
+ }
531
+ if (mLoadAdCallbackDataPtr != CPP_NULLPTR ) {
531
532
completeBannerViewLoadedAd (mLoadAdCallbackDataPtr );
532
533
mLoadAdCallbackDataPtr = CPP_NULLPTR ;
533
- // Only update the bounding box if the banner view is already visible.
534
- if ( mPopUp != null && mPopUp . isShowing ()) {
535
- // Loading an ad can sometimes cause the bounds to change.
536
- mNotifyBoundingBoxListenerOnNextDraw . set ( true );
537
- }
534
+ }
535
+ // Only update the bounding box if the banner view is already visible.
536
+ if ( mPopUp != null && mPopUp . isShowing ()) {
537
+ // Loading an ad can sometimes cause the bounds to change.
538
+ mNotifyBoundingBoxListenerOnNextDraw . set ( true );
538
539
}
539
540
}
540
541
super .onAdLoaded ();
@@ -543,17 +544,17 @@ public void onAdLoaded() {
543
544
@ Override
544
545
public void onAdOpened () {
545
546
synchronized (mBannerViewLock ) {
546
- if (mAdView != null ) {
547
+ if (mBannerViewInternalPtr != CPP_NULLPTR ) {
547
548
notifyAdOpened (mBannerViewInternalPtr );
548
- mNotifyBoundingBoxListenerOnNextDraw .set (true );
549
549
}
550
+ mNotifyBoundingBoxListenerOnNextDraw .set (true );
550
551
}
551
552
super .onAdOpened ();
552
553
}
553
554
554
555
public void onPaidEvent (AdValue value ) {
555
556
synchronized (mBannerViewLock ) {
556
- if (mAdView != null ) {
557
+ if (mBannerViewInternalPtr != CPP_NULLPTR ) {
557
558
notifyPaidEvent (mBannerViewInternalPtr , value .getCurrencyCode (),
558
559
value .getPrecisionType (), value .getValueMicros ());
559
560
}
@@ -575,7 +576,7 @@ public void onPaidEvent(AdValue value) {
575
576
@ Override
576
577
public boolean onPreDraw () {
577
578
if (mNotifyBoundingBoxListenerOnNextDraw .compareAndSet (true , false )) {
578
- if (mAdView != null ) {
579
+ if (mAdView != null && mBannerViewInternalPtr != CPP_NULLPTR ) {
579
580
notifyBoundingBoxChanged (mBannerViewInternalPtr );
580
581
}
581
582
}
0 commit comments