2
2
3
3
import android .app .Activity ;
4
4
import android .content .Context ;
5
- import android .content .DialogInterface ;
6
5
import android .graphics .Rect ;
7
6
8
7
import androidx .annotation .NonNull ;
9
- import androidx .annotation .Nullable ;
10
8
import androidx .fragment .app .FragmentActivity ;
11
9
12
10
class IterableInAppDisplayer {
@@ -18,14 +16,14 @@ class IterableInAppDisplayer {
18
16
}
19
17
20
18
boolean isShowingInApp () {
21
- return IterableInAppHTMLNotification .getInstance () != null ;
19
+ return IterableInAppFragmentHTMLNotification .getInstance () != null ;
22
20
}
23
21
24
22
boolean showMessage (@ NonNull IterableInAppMessage message , IterableInAppLocation location , @ NonNull final IterableHelper .IterableUrlCallback clickCallback ) {
25
23
Activity currentActivity = activityMonitor .getCurrentActivity ();
26
24
// Prevent double display
27
25
if (currentActivity != null ) {
28
- return IterableInAppDisplayer .showIterableNotificationHTML (currentActivity ,
26
+ return IterableInAppDisplayer .showIterableFragmentNotificationHTML (currentActivity ,
29
27
message .getContent ().html ,
30
28
message .getMessageId (),
31
29
clickCallback ,
@@ -36,50 +34,6 @@ boolean showMessage(@NonNull IterableInAppMessage message, IterableInAppLocation
36
34
return false ;
37
35
}
38
36
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
-
83
37
/**
84
38
* Displays an html rendered InApp Notification
85
39
* @param context
0 commit comments