@Test public void show_addsViewOnlyOnce() { final WindowManager.LayoutParams expectedLayoutParams = new WindowManager.LayoutParams( inappMessageLayoutConfig.windowWidth(), inappMessageLayoutConfig.windowHeight(), FiamWindowManager.DEFAULT_TYPE, inappMessageLayoutConfig.windowFlag(), PixelFormat.TRANSLUCENT); expectedLayoutParams.dimAmount = 0.3f; expectedLayoutParams.gravity = WINDOW_GRAVITY; expectedLayoutParams.windowAnimations = 0; fiamWindowManager.show(bindingWrapper, activity); fiamWindowManager.show(bindingWrapper, activity); fiamWindowManager.show(bindingWrapper, activity); verify(windowManager, times(1)) .addView(eq(bindingWrapper.getRootView()), layoutArgCaptor.capture()); assertThat(layoutArgCaptor.getValue().toString()).isEqualTo(expectedLayoutParams.toString()); }
public void show(@NonNull final BindingWrapper bindingWrapper, @NonNull Activity activity) { if (isFiamDisplayed()) { Logging.loge("Fiam already active. Cannot show new Fiam."); return; } InAppMessageLayoutConfig config = bindingWrapper.getConfig(); final WindowManager.LayoutParams layoutParams = getLayoutParams(config, activity); final WindowManager windowManager = getWindowManager(activity); final View rootView = bindingWrapper.getRootView(); windowManager.addView(rootView, layoutParams); Rect insetDimensions = getInsetDimensions(activity); Logging.logdPair("Inset (top, bottom)", insetDimensions.top, insetDimensions.bottom); Logging.logdPair("Inset (left, right)", insetDimensions.left, insetDimensions.right); if (bindingWrapper.canSwipeToDismiss()) { SwipeDismissTouchListener listener = getSwipeListener(config, bindingWrapper, windowManager, layoutParams); bindingWrapper.getDialogView().setOnTouchListener(listener); } this.bindingWrapper = bindingWrapper; }
FiamWindowManager { public void show(@NonNull final BindingWrapper bindingWrapper, @NonNull Activity activity) { if (isFiamDisplayed()) { Logging.loge("Fiam already active. Cannot show new Fiam."); return; } InAppMessageLayoutConfig config = bindingWrapper.getConfig(); final WindowManager.LayoutParams layoutParams = getLayoutParams(config, activity); final WindowManager windowManager = getWindowManager(activity); final View rootView = bindingWrapper.getRootView(); windowManager.addView(rootView, layoutParams); Rect insetDimensions = getInsetDimensions(activity); Logging.logdPair("Inset (top, bottom)", insetDimensions.top, insetDimensions.bottom); Logging.logdPair("Inset (left, right)", insetDimensions.left, insetDimensions.right); if (bindingWrapper.canSwipeToDismiss()) { SwipeDismissTouchListener listener = getSwipeListener(config, bindingWrapper, windowManager, layoutParams); bindingWrapper.getDialogView().setOnTouchListener(listener); } this.bindingWrapper = bindingWrapper; } }
FiamWindowManager { public void show(@NonNull final BindingWrapper bindingWrapper, @NonNull Activity activity) { if (isFiamDisplayed()) { Logging.loge("Fiam already active. Cannot show new Fiam."); return; } InAppMessageLayoutConfig config = bindingWrapper.getConfig(); final WindowManager.LayoutParams layoutParams = getLayoutParams(config, activity); final WindowManager windowManager = getWindowManager(activity); final View rootView = bindingWrapper.getRootView(); windowManager.addView(rootView, layoutParams); Rect insetDimensions = getInsetDimensions(activity); Logging.logdPair("Inset (top, bottom)", insetDimensions.top, insetDimensions.bottom); Logging.logdPair("Inset (left, right)", insetDimensions.left, insetDimensions.right); if (bindingWrapper.canSwipeToDismiss()) { SwipeDismissTouchListener listener = getSwipeListener(config, bindingWrapper, windowManager, layoutParams); bindingWrapper.getDialogView().setOnTouchListener(listener); } this.bindingWrapper = bindingWrapper; } @Inject  FiamWindowManager(); }
FiamWindowManager { public void show(@NonNull final BindingWrapper bindingWrapper, @NonNull Activity activity) { if (isFiamDisplayed()) { Logging.loge("Fiam already active. Cannot show new Fiam."); return; } InAppMessageLayoutConfig config = bindingWrapper.getConfig(); final WindowManager.LayoutParams layoutParams = getLayoutParams(config, activity); final WindowManager windowManager = getWindowManager(activity); final View rootView = bindingWrapper.getRootView(); windowManager.addView(rootView, layoutParams); Rect insetDimensions = getInsetDimensions(activity); Logging.logdPair("Inset (top, bottom)", insetDimensions.top, insetDimensions.bottom); Logging.logdPair("Inset (left, right)", insetDimensions.left, insetDimensions.right); if (bindingWrapper.canSwipeToDismiss()) { SwipeDismissTouchListener listener = getSwipeListener(config, bindingWrapper, windowManager, layoutParams); bindingWrapper.getDialogView().setOnTouchListener(listener); } this.bindingWrapper = bindingWrapper; } @Inject  FiamWindowManager(); void show(@NonNull final BindingWrapper bindingWrapper, @NonNull Activity activity); boolean isFiamDisplayed(); void destroy(@NonNull Activity activity); }
FiamWindowManager { public void show(@NonNull final BindingWrapper bindingWrapper, @NonNull Activity activity) { if (isFiamDisplayed()) { Logging.loge("Fiam already active. Cannot show new Fiam."); return; } InAppMessageLayoutConfig config = bindingWrapper.getConfig(); final WindowManager.LayoutParams layoutParams = getLayoutParams(config, activity); final WindowManager windowManager = getWindowManager(activity); final View rootView = bindingWrapper.getRootView(); windowManager.addView(rootView, layoutParams); Rect insetDimensions = getInsetDimensions(activity); Logging.logdPair("Inset (top, bottom)", insetDimensions.top, insetDimensions.bottom); Logging.logdPair("Inset (left, right)", insetDimensions.left, insetDimensions.right); if (bindingWrapper.canSwipeToDismiss()) { SwipeDismissTouchListener listener = getSwipeListener(config, bindingWrapper, windowManager, layoutParams); bindingWrapper.getDialogView().setOnTouchListener(listener); } this.bindingWrapper = bindingWrapper; } @Inject  FiamWindowManager(); void show(@NonNull final BindingWrapper bindingWrapper, @NonNull Activity activity); boolean isFiamDisplayed(); void destroy(@NonNull Activity activity);  }