Ejemplo n.º 1
0
 // DownloadTaskListener
 @Override
 public void onComplete(String url, DownloadResponse downloadResponse) {
   if (downloadResponse != null && downloadResponse.getStatusCode() == HttpStatus.SC_OK) {
     final Bitmap companionAdBitmap = HttpResponses.asBitmap(downloadResponse);
     if (companionAdBitmap != null) {
       // If Bitmap fits in ImageView, then don't use MATCH_PARENT
       final int width = Dips.dipsToIntPixels(companionAdBitmap.getWidth(), getContext());
       final int height = Dips.dipsToIntPixels(companionAdBitmap.getHeight(), getContext());
       final int imageViewWidth = mCompanionAdImageView.getMeasuredWidth();
       final int imageViewHeight = mCompanionAdImageView.getMeasuredHeight();
       if (width < imageViewWidth && height < imageViewHeight) {
         mCompanionAdImageView.getLayoutParams().width = width;
         mCompanionAdImageView.getLayoutParams().height = height;
       }
       mCompanionAdImageView.setImageBitmap(companionAdBitmap);
       mCompanionAdImageView.setOnClickListener(
           new View.OnClickListener() {
             @Override
             public void onClick(View view) {
               if (mVastCompanionAd != null) {
                 handleClick(
                     mVastCompanionAd.getClickTrackers(), mVastCompanionAd.getClickThroughUrl());
               }
             }
           });
     }
   }
 }
 @Override
 void onCreate() {
   super.onCreate();
   mButtonSize = Dips.asIntPixels(CLOSE_BUTTON_SIZE, getContext());
   mButtonPadding = Dips.asIntPixels(CLOSE_BUTTON_PADDING, getContext());
   createInterstitialCloseButton();
   mCloseButton.setVisibility(GONE);
   mVideoView.start();
 }
  public CloseableLayout(@NonNull Context context) {
    super(context);

    mCloseDrawable = new StateListDrawable();
    mClosePosition = ClosePosition.TOP_RIGHT;

    mCloseDrawable.addState(
        SELECTED_STATE_SET, INTERSTITIAL_CLOSE_BUTTON_PRESSED.createDrawable(context));
    mCloseDrawable.addState(
        EMPTY_STATE_SET, INTERSTITIAL_CLOSE_BUTTON_NORMAL.createDrawable(context));

    mCloseDrawable.setState(EMPTY_STATE_SET);
    mCloseDrawable.setCallback(this);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    mCloseRegionSize = Dips.asIntPixels(CLOSE_REGION_SIZE_DP, context);
    mCloseButtonSize = Dips.asIntPixels(CLOSE_BUTTON_SIZE_DP, context);
    mCloseButtonPadding = Dips.asIntPixels(CLOSE_BUTTON_PADDING_DP, context);

    setWillNotDraw(false);
  }