@@ -61,6 +61,7 @@ class InAppMessageView {
61
61
62
62
interface InAppMessageViewListener {
63
63
void onMessageWasShown ();
64
+ void onMessageWillDismiss ();
64
65
void onMessageWasDismissed ();
65
66
}
66
67
@@ -243,7 +244,6 @@ public void run() {
243
244
244
245
if (messageController != null ) {
245
246
animateInAppMessage (displayLocation , draggableRelativeLayout , parentRelativeLayout );
246
- messageController .onMessageWasShown ();
247
247
}
248
248
249
249
startDismissTimerIfNeeded ();
@@ -310,6 +310,9 @@ private void setUpDraggableLayout(final Context context,
310
310
draggableRelativeLayout .setListener (new DraggableRelativeLayout .DraggableListener () {
311
311
@ Override
312
312
public void onDismiss () {
313
+ if (messageController != null ) {
314
+ messageController .onMessageWillDismiss ();
315
+ }
313
316
finishAfterDelay (null );
314
317
}
315
318
@@ -388,6 +391,9 @@ private void startDismissTimerIfNeeded() {
388
391
389
392
scheduleDismissRunnable = new Runnable () {
390
393
public void run () {
394
+ if (messageController != null ) {
395
+ messageController .onMessageWillDismiss ();
396
+ }
391
397
if (currentActivity != null ) {
392
398
dismissAndAwaitNextMessage (null );
393
399
scheduleDismissRunnable = null ;
@@ -489,9 +495,7 @@ private void dereferenceViews() {
489
495
private void animateInAppMessage (WebViewManager .Position displayLocation , View messageView , View backgroundView ) {
490
496
final CardView messageViewCardView = messageView .findViewWithTag (IN_APP_MESSAGE_CARD_VIEW_TAG );
491
497
492
- Animation .AnimationListener cardViewAnimCallback = null ;
493
- if (Build .VERSION .SDK_INT == Build .VERSION_CODES .M )
494
- cardViewAnimCallback = createAnimationListenerForAndroidApi23Elevation (messageViewCardView );
498
+ Animation .AnimationListener cardViewAnimCallback = createAnimationListener (messageViewCardView );
495
499
496
500
// Based on the location of the in app message apply and animation to match
497
501
switch (displayLocation ) {
@@ -508,7 +512,7 @@ private void animateInAppMessage(WebViewManager.Position displayLocation, View m
508
512
}
509
513
}
510
514
511
- private Animation .AnimationListener createAnimationListenerForAndroidApi23Elevation (final CardView messageViewCardView ) {
515
+ private Animation .AnimationListener createAnimationListener (final CardView messageViewCardView ) {
512
516
return new Animation .AnimationListener () {
513
517
@ Override
514
518
public void onAnimationStart (Animation animation ) {
@@ -518,7 +522,12 @@ public void onAnimationStart(Animation animation) {
518
522
@ Override
519
523
public void onAnimationEnd (Animation animation ) {
520
524
// For Android 6 API 23 devices, waits until end of animation to set elevation of CardView class
521
- messageViewCardView .setCardElevation (dpToPx (5 ));
525
+ if (Build .VERSION .SDK_INT == Build .VERSION_CODES .M ) {
526
+ messageViewCardView .setCardElevation (dpToPx (5 ));
527
+ }
528
+ if (messageController != null ) {
529
+ messageController .onMessageWasShown ();
530
+ }
522
531
}
523
532
524
533
@ Override
0 commit comments