import android.view.View;
import com.android.camera.debug.Log;
+import com.android.camera.util.Size;
import com.android.camera2.R;
import com.google.common.base.Optional;
* @return a bitmap thumbnail for this item.
*/
public Optional<Bitmap> generateThumbnail(int boundingWidthPx, int boundingHeightPx);
+
+ /**
+ * Dimensions of this item.
+ *
+ * @return physical width and height in pixels.
+ */
+ public Size getDimensions();
+
+ /**
+ * Returns the rotation of the image in degrees clockwise. The valid values
+ * are 0, 90, 180, and 270.
+ */
+ public int getOrientation();
}
import com.android.camera.Storage;
import com.android.camera.debug.Log;
+import com.android.camera.util.Size;
import com.bumptech.glide.BitmapRequestBuilder;
import com.bumptech.glide.Glide;
import com.google.common.base.Optional;
public Optional<MediaDetails> getMediaDetails() {
MediaDetails mediaDetails = new MediaDetails();
mediaDetails.addDetail(MediaDetails.INDEX_TITLE, mData.getTitle());
- mediaDetails.addDetail(MediaDetails.INDEX_WIDTH, mData.getDimensions().getWidth());
- mediaDetails.addDetail(MediaDetails.INDEX_HEIGHT, mData.getDimensions().getHeight());
+ mediaDetails.addDetail(MediaDetails.INDEX_WIDTH, getDimensions().getWidth());
+ mediaDetails.addDetail(MediaDetails.INDEX_HEIGHT, getDimensions().getHeight());
mediaDetails.addDetail(MediaDetails.INDEX_PATH, mData.getFilePath());
mediaDetails.addDetail(MediaDetails.INDEX_DATETIME,
mDateFormatter.format(mData.getLastModifiedDate()));
return mMetaData;
}
+ @Override
+ public Size getDimensions() {
+ return mData.getDimensions();
+ }
+
+ @Override
+ public int getOrientation() {
+ return mData.getOrientation();
+ }
+
// TODO: Move the glide classes to a specific rendering class.
protected BitmapRequestBuilder<Uri, Bitmap> glideFullResBitmap(Uri uri,
int width, int height) {
*
* @return physical width and height in pixels.
*/
- public Size getDimensions() {
+ /* package */ Size getDimensions() {
return mDimensions;
}
* Returns the rotation of the image in degrees clockwise. The valid values
* are 0, 90, 180, and 270.
*/
- public int getOrientation() {
+ /* package */ int getOrientation() {
return mOrientation;
}
public Optional<Bitmap> generateThumbnail(int boundingWidthPx, int boundingHeightPx) {
return Optional.absent();
}
+
+ @Override
+ public Size getDimensions() {
+ return mItemData.getDimensions();
+ }
+
+ @Override
+ public int getOrientation() {
+ return mItemData.getOrientation();
+ }
}
Glide.clear(view);
}
+ @Override
+ public Size getDimensions() {
+ return mData.getDimensions();
+ }
+
+ @Override
+ public int getOrientation() {
+ return mData.getOrientation();
+ }
}
import com.android.camera.data.FilmstripItemAttributes.Attributes;
import com.android.camera.debug.Log;
+import com.android.camera.util.Size;
import com.android.camera2.R;
import com.bumptech.glide.Glide;
import com.google.common.base.Optional;
private final VideoItemFactory mVideoItemFactory;
+ private Size mCachedSize;
+
public VideoItem(Context context, VideoItemData data, VideoItemFactory videoItemFactory) {
super(context, data, VIDEO_ITEM_ATTRIBUTES);
mVideoItemFactory = videoItemFactory;
}
@Override
+ public Size getDimensions() {
+ int width = getWidth();
+ int height = getHeight();
+ if (mCachedSize == null ||
+ width != mCachedSize.getWidth() || height != mCachedSize.getHeight()) {
+ mCachedSize = new Size(width, height);
+ }
+ return mCachedSize;
+ }
+
+ @Override
public boolean delete() {
ContentResolver cr = mContext.getContentResolver();
cr.delete(VideoDataQuery.CONTENT_URI,
}
Point dim = CameraUtil.resizeToFill(
- imageData.getData().getDimensions().getWidth(),
- imageData.getData().getDimensions().getHeight(),
- imageData.getData().getOrientation(),
+ imageData.getDimensions().getWidth(),
+ imageData.getDimensions().getHeight(),
+ imageData.getOrientation(),
boundWidth,
boundHeight);
item.setMaximumBitmapRequested();
// Request full size bitmap, or max that DataAdapter will create.
int index = item.getAdapterIndex();
- int h = mDataAdapter.getFilmstripItemAt(index).getData().getDimensions().getHeight();
- int w = mDataAdapter.getFilmstripItemAt(index).getData().getDimensions().getWidth();
+ int h = mDataAdapter.getFilmstripItemAt(index).getDimensions().getHeight();
+ int w = mDataAdapter.getFilmstripItemAt(index).getDimensions().getWidth();
item.resizeView(w, h);
}
final FilmstripItem data = mDataAdapter.getFilmstripItemAt(index);
Point dim = CameraUtil
.resizeToFill(
- data.getData().getDimensions().getWidth(),
- data.getData().getDimensions().getHeight(),
- data.getData().getOrientation(),
+ data.getDimensions().getWidth(),
+ data.getDimensions().getHeight(),
+ data.getOrientation(),
getMeasuredWidth(),
getMeasuredHeight());
final int offsetX = dim.x + mViewGapInPixel;
// If there is no scrolling at all, adjust mCenterX to place
// the current item at the center.
Point dim = CameraUtil.resizeToFill(
- data.getData().getDimensions().getWidth(),
- data.getData().getDimensions().getHeight(),
- data.getData().getOrientation(),
+ data.getDimensions().getWidth(),
+ data.getDimensions().getHeight(),
+ data.getOrientation(),
getMeasuredWidth(),
getMeasuredHeight());
mCenterX = curr.getLeftPosition() + dim.x / 2;
if (imageData == null || !imageData.getAttributes().canZoomInPlace()) {
return FULL_SCREEN_SCALE;
}
- float imageWidth = imageData.getData().getDimensions().getWidth();
- if (imageData.getData().getOrientation() == 90
- || imageData.getData().getOrientation() == 270) {
- imageWidth = imageData.getData().getDimensions().getHeight();
+ float imageWidth = imageData.getDimensions().getWidth();
+ if (imageData.getOrientation() == 90
+ || imageData.getOrientation() == 270) {
+ imageWidth = imageData.getDimensions().getHeight();
}
float scale = imageWidth / curr.getWidth();
if (allowOverScale) {
if (uri == null || uri == Uri.EMPTY) {
return;
}
- int orientation = imageData.getData().getOrientation();
+ int orientation = imageData.getOrientation();
mZoomView.loadBitmap(uri, orientation, viewRect);
}