コード例 #1
0
  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);
  }
コード例 #2
0
 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());
 }
コード例 #3
0
  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());
    }
  }
コード例 #4
0
 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"));
   }
 }
コード例 #5
0
  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);
    }
  }
コード例 #6
0
  @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);
    }
  }
コード例 #7
0
  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);
  }
コード例 #8
0
 private void broadcastAdClickedIntent() {
   Intent intent = new Intent();
   intent.setAction(StaticParams.CLICK_INTENT);
   mAd.getContext().sendBroadcast(intent);
 }
コード例 #9
0
 private void broadcastDestroyIntent() {
   Intent intent = new Intent();
   intent.setAction(StaticParams.DESTROY_INTENT);
   mAd.getContext().sendBroadcast(intent);
 }
コード例 #10
0
 private void handleClose() {
   Logging.out(LOG_TAG, "JS command: close", LogLevel.DEBUG);
   mAd.dismiss();
 }
コード例 #11
0
 private void handleLoadSuccess() {
   Logging.out(LOG_TAG, "JS command: load success", LogLevel.DEBUG);
   mAd.startExpirationTimer();
   mAd.onAdLoadSuccess();
 }
コード例 #12
0
 private void loadFail(BaseAd baseAd, LoopMeError error) {
   baseAd.onAdLoadFail(error);
 }
コード例 #13
0
  @Override
  public void destroy() {
    broadcastDestroyIntent();

    super.destroy();
  }