use of com.android.gallery3d.data.MediaItem in project android_packages_apps_Gallery2 by LineageOS.
the class PhotoDataAdapter method updateCurrentIndex.
private void updateCurrentIndex(int index) {
if (mCurrentIndex == index)
return;
mCurrentIndex = index;
updateSlidingWindow();
MediaItem item = mData[index % DATA_CACHE_SIZE];
mItemPath = item == null ? null : item.getPath();
updateImageCache();
updateImageRequests();
updateTileProvider();
if (mDataListener != null) {
mDataListener.onPhotoChanged(index, mItemPath);
}
fireDataChange();
}
use of com.android.gallery3d.data.MediaItem in project android_packages_apps_Gallery2 by LineageOS.
the class PhotoDataAdapter method uploadScreenNail.
private void uploadScreenNail(int offset) {
int index = mCurrentIndex + offset;
if (index < mActiveStart || index >= mActiveEnd)
return;
MediaItem item = getItem(index);
if (item == null)
return;
ImageEntry e = mImageCache.get(item.getPath());
if (e == null)
return;
ScreenNail s = e.screenNail;
if (s instanceof TiledScreenNail) {
TiledTexture t = ((TiledScreenNail) s).getTexture();
if (t != null && !t.isReady())
mUploader.addTexture(t);
}
}
use of com.android.gallery3d.data.MediaItem in project android_packages_apps_Gallery2 by LineageOS.
the class GalleryProvider method getType.
// TODO: consider concurrent access
@Override
public String getType(Uri uri) {
long token = Binder.clearCallingIdentity();
try {
Path path = Path.fromString(uri.getPath());
MediaItem item = (MediaItem) mDataManager.getMediaObject(path);
return item != null ? item.getMimeType() : null;
} finally {
Binder.restoreCallingIdentity(token);
}
}
use of com.android.gallery3d.data.MediaItem in project android_packages_apps_Gallery2 by LineageOS.
the class PhotoView method buildFallbackEffect.
public PhotoFallbackEffect buildFallbackEffect(GLView root, GLCanvas canvas) {
Rect location = new Rect();
Utils.assertTrue(root.getBoundsOf(this, location));
Rect fullRect = bounds();
PhotoFallbackEffect effect = new PhotoFallbackEffect();
for (int i = -SCREEN_NAIL_MAX; i <= SCREEN_NAIL_MAX; ++i) {
MediaItem item = mModel.getMediaItem(i);
if (item == null)
continue;
ScreenNail sc = mModel.getScreenNail(i);
if (!(sc instanceof TiledScreenNail) || ((TiledScreenNail) sc).isShowingPlaceholder())
continue;
// Now, sc is BitmapScreenNail and is not showing placeholder
Rect rect = new Rect(getPhotoRect(i));
if (!Rect.intersects(fullRect, rect))
continue;
rect.offset(location.left, location.top);
int width = sc.getWidth();
int height = sc.getHeight();
int rotation = mModel.getImageRotation(i);
RawTexture texture;
if ((rotation % 180) == 0) {
texture = new RawTexture(width, height, true);
canvas.beginRenderTarget(texture);
canvas.translate(width / 2f, height / 2f);
} else {
texture = new RawTexture(height, width, true);
canvas.beginRenderTarget(texture);
canvas.translate(height / 2f, width / 2f);
}
canvas.rotate(rotation, 0, 0, 1);
canvas.translate(-width / 2f, -height / 2f);
sc.draw(canvas, 0, 0, width, height);
canvas.endRenderTarget();
effect.addEntry(item.getPath(), rect, texture);
}
return effect;
}
use of com.android.gallery3d.data.MediaItem in project android_packages_apps_Gallery2 by LineageOS.
the class SelectionManager method expandMediaSet.
private static boolean expandMediaSet(ArrayList<Path> items, MediaSet set, int maxSelection) {
int subCount = set.getSubMediaSetCount();
for (int i = 0; i < subCount; i++) {
if (!expandMediaSet(items, set.getSubMediaSet(i), maxSelection)) {
return false;
}
}
int total = set.getMediaItemCount();
int batch = 50;
int index = 0;
while (index < total) {
int count = index + batch < total ? batch : total - index;
ArrayList<MediaItem> list = set.getMediaItem(index, count);
if (list != null && list.size() > (maxSelection - items.size())) {
return false;
}
for (MediaItem item : list) {
items.add(item.getPath());
}
index += batch;
}
return true;
}
Aggregations