private void configMinimizedViewLayoutParams(LoopMeBannerView bannerView) { LayoutParams lp = (LayoutParams) bannerView.getLayoutParams(); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); lp.bottomMargin = mMinimizedMode.getMarginBottom(); lp.rightMargin = mMinimizedMode.getMarginRight(); bannerView.setLayoutParams(lp); }
void switchToMinimizedMode() { if (mDisplayMode == DisplayMode.MINIMIZED) { if (getCurrentVideoState() == VideoState.PAUSED) { setWebViewState(WebviewState.VISIBLE); } return; } Logging.out(LOG_TAG, "switchToMinimizedMode", LogLevel.DEBUG); mDisplayMode = DisplayMode.MINIMIZED; int width = mMinimizedMode.getWidth(); int height = mMinimizedMode.getHeight(); mMinimizedView = new LoopMeBannerView(mAdView.getContext(), width, height); rebuildView(mMinimizedView); addBordersToView(mMinimizedView); if (mAdView.getCurrentWebViewState() == WebviewState.HIDDEN) { mMinimizedView.setAlpha(0); } mMinimizedMode.getRootView().addView(mMinimizedView); configMinimizedViewLayoutParams(mMinimizedView); setWebViewState(WebviewState.VISIBLE); mAdView.setOnTouchListener( new SwipeListener( width, new SwipeListener.Listener() { @Override public void onSwipe(boolean toRight) { mAdView.setWebViewState(WebviewState.HIDDEN); Animation anim = AnimationUtils.makeOutAnimation(mAd.getContext(), toRight); anim.setDuration(200); mMinimizedView.startAnimation(anim); switchToNormalMode(); mMinimizedMode = null; } })); }
@Override public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) { Logging.out(LOG_TAG, "onSurfaceTextureAvailable", LogLevel.DEBUG); int viewWidth = 0; int viewHeight = 0; switch (mDisplayMode) { case DisplayMode.MINIMIZED: if (mMinimizedMode != null) { viewWidth = mMinimizedMode.getWidth(); viewHeight = mMinimizedMode.getHeight(); } else { Logging.out(LOG_TAG, "WARNING: MinimizedMode is null", LogLevel.ERROR); } break; case DisplayMode.NORMAL: viewWidth = mAd.detectWidth(); viewHeight = mAd.detectHeight(); break; case DisplayMode.FULLSCREEN: viewWidth = Utils.getScreenWidth(); viewHeight = Utils.getScreenHeight(); break; default: Logging.out(LOG_TAG, "Unknown display mode", LogLevel.ERROR); break; } if (mVideoController != null) { mVideoController.setSurface(mTextureView); mVideoController.resizeVideo(mTextureView, viewWidth, viewHeight); } }
boolean isMinimizedModeEnable() { return mMinimizedMode != null && mMinimizedMode.getRootView() != null; }