void resize(int w, int h, int offset_x, int offset_y, MRAIDImplementation.CUSTOM_CLOSE_POSITION custom_close_position, boolean allow_offscreen, final MRAIDImplementation caller) { MRAIDChangeSize(w, h);
void expand(int w, int h, boolean custom_close, final MRAIDImplementation caller, AdWebView.MRAIDFullscreenListener listener) { MRAIDChangeSize(w, h); // Add a stock close_button button to the top right corner close_button = ViewUtil.createCloseButton(this.getContext(), custom_close); FrameLayout.LayoutParams blp = (LayoutParams) close_button.getLayoutParams(); // place the close button at the top right of the adview if it isn't fullscreen if (!caller.owner.isFullScreen) { if (getChildAt(0) != null) { blp.rightMargin = (this.getMeasuredWidth() - this.getChildAt(0).getMeasuredWidth()) / 2; } } close_button.setLayoutParams(blp); close_button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { caller.close(); } }); if (caller.owner.isFullScreen) { mraidFullscreenExpand(caller, custom_close, listener); } else { // if not fullscreen, just add the close button this.addView(close_button); } isMRAIDExpanded = true; }
protected void close(int w, int h, MRAIDImplementation caller) { // Remove MRAID close button ViewUtil.removeChildFromParent(close_button); close_button = null; if (caller.owner.isFullScreen) { ViewUtil.removeChildFromParent(caller.owner); if (caller.getDefaultContainer() != null) { caller.getDefaultContainer().addView(caller.owner, 0); } if (caller.getFullscreenActivity() != null) { caller.getFullscreenActivity().finish(); } // Reset the context of MutableContext wrapper for banner expand and close case. if (getMediaType().equals(MediaType.BANNER) && (caller.owner.getContext() instanceof MutableContextWrapper)) { ((MutableContextWrapper) caller.owner.getContext()).setBaseContext(getContext()); } } // null these out for safety mraidFullscreenContainer = null; mraidFullscreenImplementation = null; mraidFullscreenListener = null; MRAIDChangeSize(w, h); mraid_is_closing = true; isMRAIDExpanded = false; }