@@ -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
@@ -489,9 +492,7 @@ private void dereferenceViews() {
489
492
private void animateInAppMessage (WebViewManager .Position displayLocation , View messageView , View backgroundView ) {
490
493
final CardView messageViewCardView = messageView .findViewWithTag (IN_APP_MESSAGE_CARD_VIEW_TAG );
491
494
492
- Animation .AnimationListener cardViewAnimCallback = null ;
493
- if (Build .VERSION .SDK_INT == Build .VERSION_CODES .M )
494
- cardViewAnimCallback = createAnimationListenerForAndroidApi23Elevation (messageViewCardView );
495
+ Animation .AnimationListener cardViewAnimCallback = createAnimationListener (messageViewCardView );
495
496
496
497
// Based on the location of the in app message apply and animation to match
497
498
switch (displayLocation ) {
@@ -508,7 +509,7 @@ private void animateInAppMessage(WebViewManager.Position displayLocation, View m
508
509
}
509
510
}
510
511
511
- private Animation .AnimationListener createAnimationListenerForAndroidApi23Elevation (final CardView messageViewCardView ) {
512
+ private Animation .AnimationListener createAnimationListener (final CardView messageViewCardView ) {
512
513
return new Animation .AnimationListener () {
513
514
@ Override
514
515
public void onAnimationStart (Animation animation ) {
@@ -518,7 +519,12 @@ public void onAnimationStart(Animation animation) {
518
519
@ Override
519
520
public void onAnimationEnd (Animation animation ) {
520
521
// For Android 6 API 23 devices, waits until end of animation to set elevation of CardView class
521
- messageViewCardView .setCardElevation (dpToPx (5 ));
522
+ if (Build .VERSION .SDK_INT == Build .VERSION_CODES .M ) {
523
+ messageViewCardView .setCardElevation (dpToPx (5 ));
524
+ }
525
+ if (messageController != null ) {
526
+ messageController .onMessageWasShown ();
527
+ }
522
528
}
523
529
524
530
@ Override
0 commit comments