Skip to content

Commit 892c750

Browse files
authored
[MOB-1424] InAppFragment improvements, delayed display (#229)
[MOB-1424] InAppFragment improvements, delayed display
2 parents 299e405 + aa3be89 commit 892c750

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

iterableapi/src/main/java/com/iterable/iterableapi/IterableInAppFragmentHTMLNotification.java

+14-6
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public class IterableInAppFragmentHTMLNotification extends DialogFragment implem
4141
private static final String MESSAGE_ID = "MessageId";
4242
private static final String INAPP_OPEN_TRACKED = "InAppOpenTracked";
4343

44+
private static final int DELAY_THRESHOLD_MS = 500;
45+
4446
static IterableInAppFragmentHTMLNotification notification;
4547
static IterableHelper.IterableUrlCallback clickCallback;
4648
static IterableInAppLocation location;
@@ -125,6 +127,7 @@ public void onDestroy() {
125127
*/
126128
public void setLoaded(boolean loaded) {
127129
this.loaded = loaded;
130+
showDialogView();
128131
}
129132

130133
@NonNull
@@ -148,7 +151,6 @@ public void onBackPressed() {
148151
if (insetPadding.bottom == 0 && insetPadding.top == 0) {
149152
dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
150153
}
151-
hideDialogView(dialog);
152154
return dialog;
153155
}
154156

@@ -190,20 +192,27 @@ public void run() {
190192
if (savedInstanceState == null || !savedInstanceState.getBoolean(INAPP_OPEN_TRACKED, false)) {
191193
IterableApi.sharedInstance.trackInAppOpen(messageId, location);
192194
}
195+
hideDialogView();
193196
return relativeLayout;
194197
}
195198

196-
private void hideDialogView(Dialog dialog) {
199+
private void hideDialogView() {
197200
try {
198-
dialog.getWindow().getDecorView().setVisibility(View.INVISIBLE);
201+
getDialog().getWindow().getDecorView().setAlpha(0.0f);
202+
webView.postDelayed(new Runnable() {
203+
@Override
204+
public void run() {
205+
showDialogView();
206+
}
207+
}, DELAY_THRESHOLD_MS);
199208
} catch (NullPointerException e) {
200209
IterableLogger.e(TAG, "View not present. Failed to hide before resizing inapp");
201210
}
202211
}
203212

204-
private void showDialogView(Dialog dialog) {
213+
private void showDialogView() {
205214
try {
206-
dialog.getWindow().getDecorView().setVisibility(View.VISIBLE);
215+
getDialog().getWindow().getDecorView().setAlpha(1.0f);
207216
} catch (NullPointerException e) {
208217
IterableLogger.e(TAG, "View not present. Failed to show inapp", e);
209218
}
@@ -306,7 +315,6 @@ public void run() {
306315
wlp.flags = WindowManager.LayoutParams.FLAG_DIM_BEHIND;
307316
window.setAttributes(wlp);
308317
}
309-
showDialogView(getDialog());
310318
} catch (IllegalArgumentException e) {
311319
IterableLogger.e(TAG, "Exception while trying to resize an in-app message", e);
312320
}

0 commit comments

Comments
 (0)