private void startAdActivity() { LoopMeAdHolder.putAd(mAd); Context context = mAd.getContext(); Intent intent = new Intent(context, AdActivity.class); intent.putExtra(StaticParams.APPKEY_TAG, mAd.getAppKey()); intent.putExtra(StaticParams.FORMAT_TAG, mAd.getAdFormat()); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); }
public ViewController(BaseAd ad) { mAd = ad; mAdView = new AdView(mAd.getContext()); mBridgeListener = initBridgeListener(); mAdView.addBridgeListener(mBridgeListener); mAdView.setOnTouchListener( new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return (event.getAction() == MotionEvent.ACTION_MOVE); } }); mVideoController = new VideoController(mAd.getAppKey(), mAdView, mAd.getAdFormat()); }
private void handleVideoLoad(String videoUrl) { Logging.out(LOG_TAG, "JS command: load video " + videoUrl, LogLevel.DEBUG); mIsVideoPresented = true; if (mVideoController != null) { mVideoController.loadVideoFile(videoUrl, mAd.getContext()); } }
void preloadHtml(String html) { if (mAdView != null) { Logging.out(LOG_TAG, "loadDataWithBaseURL", LogLevel.DEBUG); mAdView.loadDataWithBaseURL(null, html, "text/html", "UTF-8", null); } else { mAd.onAdLoadFail(new LoopMeError("Html loading error")); } }
private void handleNonLoopMe(String url) { Logging.out(LOG_TAG, "Non Js command", LogLevel.DEBUG); Context context = mAd.getContext(); if (Utils.isOnline(context)) { Intent intent = new Intent(context, AdBrowserActivity.class); intent.putExtra(EXTRA_URL, url); intent.putExtra(StaticParams.APPKEY_TAG, mAd.getAppKey()); intent.putExtra(StaticParams.FORMAT_TAG, mAd.getAdFormat()); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mAd.onAdClicked(); setWebViewState(WebviewState.HIDDEN); broadcastAdClickedIntent(); context.startActivity(intent); } else { Logging.out(LOG_TAG, "No internet connection", LogLevel.DEBUG); } }
@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); } }
void buildVideoAdView(ViewGroup bannerView) { mTextureView = new TextureView(mAd.getContext()); mTextureView.setBackgroundColor(Color.TRANSPARENT); mTextureView.setSurfaceTextureListener(this); mAdView.setBackgroundColor(Color.TRANSPARENT); mAdView.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null); bannerView.setBackgroundColor(Color.BLACK); bannerView.addView(mTextureView, 0); if (mAdView.getParent() != null) { ((ViewGroup) mAdView.getParent()).removeView(mAdView); } bannerView.addView(mAdView, 1); }
private void broadcastAdClickedIntent() { Intent intent = new Intent(); intent.setAction(StaticParams.CLICK_INTENT); mAd.getContext().sendBroadcast(intent); }
private void broadcastDestroyIntent() { Intent intent = new Intent(); intent.setAction(StaticParams.DESTROY_INTENT); mAd.getContext().sendBroadcast(intent); }
private void handleClose() { Logging.out(LOG_TAG, "JS command: close", LogLevel.DEBUG); mAd.dismiss(); }
private void handleLoadSuccess() { Logging.out(LOG_TAG, "JS command: load success", LogLevel.DEBUG); mAd.startExpirationTimer(); mAd.onAdLoadSuccess(); }
private void loadFail(BaseAd baseAd, LoopMeError error) { baseAd.onAdLoadFail(error); }
@Override public void destroy() { broadcastDestroyIntent(); super.destroy(); }