22
33import android .app .Activity ;
44import android .content .Context ;
5- import android .content .DialogInterface ;
65import android .graphics .Rect ;
76
87import androidx .annotation .NonNull ;
9- import androidx .annotation .Nullable ;
108import androidx .fragment .app .FragmentActivity ;
119
1210class IterableInAppDisplayer {
@@ -18,14 +16,14 @@ class IterableInAppDisplayer {
1816 }
1917
2018 boolean isShowingInApp () {
21- return IterableInAppHTMLNotification .getInstance () != null ;
19+ return IterableInAppFragmentHTMLNotification .getInstance () != null ;
2220 }
2321
2422 boolean showMessage (@ NonNull IterableInAppMessage message , IterableInAppLocation location , @ NonNull final IterableHelper .IterableUrlCallback clickCallback ) {
2523 Activity currentActivity = activityMonitor .getCurrentActivity ();
2624 // Prevent double display
2725 if (currentActivity != null ) {
28- return IterableInAppDisplayer .showIterableNotificationHTML (currentActivity ,
26+ return IterableInAppDisplayer .showIterableFragmentNotificationHTML (currentActivity ,
2927 message .getContent ().html ,
3028 message .getMessageId (),
3129 clickCallback ,
@@ -36,50 +34,6 @@ boolean showMessage(@NonNull IterableInAppMessage message, IterableInAppLocation
3634 return false ;
3735 }
3836
39- /**
40- * Displays an html rendered InApp Notification
41- * @param context
42- * @param htmlString
43- * @param messageId
44- * @param clickCallback
45- * @param backgroundAlpha
46- * @param padding
47- */
48- static boolean showIterableNotificationHTML (@ NonNull Context context , @ Nullable String htmlString , String messageId , final IterableHelper .IterableUrlCallback clickCallback , double backgroundAlpha , Rect padding , boolean callbackOnCancel , IterableInAppLocation location ) {
49- if (context instanceof Activity ) {
50- Activity currentActivity = (Activity ) context ;
51- if (htmlString != null ) {
52- if (IterableInAppHTMLNotification .getInstance () != null ) {
53- IterableLogger .w (IterableInAppManager .TAG , "Skipping the in-app notification: another notification is already being displayed" );
54- return false ;
55- }
56-
57- IterableInAppHTMLNotification notification = IterableInAppHTMLNotification .createInstance (context , htmlString );
58- notification .setTrackParams (messageId );
59- notification .setCallback (clickCallback );
60- notification .setBackgroundAlpha (backgroundAlpha );
61- notification .setPadding (padding );
62- notification .setOwnerActivity (currentActivity );
63- notification .setLocation (location );
64-
65- if (callbackOnCancel ) {
66- notification .setOnCancelListener (new DialogInterface .OnCancelListener () {
67- @ Override
68- public void onCancel (DialogInterface dialog ) {
69- clickCallback .execute (null );
70- }
71- });
72- }
73-
74- notification .show ();
75- return true ;
76- }
77- } else {
78- IterableLogger .w (IterableInAppManager .TAG , "To display in-app notifications, the context must be of an instance of: Activity" );
79- }
80- return false ;
81- }
82-
8337 /**
8438 * Displays an html rendered InApp Notification
8539 * @param context
0 commit comments