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(); } }
@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()); } }
public int getCount() { if (mMediaViewCollection == null) return 0; return mMediaViewCollection.getCount(); }