コード例 #1
0
 public void setScaleType(boolean setToFitIfFirstPhotoIsPortrait) {
   if (mMediaViewCollection != null) {
     if (setToFitIfFirstPhotoIsPortrait && mMediaViewCollection.isFirstViewPortrait())
       mMediaViewCollection.setScaleType(ScaleType.FIT_CENTER);
     else mMediaViewCollection.setScaleType(ScaleType.CENTER_CROP);
   }
 }
コード例 #2
0
 private void createSingleImageView() {
   View view = mMediaViewCollection.getView(0);
   if (view.getParent() != null) ((ViewGroup) view.getParent()).removeView(view);
   if (mAllowFullScreenMediaViewing) {
     view.setOnClickListener(
         new OnMediaItemClickedListener(mMediaViewCollection.getContentForView(view)));
   } else {
     view.setOnClickListener(null);
     view.setClickable(false);
   }
   this.addView(view);
 }
コード例 #3
0
 public void updateView() {
   this.removeAllViews();
   if (mMediaViewCollection == null || mMediaViewCollection.getCount() == 0) {
     if (mShowPlaceholder) createPlaceholderView();
   } else if (!mMediaViewCollection.containsLoadedMedia()) {
     if (mShowDLButtonForBitWise) {
       if (mMediaViewCollection.isLoadingMedia()) createDownloadingView(false);
       else createDownloadView();
     } else if (mShowPlaceholderWhileLoading) createDownloadingView(true);
   } else if (mMediaViewCollection.getCount() > 1) {
     createMultiImageView();
   } else if (mMediaViewCollection.getCount() == 1) {
     createSingleImageView();
   }
 }
コード例 #4
0
 @Override
 public void onClick(View v) {
   if (v == mDownloadView) {
     mMediaViewCollection.refreshViews(true, false);
     updateView();
   }
 }
コード例 #5
0
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    if (!mShowPlaceholder
        && (mMediaViewCollection == null || mMediaViewCollection.getCount() == 0)) {
      setMeasuredDimension(0, 0);
      return;
    }

    if (mMediaViewCollection != null
        && !mMediaViewCollection.containsLoadedMedia()
        && !mShowPlaceholderWhileLoading) {
      if (this.mShowDLButtonForBitWise) {
        Log.v("MediaView", "No cached image, but show DL button");
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
      } else {
        Log.v("MediaView", "No cached image, set height to 0");
        setMeasuredDimension(0, 0);
      }
    } else if (mHeightInhibitor == 0) {
      super.onMeasure(widthMeasureSpec, heightMeasureSpec);
      Log.v(
          "MediaView",
          "Contains cached image, no constraints, set height to " + this.getMeasuredHeight());
    } else if (MeasureSpec.getMode(widthMeasureSpec) != MeasureSpec.UNSPECIFIED) {
      int inhibitedHeightSpec =
          MeasureSpec.makeMeasureSpec(
              (int) (MeasureSpec.getSize(widthMeasureSpec) / mHeightInhibitor),
              MeasureSpec.getMode(widthMeasureSpec));
      super.onMeasure(widthMeasureSpec, inhibitedHeightSpec);
      Log.v("MediaView", "Cached image, set height to " + this.getMeasuredHeight());
    } else {
      super.onMeasure(widthMeasureSpec, heightMeasureSpec);
      int width = this.getMeasuredWidth();
      if (mHeightInhibitor != 0) {
        int height = (int) (width / mHeightInhibitor);
        super.onMeasure(
            MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
            MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
      }
      Log.v("MediaView", "Contains cached image, set height to " + this.getMeasuredHeight());
    }
  }
コード例 #6
0
 private void createDownloadView() {
   if (mDownloadView == null) {
     mDownloadView =
         LayoutInflater.from(getContext())
             .inflate(R.layout.story_media_bitwise_placeholder, this, false);
   }
   mDownloadView.setOnClickListener(this);
   ImageView iv = ((ImageView) mDownloadView.findViewById(R.id.ivDownloadIcon));
   iv.setImageResource(
       mMediaViewCollection.isFirstViewVideo()
           ? R.drawable.ic_load_video
           : R.drawable.ic_load_photo);
   this.addView(mDownloadView);
   iv.clearAnimation();
 }
コード例 #7
0
  private void createDownloadingView(boolean useFinalSize) {
    if (mDownloadView == null) {
      mDownloadView =
          LayoutInflater.from(getContext())
              .inflate(R.layout.story_media_bitwise_placeholder, this, false);
    }
    if (useFinalSize) mDownloadView.getLayoutParams().height = LayoutParams.MATCH_PARENT;
    else mDownloadView.getLayoutParams().height = UIHelpers.dpToPx(50, getContext());

    mDownloadView.setOnClickListener(null);
    ImageView iv = ((ImageView) mDownloadView.findViewById(R.id.ivDownloadIcon));
    iv.setImageResource(
        mMediaViewCollection.isFirstViewVideo()
            ? R.drawable.ic_load_video
            : R.drawable.ic_context_load);
    this.addView(mDownloadView);
    iv.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.rotate));
  }
コード例 #8
0
 public boolean isMediaLoaded() {
   return mMediaViewCollection != null && mMediaViewCollection.containsLoadedMedia();
 }
コード例 #9
0
 public int getCount() {
   if (mMediaViewCollection == null) return 0;
   return mMediaViewCollection.getCount();
 }