import com.android.gallery3d.ui.GLCanvas;
import com.android.gallery3d.ui.GLRoot;
import com.android.gallery3d.ui.GLView;
-import com.android.gallery3d.ui.GridDrawer;
-import com.android.gallery3d.ui.HighlightDrawer;
import com.android.gallery3d.ui.RelativePosition;
import com.android.gallery3d.ui.ScreenNailHolder;
import com.android.gallery3d.ui.SelectionManager;
protected SelectionManager mSelectionManager;
private Vibrator mVibrator;
- private GridDrawer mGridDrawer;
- private HighlightDrawer mHighlightDrawer;
private boolean mGetContent;
private boolean mShowClusterMenu;
if (mShowDetails) {
mDetailsHelper.layout(left, slotViewTop, right, bottom);
} else {
- mAlbumView.setSelectionDrawer(mGridDrawer);
+ mAlbumView.setHighlightItemPath(null);
}
// Set the mSlotView as a reference point to the open animation
}
private void onDown(int index) {
- MediaItem item = mAlbumDataAdapter.get(index);
- Path path = (item == null) ? null : item.getPath();
- mSelectionManager.setPressedPath(path);
- mSlotView.invalidate();
+ mAlbumView.setPressedIndex(index);
}
private void onUp() {
- mSelectionManager.setPressedPath(null);
- mSlotView.invalidate();
+ mAlbumView.setPressedIndex(-1);
}
private void onSingleTapUp(int slotIndex) {
return;
}
if (mShowDetails) {
- mHighlightDrawer.setHighlightItem(item.getPath());
+ mAlbumView.setHighlightItemPath(item.getPath());
mDetailsHelper.reloadDetails(slotIndex);
} else if (!mSelectionManager.inSelectionMode()) {
if (mGetContent) {
private void initializeViews() {
mSelectionManager = new SelectionManager(mActivity, false);
mSelectionManager.setSelectionListener(this);
- mGridDrawer = new GridDrawer((Context) mActivity, mSelectionManager);
Config.AlbumPage config = Config.AlbumPage.get((Context) mActivity);
mSlotView = new SlotView((Context) mActivity, config.slotViewSpec);
- mAlbumView = new AlbumView(mActivity, mSlotView);
+ mAlbumView = new AlbumView(mActivity, mSlotView, mSelectionManager);
mSlotView.setSlotRenderer(mAlbumView);
- mAlbumView.setSelectionDrawer(mGridDrawer);
mRootPane.addComponent(mSlotView);
mSlotView.setListener(new SlotView.SimpleListener() {
@Override
private void showDetails() {
mShowDetails = true;
if (mDetailsHelper == null) {
- mHighlightDrawer = new HighlightDrawer(mActivity.getAndroidContext(),
- mSelectionManager);
mDetailsHelper = new DetailsHelper(mActivity, mRootPane, mDetailsSource);
mDetailsHelper.setCloseListener(new CloseListener() {
public void onClose() {
}
});
}
- mAlbumView.setSelectionDrawer(mHighlightDrawer);
mDetailsHelper.show();
}
private void hideDetails() {
mShowDetails = false;
mDetailsHelper.hide();
- mAlbumView.setSelectionDrawer(mGridDrawer);
+ mAlbumView.setHighlightItemPath(null);
mSlotView.invalidate();
}
public MediaDetails getDetails() {
MediaObject item = mAlbumDataAdapter.get(mIndex);
if (item != null) {
- mHighlightDrawer.setHighlightItem(item.getPath());
+ mAlbumView.setHighlightItemPath(item.getPath());
return item.getDetails();
} else {
return null;
import com.android.gallery3d.ui.GLCanvas;
import com.android.gallery3d.ui.GLRoot;
import com.android.gallery3d.ui.GLView;
-import com.android.gallery3d.ui.GridDrawer;
-import com.android.gallery3d.ui.HighlightDrawer;
import com.android.gallery3d.ui.SelectionManager;
import com.android.gallery3d.ui.SlotView;
import com.android.gallery3d.util.Future;
protected SelectionManager mSelectionManager;
private AlbumSetDataAdapter mAlbumSetDataAdapter;
- private GridDrawer mGridDrawer;
- private HighlightDrawer mHighlightDrawer;
private boolean mGetContent;
private boolean mGetAlbum;
if (mShowDetails) {
mDetailsHelper.layout(left, slotViewTop, right, bottom);
} else {
- mAlbumSetView.setSelectionDrawer(mGridDrawer);
+ mAlbumSetView.setHighlightItemPath(null);
}
mSlotView.layout(0, slotViewTop, slotViewRight, slotViewBottom);
if (targetSet == null) return; // Content is dirty, we shall reload soon
if (mShowDetails) {
- Path path = targetSet.getPath();
- mHighlightDrawer.setHighlightItem(path);
+ mAlbumSetView.setHighlightItemPath(targetSet.getPath());
mDetailsHelper.reloadDetails(slotIndex);
} else if (!mSelectionManager.inSelectionMode()) {
Bundle data = new Bundle(getData());
}
private void onDown(int index) {
- MediaSet set = mAlbumSetDataAdapter.getMediaSet(index);
- Path path = (set == null) ? null : set.getPath();
- mSelectionManager.setPressedPath(path);
- mSlotView.invalidate();
+ mAlbumSetView.setPressedIndex(index);
}
private void onUp() {
- mSelectionManager.setPressedPath(null);
- mSlotView.invalidate();
+ mAlbumSetView.setPressedIndex(-1);
}
public void onLongTap(int slotIndex) {
mSelectionManager = new SelectionManager(mActivity, true);
mSelectionManager.setSelectionListener(this);
- mGridDrawer = new GridDrawer((Context) mActivity, mSelectionManager);
Config.AlbumSetPage config = Config.AlbumSetPage.get((Context) mActivity);
mSlotView = new SlotView((Context) mActivity, config.slotViewSpec);
mAlbumSetView = new AlbumSetView(
- mActivity, mGridDrawer, mSlotView, config.labelSpec);
+ mActivity, mSelectionManager, mSlotView, config.labelSpec);
mSlotView.setSlotRenderer(mAlbumSetView);
mSlotView.setListener(new SlotView.SimpleListener() {
@Override
private void hideDetails() {
mShowDetails = false;
mDetailsHelper.hide();
- mAlbumSetView.setSelectionDrawer(mGridDrawer);
+ mAlbumSetView.setHighlightItemPath(null);
mSlotView.invalidate();
}
private void showDetails() {
mShowDetails = true;
if (mDetailsHelper == null) {
- mHighlightDrawer = new HighlightDrawer(mActivity.getAndroidContext(),
- mSelectionManager);
mDetailsHelper = new DetailsHelper(mActivity, mRootPane, mDetailsSource);
mDetailsHelper.setCloseListener(new CloseListener() {
@Override
}
});
}
- mAlbumSetView.setSelectionDrawer(mHighlightDrawer);
mDetailsHelper.show();
}
public MediaDetails getDetails() {
MediaObject item = mAlbumSetDataAdapter.getMediaSet(mIndex);
if (item != null) {
- mHighlightDrawer.setHighlightItem(item.getPath());
+ mAlbumSetView.setHighlightItemPath(item.getPath());
return item.getDetails();
} else {
return null;
import com.android.gallery3d.data.MediaObject;
import com.android.gallery3d.data.MediaSet;
import com.android.gallery3d.data.Path;
-import com.android.gallery3d.ui.AlbumSetView;
import com.android.gallery3d.ui.CacheStorageUsageInfo;
import com.android.gallery3d.ui.GLCanvas;
import com.android.gallery3d.ui.GLView;
import com.android.gallery3d.ui.ManageCacheDrawer;
import com.android.gallery3d.ui.MenuExecutor;
-import com.android.gallery3d.ui.SelectionDrawer;
import com.android.gallery3d.ui.SelectionManager;
import com.android.gallery3d.ui.SlotView;
import com.android.gallery3d.ui.SynchronizedHandler;
private static final int PROGRESS_BAR_MAX = 10000;
private SlotView mSlotView;
- private AlbumSetView mAlbumSetView;
-
private MediaSet mMediaSet;
protected SelectionManager mSelectionManager;
- protected SelectionDrawer mSelectionDrawer;
+ protected ManageCacheDrawer mSelectionDrawer;
private AlbumSetDataAdapter mAlbumSetDataAdapter;
private float mUserDistance; // in pixel
}
};
+ @Override
public void onEyePositionChanged(float x, float y, float z) {
mRootPane.lockRendering();
mX = x;
}
private void onDown(int index) {
- MediaSet set = mAlbumSetDataAdapter.getMediaSet(index);
- Path path = (set == null) ? null : set.getPath();
- mSelectionManager.setPressedPath(path);
- mSlotView.invalidate();
+ mSelectionDrawer.setPressedIndex(index);
}
private void onUp() {
- mSelectionManager.setPressedPath(null);
- mSlotView.invalidate();
+ mSelectionDrawer.setPressedIndex(-1);
}
public void onSingleTapUp(int slotIndex) {
public void onPause() {
super.onPause();
mAlbumSetDataAdapter.pause();
- mAlbumSetView.pause();
+ mSelectionDrawer.pause();
mEyePosition.pause();
if (mUpdateStorageInfo != null) {
super.onResume();
setContentPane(mRootPane);
mAlbumSetDataAdapter.resume();
- mAlbumSetView.resume();
+ mSelectionDrawer.resume();
mEyePosition.resume();
mUpdateStorageInfo = mActivity.getThreadPool().submit(mUpdateStorageInfoJob);
FrameLayout layout = (FrameLayout) ((Activity) mActivity).findViewById(R.id.footer);
mAlbumSetDataAdapter = new AlbumSetDataAdapter(
mActivity, mMediaSet, DATA_CACHE_SIZE);
- mAlbumSetView.setModel(mAlbumSetDataAdapter);
+ mSelectionDrawer.setModel(mAlbumSetDataAdapter);
}
private void initializeViews() {
mSelectionManager.setSelectionListener(this);
Config.ManageCachePage config = Config.ManageCachePage.get(activity);
- mSelectionDrawer = new ManageCacheDrawer((Context) mActivity,
- mSelectionManager, config.cachePinSize, config.cachePinMargin);
mSlotView = new SlotView((Context) mActivity, config.slotViewSpec);
- mAlbumSetView = new AlbumSetView(mActivity, mSelectionDrawer,
- mSlotView, config.labelSpec);
- mSlotView.setSlotRenderer(mAlbumSetView);
+ mSelectionDrawer = new ManageCacheDrawer(mActivity, mSelectionManager, mSlotView,
+ config.labelSpec, config.cachePinSize, config.cachePinMargin);
+ mSlotView.setSlotRenderer(mSelectionDrawer);
mSlotView.setListener(new SlotView.SimpleListener() {
@Override
public void onDown(int index) {
}
}
+ @Override
public void onProgressComplete(int result) {
onBackPressed();
}
+ @Override
public void onProgressUpdate(int index) {
}
+ @Override
public void onSelectionModeChange(int mode) {
}
+ @Override
public void onSelectionChange(Path path, boolean selected) {
}
-
}
--- /dev/null
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.data;
+
+import com.android.gallery3d.util.MediaSetUtils;
+
+public final class DataSourceType {
+ public static final int TYPE_NOT_CATEGORIZED = 0;
+ public static final int TYPE_LOCAL = 1;
+ public static final int TYPE_PICASA = 2;
+ public static final int TYPE_MTP = 3;
+ public static final int TYPE_CAMERA = 4;
+
+ private static final Path PICASA_ROOT = Path.fromString("/picasa");
+ private static final Path LOCAL_ROOT = Path.fromString("/local");
+ private static final Path MTP_ROOT = Path.fromString("/mtp");
+
+ public static int identifySourceType(MediaSet set) {
+ if (set == null) {
+ return TYPE_NOT_CATEGORIZED;
+ }
+
+ Path path = set.getPath();
+ if (MediaSetUtils.isCameraSource(path)) return TYPE_CAMERA;
+
+ Path prefix = path.getPrefixPath();
+
+ if (prefix == PICASA_ROOT) return TYPE_PICASA;
+ if (prefix == MTP_ROOT) return TYPE_MTP;
+ if (prefix == LOCAL_ROOT) return TYPE_LOCAL;
+
+ return TYPE_NOT_CATEGORIZED;
+ }
+}
}
public String getPrefix() {
+ if (this == sRoot) return "";
+ return getPrefixPath().mSegment;
+ }
+
+ public Path getPrefixPath() {
synchronized (Path.class) {
Path current = this;
- if (current == sRoot) return "";
+ if (current == sRoot) {
+ throw new IllegalStateException();
+ }
while (current.mParent != sRoot) {
current = current.mParent;
}
- return current.mSegment;
+ return current;
}
}
--- /dev/null
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.ui;
+
+import android.content.Context;
+import android.graphics.Rect;
+
+import com.android.gallery3d.R;
+
+public abstract class AbstractSlotRenderer implements SlotView.SlotRenderer {
+
+ private final ResourceTexture mVideoOverlay;
+ private final ResourceTexture mVideoPlayIcon;
+ private final NinePatchTexture mPanoramaBorder;
+ private final NinePatchTexture mFramePressed;
+ private final NinePatchTexture mFrameSelected;
+
+ protected AbstractSlotRenderer(Context context) {
+ mVideoOverlay = new ResourceTexture(context, R.drawable.ic_video_thumb);
+ mVideoPlayIcon = new ResourceTexture(context, R.drawable.ic_gallery_play);
+ mPanoramaBorder = new NinePatchTexture(context, R.drawable.ic_pan_thumb);
+ mFramePressed = new NinePatchTexture(context, R.drawable.grid_pressed);
+ mFrameSelected = new NinePatchTexture(context, R.drawable.grid_selected);
+ }
+
+ protected void drawContent(GLCanvas canvas,
+ Texture content, int width, int height, int rotation) {
+ canvas.save(GLCanvas.SAVE_FLAG_MATRIX);
+
+ if (rotation != 0) {
+ canvas.rotate(rotation, 0, 0, 1);
+ if (((rotation % 90) & 1) != 0) {
+ int temp = height;
+ height = width;
+ width = height;
+ }
+ }
+
+ // Fit the content into the box
+ float scale = Math.min(
+ (float) width / content.getWidth(),
+ (float) height / content.getHeight());
+ canvas.scale(scale, scale, 1);
+ content.draw(canvas, 0, 0);
+
+ canvas.restore();
+ }
+
+ protected void drawVideoOverlay(GLCanvas canvas, int width, int height) {
+ // Scale the video overlay to the height of the thumbnail and put it
+ // on the left side.
+ ResourceTexture v = mVideoOverlay;
+ float scale = (float) height / v.getHeight();
+ int w = Math.round(scale * v.getWidth());
+ int h = Math.round(scale * v.getHeight());
+ v.draw(canvas, 0, 0, w, h);
+
+ int s = Math.min(width, height) / 6;
+ mVideoPlayIcon.draw(canvas, (width - s) / 2, (height - s) / 2, s, s);
+ }
+
+ protected void drawPanoramaBorder(GLCanvas canvas, int width, int height) {
+ float scale = (float) width / mPanoramaBorder.getWidth();
+ int w = Math.round(scale * mPanoramaBorder.getWidth());
+ int h = Math.round(scale * mPanoramaBorder.getHeight());
+ // draw at the top
+ mPanoramaBorder.draw(canvas, 0, 0, w, h);
+ // draw at the bottom
+ mPanoramaBorder.draw(canvas, 0, height - h, w, h);
+ }
+
+ protected void drawPressedFrame(GLCanvas canvas, int width, int height) {
+ drawFrame(canvas, mFramePressed, 0, 0, width, height);
+ }
+
+ protected void drawSelectedFrame(GLCanvas canvas, int width, int height) {
+ drawFrame(canvas, mFrameSelected, 0, 0, width, height);
+ }
+
+ protected static void drawFrame(GLCanvas canvas, NinePatchTexture frame,
+ int x, int y, int width, int height) {
+ Rect p = frame.getPaddings();
+ frame.draw(canvas, x - p.left, y - p.top, width + p.left + p.right,
+ height + p.top + p.bottom);
+ }
+}
import com.android.gallery3d.R;
import com.android.gallery3d.common.Utils;
+import com.android.gallery3d.data.DataSourceType;
import com.android.gallery3d.data.MediaSet;
import com.android.gallery3d.util.ThreadPool;
import com.android.gallery3d.util.ThreadPool.JobContext;
private Bitmap getOverlayAlbumIcon(int sourceType) {
switch (sourceType) {
- case SelectionDrawer.DATASOURCE_TYPE_CAMERA:
+ case DataSourceType.TYPE_CAMERA:
return mCameraIcon.get();
- case SelectionDrawer.DATASOURCE_TYPE_LOCAL:
+ case DataSourceType.TYPE_LOCAL:
return mLocalSetIcon.get();
- case SelectionDrawer.DATASOURCE_TYPE_MTP:
+ case DataSourceType.TYPE_MTP:
return mMtpIcon.get();
- case SelectionDrawer.DATASOURCE_TYPE_PICASA:
+ case DataSourceType.TYPE_PICASA:
return mPicasaIcon.get();
}
return null;
import com.android.gallery3d.R;
import com.android.gallery3d.app.GalleryActivity;
import com.android.gallery3d.common.Utils;
+import com.android.gallery3d.data.DataSourceType;
import com.android.gallery3d.data.MediaItem;
import com.android.gallery3d.data.MediaObject;
import com.android.gallery3d.data.MediaSet;
import com.android.gallery3d.util.Future;
import com.android.gallery3d.util.FutureListener;
import com.android.gallery3d.util.GalleryUtils;
-import com.android.gallery3d.util.MediaSetUtils;
import com.android.gallery3d.util.ThreadPool;
public class AlbumSetSlidingWindow implements AlbumSetView.ModelListener {
}
public AlbumSetSlidingWindow(GalleryActivity activity,
- AlbumSetView.LabelSpec labelSpec, SelectionDrawer drawer,
- AlbumSetView.Model source, int cacheSize) {
+ AlbumSetView.Model source, AlbumSetView.LabelSpec labelSpec, int cacheSize) {
source.setModelListener(this);
mSource = source;
mData = new AlbumSetEntry[cacheSize];
int slotIndex, MediaSet album, MediaItem cover) {
entry.album = album;
entry.setDataVersion = getDataVersion(album);
- entry.sourceType = identifySourceType(album);
+ entry.sourceType = DataSourceType.identifySourceType(album);
entry.cacheFlag = identifyCacheFlag(album);
entry.cacheStatus = identifyCacheStatus(album);
entry.setPath = (album == null) ? null : album.getPath();
public BitmapTexture getLoadingTexture() {
if (mLoadingLabel == null) {
Bitmap bitmap = mLabelMaker.requestLabel(mLoadingText, null,
- SelectionDrawer.DATASOURCE_TYPE_NOT_CATEGORIZED)
+ DataSourceType.TYPE_NOT_CATEGORIZED)
.run(ThreadPool.JOB_CONTEXT_STUB);
mLoadingLabel = new BitmapTexture(bitmap);
mLoadingLabel.setOpaque(false);
}
}
- private static int identifySourceType(MediaSet set) {
- if (set == null) {
- return SelectionDrawer.DATASOURCE_TYPE_NOT_CATEGORIZED;
- }
-
- Path path = set.getPath();
- if (MediaSetUtils.isCameraSource(path)) {
- return SelectionDrawer.DATASOURCE_TYPE_CAMERA;
- }
-
- int type = SelectionDrawer.DATASOURCE_TYPE_NOT_CATEGORIZED;
- String prefix = path.getPrefix();
-
- if (prefix.equals("picasa")) {
- type = SelectionDrawer.DATASOURCE_TYPE_PICASA;
- } else if (prefix.equals("local") || prefix.equals("merge")) {
- type = SelectionDrawer.DATASOURCE_TYPE_LOCAL;
- } else if (prefix.equals("mtp")) {
- type = SelectionDrawer.DATASOURCE_TYPE_MTP;
- }
-
- return type;
- }
-
private static int identifyCacheFlag(MediaSet set) {
if (set == null || (set.getSupportedOperations()
& MediaSet.SUPPORT_CACHE) == 0) {
package com.android.gallery3d.ui;
import android.content.Context;
-import android.util.FloatMath;
import com.android.gallery3d.R;
import com.android.gallery3d.app.GalleryActivity;
import com.android.gallery3d.data.MediaItem;
+import com.android.gallery3d.data.MediaObject;
import com.android.gallery3d.data.MediaSet;
+import com.android.gallery3d.data.Path;
import com.android.gallery3d.ui.AlbumSetSlidingWindow.AlbumSetEntry;
// TODO: rename to AlbumSetRenderer
-public class AlbumSetView implements SlotView.SlotRenderer {
+public class AlbumSetView extends AbstractSlotRenderer {
@SuppressWarnings("unused")
private static final String TAG = "AlbumSetView";
private static final int CACHE_SIZE = 64;
private static final int PLACEHOLDER_COLOR = 0xFF222222;
private final ColorTexture mWaitLoadingTexture;
- private AlbumSetSlidingWindow mDataWindow;
private final GalleryActivity mActivity;
- private final LabelSpec mLabelSpec;
+ private final SelectionManager mSelectionManager;
+ protected final LabelSpec mLabelSpec;
- private SelectionDrawer mSelectionDrawer;
+ protected AlbumSetSlidingWindow mDataWindow;
private SlotView mSlotView;
private NinePatchTexture mDarkStrip;
+ private int mPressedIndex = -1;
+ private Path mHighlightItemPath = null;
+ private boolean mInSelectionMode;
+
public static interface Model {
public MediaItem getCoverItem(int index);
public MediaSet getMediaSet(int index);
public int iconSize;
}
- public AlbumSetView(GalleryActivity activity, SelectionDrawer drawer,
+ public AlbumSetView(GalleryActivity activity, SelectionManager selectionManager,
SlotView slotView, LabelSpec labelSpec) {
+ super ((Context) activity);
mActivity = activity;
- mLabelSpec = labelSpec;
+ mSelectionManager = selectionManager;
mSlotView = slotView;
+ mLabelSpec = labelSpec;
mWaitLoadingTexture = new ColorTexture(PLACEHOLDER_COLOR);
mWaitLoadingTexture.setSize(1, 1);
Context context = activity.getAndroidContext();
mDarkStrip = new NinePatchTexture(context, R.drawable.dark_strip);
+ }
- setSelectionDrawer(drawer);
+ public void setPressedIndex(int index) {
+ if (mPressedIndex == index) return;
+ mPressedIndex = index;
+ mSlotView.invalidate();
}
- public void setSelectionDrawer(SelectionDrawer drawer) {
- mSelectionDrawer = drawer;
+ public void setHighlightItemPath(Path path) {
+ if (mHighlightItemPath == path) return;
+ mHighlightItemPath = path;
mSlotView.invalidate();
}
mSlotView.setSlotCount(0);
}
if (model != null) {
- mDataWindow = new AlbumSetSlidingWindow(mActivity, mLabelSpec,
- mSelectionDrawer, model, CACHE_SIZE);
+ mDataWindow = new AlbumSetSlidingWindow(
+ mActivity, model, mLabelSpec, CACHE_SIZE);
mDataWindow.setListener(new MyCacheListener());
mSlotView.setSlotCount(mDataWindow.size());
}
@Override
public int renderSlot(GLCanvas canvas, int index, int pass, int width, int height) {
AlbumSetEntry entry = mDataWindow.get(index);
- return renderContent(canvas, pass, entry, width, height)
- | renderLabel(canvas, pass, entry, width, height);
+ int renderRequestFlags = 0;
+ renderRequestFlags |= renderContent(canvas, entry, width, height);
+ renderRequestFlags |= renderLabel(canvas, entry, width, height);
+ renderRequestFlags |= renderOverlay(canvas, index, entry, width, height);
+ return renderRequestFlags;
+ }
+
+ protected int renderOverlay(
+ GLCanvas canvas, int index, AlbumSetEntry entry, int width, int height) {
+ Path path = entry.setPath;
+ if (mPressedIndex == index) {
+ drawPressedFrame(canvas, width, height);
+ } else if ((path != null) && (mHighlightItemPath == path)) {
+ drawSelectedFrame(canvas, width, height);
+ } else if (mInSelectionMode && mSelectionManager.isItemSelected(path)) {
+ drawSelectedFrame(canvas, width, height);
+ }
+ return 0;
}
- private int renderContent(GLCanvas canvas,
- int pass, AlbumSetEntry entry, int width, int height) {
- Texture content = checkTexture(canvas, entry.content);
+ protected int renderContent(
+ GLCanvas canvas, AlbumSetEntry entry, int width, int height) {
+ int renderRequestFlags = 0;
+ Texture content = checkTexture(canvas, entry.content);
if (content == null) {
content = mWaitLoadingTexture;
entry.isWaitLoadingDisplayed = true;
} else if (entry.isWaitLoadingDisplayed) {
entry.isWaitLoadingDisplayed = false;
entry.content = new FadeInTexture(
- PLACEHOLDER_COLOR, (BitmapTexture) content);
+ PLACEHOLDER_COLOR, (BitmapTexture) entry.content);
content = entry.content;
}
-
- // Fit the content into the box
- int w = content.getWidth();
- int h = content.getHeight();
-
- float scale = Math.min(width / (float) w, height / (float) h);
-
- w = (int) FloatMath.floor(w * scale);
- h = (int) FloatMath.floor(h * scale);
-
- canvas.translate(width / 2, height / 2);
- // Now draw it
- mSelectionDrawer.draw(canvas, content, width, height,
- entry.rotation, entry.setPath, entry.sourceType, entry.mediaType,
- entry.isPanorama, mLabelSpec.labelBackgroundHeight,
- entry.cacheFlag == MediaSet.CACHE_FLAG_FULL,
- (entry.cacheFlag == MediaSet.CACHE_FLAG_FULL)
- && (entry.cacheStatus != MediaSet.CACHE_STATUS_CACHED_FULL));
- canvas.translate(-width / 2, -height / 2);
-
+ drawContent(canvas, content, width, height, entry.rotation);
if ((content instanceof FadeInTexture) &&
((FadeInTexture) content).isAnimating()) {
- return SlotView.RENDER_MORE_FRAME;
+ renderRequestFlags |= SlotView.RENDER_MORE_FRAME;
}
- return 0;
- }
- private int renderLabel(GLCanvas canvas,
- int pass, AlbumSetEntry entry, int width, int height) {
+ if (entry.mediaType == MediaObject.MEDIA_TYPE_VIDEO) {
+ drawVideoOverlay(canvas, width, height);
+ }
+
+ if (entry.isPanorama) {
+ drawPanoramaBorder(canvas, width, height);
+ }
+
+ return renderRequestFlags;
+ }
+ protected int renderLabel(
+ GLCanvas canvas, AlbumSetEntry entry, int width, int height) {
// We show the loading message only when the album is still loading
// (Not when we are still preparing the label)
Texture content = checkTexture(canvas, entry.label);
}
if (content != null) {
int h = mLabelSpec.labelBackgroundHeight;
- SelectionDrawer.drawFrame(canvas, mDarkStrip, 0, height - h, width, h);
+ drawFrame(canvas, mDarkStrip, 0, height - h, width, h);
content.draw(canvas, 0, height - h, width, h);
}
return 0;
@Override
public void prepareDrawing() {
- mSelectionDrawer.prepareDrawing();
+ mInSelectionMode = mSelectionManager.inSelectionMode();
}
private class MyCacheListener implements AlbumSetSlidingWindow.Listener {
package com.android.gallery3d.ui;
-import android.util.FloatMath;
+import android.content.Context;
import com.android.gallery3d.app.GalleryActivity;
import com.android.gallery3d.data.MediaItem;
+import com.android.gallery3d.data.MediaObject;
+import com.android.gallery3d.data.Path;
-public class AlbumView implements SlotView.SlotRenderer {
+public class AlbumView extends AbstractSlotRenderer {
private static final int PLACEHOLDER_COLOR = 0xFF222222;
@SuppressWarnings("unused")
private final GalleryActivity mActivity;
private final ColorTexture mWaitLoadingTexture;
private final SlotView mSlotView;
+ private final SelectionManager mSelectionManager;
- private SelectionDrawer mSelectionDrawer;
- private int mFocusIndex = -1;
+ private int mPressedIndex = -1;
+ private Path mHighlightItemPath = null;
+ private boolean mInSelectionMode;
public static interface Model {
public int size();
public void onSizeChanged(int size);
}
- public AlbumView(GalleryActivity activity, SlotView slotView) {
- mSlotView = slotView;
+ public AlbumView(GalleryActivity activity, SlotView slotView,
+ SelectionManager selectionManager) {
+ super((Context) activity);
mActivity = activity;
+ mSlotView = slotView;
+ mSelectionManager = selectionManager;
mWaitLoadingTexture = new ColorTexture(PLACEHOLDER_COLOR);
mWaitLoadingTexture.setSize(1, 1);
}
- public void setSelectionDrawer(SelectionDrawer drawer) {
- mSelectionDrawer = drawer;
+ public void setPressedIndex(int index) {
+ if (mPressedIndex == index) return;
+ mPressedIndex = index;
+ mSlotView.invalidate();
+ }
+
+ public void setHighlightItemPath(Path path) {
+ if (mHighlightItemPath == path) return;
+ mHighlightItemPath = path;
+ mSlotView.invalidate();
}
public void setModel(Model model) {
}
}
- public void setFocusIndex(int slotIndex) {
- if (mFocusIndex == slotIndex) return;
- mFocusIndex = slotIndex;
- mSlotView.invalidate();
- }
-
private static Texture checkTexture(GLCanvas canvas, Texture texture) {
return ((texture == null) || ((texture instanceof UploadedTexture)
&& !((UploadedTexture) texture).isContentValid(canvas)))
@Override
public int renderSlot(GLCanvas canvas, int index, int pass, int width, int height) {
AlbumSlidingWindow.AlbumEntry entry = mDataWindow.get(index);
- Texture content = checkTexture(canvas, entry.content);
+ int renderRequestFlags = 0;
+
+ Texture content = checkTexture(canvas, entry.content);
if (content == null) {
content = mWaitLoadingTexture;
entry.isWaitDisplayed = true;
PLACEHOLDER_COLOR, (BitmapTexture) entry.content);
content = entry.content;
}
+ drawContent(canvas, content, width, height, entry.rotation);
+ if ((content instanceof FadeInTexture) &&
+ ((FadeInTexture) content).isAnimating()) {
+ renderRequestFlags |= SlotView.RENDER_MORE_FRAME;
+ }
- // Fit the content into the box
- int w = content.getWidth();
- int h = content.getHeight();
-
- float scale = Math.min((float) width / w, (float) height / h);
-
- w = (int) FloatMath.floor(w * scale);
- h = (int) FloatMath.floor(h * scale);
-
- // Now draw it
- if (pass == 0) {
- canvas.translate(width / 2, height / 2);
- mSelectionDrawer.draw(canvas, content, w, h,
- entry.rotation, entry.path, entry.mediaType, entry.isPanorama);
- canvas.translate(-width / 2, -height / 2);
- int result = 0;
- if (mFocusIndex == index) {
- result |= SlotView.RENDER_MORE_PASS;
- }
- if ((content instanceof FadeInTexture) &&
- ((FadeInTexture) content).isAnimating()) {
- result |= SlotView.RENDER_MORE_FRAME;
- }
- return result;
- } else if (pass == 1) {
- canvas.translate(width / 2, height / 2);
- mSelectionDrawer.drawFocus(canvas, width, height);
- canvas.translate(-width / 2, -height / 2);
+ if (entry.mediaType == MediaObject.MEDIA_TYPE_VIDEO) {
+ drawVideoOverlay(canvas, width, height);
}
- return 0;
+
+ if (entry.isPanorama) {
+ drawPanoramaBorder(canvas, width, height);
+ }
+
+ if (mPressedIndex == index) {
+ drawPressedFrame(canvas, width, height);
+ } else if ((entry.path != null) && (mHighlightItemPath == entry.path)) {
+ drawSelectedFrame(canvas, width, height);
+ } else if (mInSelectionMode && mSelectionManager.isItemSelected(entry.path)) {
+ drawSelectedFrame(canvas, width, height);
+ }
+
+ return renderRequestFlags;
}
private class MyDataModelListener implements AlbumSlidingWindow.Listener {
@Override
public void prepareDrawing() {
- mSelectionDrawer.prepareDrawing();
+ mInSelectionMode = mSelectionManager.inSelectionMode();
}
@Override
+++ /dev/null
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.content.Context;
-import android.graphics.Color;
-import android.text.Layout;
-
-import com.android.gallery3d.R;
-import com.android.gallery3d.data.Path;
-
-public class GridDrawer extends IconDrawer {
- private Texture mImportLabel;
- private int mGridWidth;
- private final SelectionManager mSelectionManager;
- private final Context mContext;
- private final int IMPORT_FONT_SIZE = 14;
- private final int IMPORT_FONT_COLOR = Color.WHITE;
- private final int IMPORT_LABEL_MARGIN = 10;
- private boolean mSelectionMode;
-
- public GridDrawer(Context context, SelectionManager selectionManager) {
- super(context);
- mContext = context;
- mSelectionManager = selectionManager;
- }
-
- @Override
- public void prepareDrawing() {
- mSelectionMode = mSelectionManager.inSelectionMode();
- }
-
- @Override
- public void draw(GLCanvas canvas, Texture content, int width,
- int height, int rotation, Path path,
- int dataSourceType, int mediaType, boolean isPanorama,
- int labelBackgroundHeight, boolean wantCache, boolean isCaching) {
-
- int x = -width / 2;
- int y = -height / 2;
-
- drawWithRotation(canvas, content, x, y, width, height, rotation);
-
- if (((rotation / 90) & 0x01) == 1) {
- int temp = width;
- width = height;
- height = temp;
- x = -width / 2;
- y = -height / 2;
- }
-
- drawMediaTypeOverlay(canvas, mediaType, isPanorama, x, y, width, height);
-
- if (dataSourceType == DATASOURCE_TYPE_MTP) {
- drawImportLabel(canvas, width, height);
- }
-
- if (mSelectionManager.isPressedPath(path)) {
- drawPressedFrame(canvas, x, y, width, height);
- } else if (mSelectionMode && mSelectionManager.isItemSelected(path)) {
- drawSelectedFrame(canvas, x, y, width, height);
- }
- }
-
- // Draws the "click to import" label at the center of the frame
- private void drawImportLabel(GLCanvas canvas, int width, int height) {
- if (mImportLabel == null || mGridWidth != width) {
- mGridWidth = width;
- mImportLabel = MultiLineTexture.newInstance(
- mContext.getString(R.string.click_import),
- width - 2 * IMPORT_LABEL_MARGIN,
- IMPORT_FONT_SIZE, IMPORT_FONT_COLOR,
- Layout.Alignment.ALIGN_CENTER);
- }
- int w = mImportLabel.getWidth();
- int h = mImportLabel.getHeight();
- mImportLabel.draw(canvas, -w / 2, -h / 2);
- }
-
- @Override
- public void drawFocus(GLCanvas canvas, int width, int height) {
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.gallery3d.ui;
-
-import android.content.Context;
-
-import com.android.gallery3d.data.Path;
-
-public class HighlightDrawer extends IconDrawer {
- private SelectionManager mSelectionManager;
- private Path mHighlightItem;
-
- public HighlightDrawer(Context context, SelectionManager selectionManager) {
- super(context);
- mSelectionManager = selectionManager;
- }
-
- public void setHighlightItem(Path item) {
- mHighlightItem = item;
- }
-
- @Override
- public void draw(GLCanvas canvas, Texture content, int width,
- int height, int rotation, Path path,
- int dataSourceType, int mediaType, boolean isPanorama,
- int labelBackgroundHeight, boolean wantCache, boolean isCaching) {
- int x = -width / 2;
- int y = -height / 2;
-
- drawWithRotation(canvas, content, x, y, width, height, rotation);
-
- if (((rotation / 90) & 0x01) == 1) {
- int temp = width;
- width = height;
- height = temp;
- x = -width / 2;
- y = -height / 2;
- }
-
- drawMediaTypeOverlay(canvas, mediaType, isPanorama, x, y, width, height);
-
- if (mSelectionManager.isPressedPath(path)) {
- drawPressedFrame(canvas, x, y, width, height);
- } else if (path == mHighlightItem) {
- drawSelectedFrame(canvas, x, y, width, height);
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.gallery3d.ui;
-
-import android.content.Context;
-
-import com.android.gallery3d.R;
-import com.android.gallery3d.data.MediaObject;
-
-public abstract class IconDrawer extends SelectionDrawer {
- private static final String TAG = "IconDrawer";
-
- private final NinePatchTexture mFramePressed;
- private final NinePatchTexture mFrameSelected;
- private final NinePatchTexture mDarkStrip;
- private final NinePatchTexture mPanoramaBorder;
- private final Texture mVideoOverlay;
- private final Texture mVideoPlayIcon;
-
- public static class IconDimension {
- int x;
- int y;
- int width;
- int height;
- }
-
- public IconDrawer(Context context) {
- mVideoOverlay = new ResourceTexture(context, R.drawable.ic_video_thumb);
- mVideoPlayIcon = new ResourceTexture(context, R.drawable.ic_gallery_play);
- mPanoramaBorder = new NinePatchTexture(context, R.drawable.ic_pan_thumb);
- mFramePressed = new NinePatchTexture(context, R.drawable.grid_pressed);
- mFrameSelected = new NinePatchTexture(context, R.drawable.grid_selected);
- mDarkStrip = new NinePatchTexture(context, R.drawable.dark_strip);
- }
-
- @Override
- public void prepareDrawing() {
- }
-
- protected void drawMediaTypeOverlay(GLCanvas canvas, int mediaType,
- boolean isPanorama, int x, int y, int width, int height) {
- if (mediaType == MediaObject.MEDIA_TYPE_VIDEO) {
- drawVideoOverlay(canvas, x, y, width, height);
- }
- if (isPanorama) {
- drawPanoramaBorder(canvas, x, y, width, height);
- }
- }
-
- protected void drawVideoOverlay(GLCanvas canvas, int x, int y,
- int width, int height) {
- // Scale the video overlay to the height of the thumbnail and put it
- // on the left side.
- float scale = (float) height / mVideoOverlay.getHeight();
- int w = Math.round(scale * mVideoOverlay.getWidth());
- int h = Math.round(scale * mVideoOverlay.getHeight());
- mVideoOverlay.draw(canvas, x, y, w, h);
-
- int side = Math.min(width, height) / 6;
- mVideoPlayIcon.draw(canvas, -side / 2, -side / 2, side, side);
- }
-
- protected void drawPanoramaBorder(GLCanvas canvas, int x, int y,
- int width, int height) {
- float scale = (float) width / mPanoramaBorder.getWidth();
- int w = Math.round(scale * mPanoramaBorder.getWidth());
- int h = Math.round(scale * mPanoramaBorder.getHeight());
- // draw at the top
- mPanoramaBorder.draw(canvas, x, y, w, h);
- // draw at the bottom
- mPanoramaBorder.draw(canvas, x, y + width - h, w, h);
- }
-
- protected void drawLabelBackground(GLCanvas canvas, int width, int height,
- int drawLabelBackground) {
- int x = -width / 2;
- int y = (height + 1) / 2 - drawLabelBackground;
- drawFrame(canvas, mDarkStrip, x, y, width, drawLabelBackground);
- }
-
- protected void drawPressedFrame(GLCanvas canvas, int x, int y, int width,
- int height) {
- drawFrame(canvas, mFramePressed, x, y, width, height);
- }
-
- protected void drawSelectedFrame(GLCanvas canvas, int x, int y, int width,
- int height) {
- drawFrame(canvas, mFrameSelected, x, y, width, height);
- }
-
- @Override
- public void drawFocus(GLCanvas canvas, int width, int height) {
- }
-}
import android.content.Context;
import com.android.gallery3d.R;
+import com.android.gallery3d.app.GalleryActivity;
+import com.android.gallery3d.data.DataSourceType;
+import com.android.gallery3d.data.MediaSet;
import com.android.gallery3d.data.Path;
+import com.android.gallery3d.ui.AlbumSetSlidingWindow.AlbumSetEntry;
-public class ManageCacheDrawer extends IconDrawer {
+public class ManageCacheDrawer extends AlbumSetView {
private final ResourceTexture mCheckedItem;
private final ResourceTexture mUnCheckedItem;
private final SelectionManager mSelectionManager;
private final int mCachePinSize;
private final int mCachePinMargin;
- public ManageCacheDrawer(Context context, SelectionManager selectionManager,
- int cachePinSize, int cachePinMargin) {
- super(context);
- mCheckedItem = new ResourceTexture(context, R.drawable.btn_make_offline_normal_on_holo_dark);
- mUnCheckedItem = new ResourceTexture(context, R.drawable.btn_make_offline_normal_off_holo_dark);
- mLocalAlbumIcon = new ResourceTexture(context, R.drawable.btn_make_offline_disabled_on_holo_dark);
+ public ManageCacheDrawer(GalleryActivity activity, SelectionManager selectionManager,
+ SlotView slotView, LabelSpec labelSpec, int cachePinSize, int cachePinMargin) {
+ super(activity, selectionManager, slotView, labelSpec);
+ Context context = (Context) activity;
+ mCheckedItem = new ResourceTexture(
+ context, R.drawable.btn_make_offline_normal_on_holo_dark);
+ mUnCheckedItem = new ResourceTexture(
+ context, R.drawable.btn_make_offline_normal_off_holo_dark);
+ mLocalAlbumIcon = new ResourceTexture(
+ context, R.drawable.btn_make_offline_disabled_on_holo_dark);
String cachingLabel = context.getString(R.string.caching_label);
mCachingText = StringTexture.newInstance(cachingLabel, 12, 0xffffffff);
mSelectionManager = selectionManager;
mCachePinMargin = cachePinMargin;
}
- @Override
- public void prepareDrawing() {
- }
-
private static boolean isLocal(int dataSourceType) {
- return dataSourceType != DATASOURCE_TYPE_PICASA;
+ return dataSourceType != DataSourceType.TYPE_PICASA;
}
@Override
- public void draw(GLCanvas canvas, Texture content, int width,
- int height, int rotation, Path path,
- int dataSourceType, int mediaType, boolean isPanorama,
- int labelBackgroundHeight, boolean wantCache, boolean isCaching) {
+ public int renderSlot(GLCanvas canvas, int index, int pass, int width, int height) {
+ AlbumSetEntry entry = mDataWindow.get(index);
- boolean selected = mSelectionManager.isItemSelected(path);
+ boolean wantCache = entry.cacheFlag == MediaSet.CACHE_FLAG_FULL;
+ boolean isCaching = wantCache && (
+ entry.cacheStatus != MediaSet.CACHE_STATUS_CACHED_FULL);
+ boolean selected = mSelectionManager.isItemSelected(entry.setPath);
boolean chooseToCache = wantCache ^ selected;
- boolean available = isLocal(dataSourceType) || chooseToCache;
+ boolean available = isLocal(entry.sourceType) || chooseToCache;
- int x = -width / 2;
- int y = -height / 2;
+ int renderRequestFlags = 0;
if (!available) {
canvas.save(GLCanvas.SAVE_FLAG_ALPHA);
canvas.multiplyAlpha(0.6f);
}
+ renderRequestFlags |= renderContent(canvas, entry, width, height);
+ if (!available) canvas.restore();
- drawWithRotation(canvas, content, x, y, width, height, rotation);
-
- if (!available) {
- canvas.restore();
- }
-
- if (((rotation / 90) & 0x01) == 1) {
- int temp = width;
- width = height;
- height = temp;
- x = -width / 2;
- y = -height / 2;
- }
+ renderRequestFlags |= renderLabel(canvas, entry, width, height);
- drawMediaTypeOverlay(canvas, mediaType, isPanorama, x, y, width, height);
- drawCachingPin(canvas, path, dataSourceType, isCaching, chooseToCache,
- width, height);
+ drawCachingPin(canvas, entry.setPath,
+ entry.sourceType, isCaching, chooseToCache, width, height);
- if (mSelectionManager.isPressedPath(path)) {
- drawPressedFrame(canvas, x, y, width, height);
- }
+ renderRequestFlags |= renderOverlay(canvas, index, entry, width, height);
+ return renderRequestFlags;
}
private void drawCachingPin(GLCanvas canvas, Path path, int dataSourceType,
boolean isCaching, boolean chooseToCache, int width, int height) {
-
- ResourceTexture icon = null;
+ ResourceTexture icon;
if (isLocal(dataSourceType)) {
icon = mLocalAlbumIcon;
} else if (chooseToCache) {
icon = mUnCheckedItem;
}
- int w = mCachePinSize;
- int h = mCachePinSize;
- int right = (width + 1) / 2;
- int bottom = (height + 1) / 2;
- int x = right - w - mCachePinMargin;
- int y = bottom - h - mCachePinMargin;
-
- icon.draw(canvas, x, y, w, h);
+ // show the icon in right bottom
+ int s = mCachePinSize;
+ int m = mCachePinMargin;
+ icon.draw(canvas, width - m - s, height - s, s, s);
if (isCaching) {
- int textWidth = mCachingText.getWidth();
- int textHeight = mCachingText.getHeight();
- // Align the center of the text to the center of the pin icon
- x = right - mCachePinMargin - (textWidth + mCachePinSize) / 2;
- y = bottom - textHeight;
- mCachingText.draw(canvas, x, y);
+ int w = mCachingText.getWidth();
+ int h = mCachingText.getHeight();
+ // Show the caching text in bottom center
+ mCachingText.draw(canvas, (width - w) / 2, height - h);
}
}
-
- @Override
- public void drawFocus(GLCanvas canvas, int width, int height) {
- }
}
+++ /dev/null
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.ui;
-
-import android.graphics.Rect;
-
-import com.android.gallery3d.data.Path;
-
-/**
- * Drawer class responsible for drawing selectable frame.
- */
-public abstract class SelectionDrawer {
- public static final int DATASOURCE_TYPE_NOT_CATEGORIZED = 0;
- public static final int DATASOURCE_TYPE_LOCAL = 1;
- public static final int DATASOURCE_TYPE_PICASA = 2;
- public static final int DATASOURCE_TYPE_MTP = 3;
- public static final int DATASOURCE_TYPE_CAMERA = 4;
-
- public abstract void prepareDrawing();
- public abstract void draw(GLCanvas canvas, Texture content,
- int width, int height, int rotation, Path path,
- int dataSourceType, int mediaType, boolean isPanorama,
- int labelBackgroundHeight, boolean wantCache, boolean isCaching);
- public abstract void drawFocus(GLCanvas canvas, int width, int height);
-
- public void draw(GLCanvas canvas, Texture content, int width, int height,
- int rotation, Path path, int mediaType, boolean isPanorama) {
- draw(canvas, content, width, height, rotation, path,
- DATASOURCE_TYPE_NOT_CATEGORIZED, mediaType, isPanorama,
- 0, false, false);
- }
-
- public static void drawWithRotation(GLCanvas canvas, Texture content,
- int x, int y, int width, int height, int rotation) {
- if (rotation != 0) {
- canvas.save(GLCanvas.SAVE_FLAG_MATRIX);
- canvas.rotate(rotation, 0, 0, 1);
- }
-
- content.draw(canvas, x, y, width, height);
-
- if (rotation != 0) {
- canvas.restore();
- }
- }
-
- public static void drawFrame(GLCanvas canvas, NinePatchTexture frame,
- int x, int y, int width, int height) {
- Rect p = frame.getPaddings();
- frame.draw(canvas, x - p.left, y - p.top, width + p.left + p.right,
- height + p.top + p.bottom);
- }
-}
private boolean mInSelectionMode;
private boolean mAutoLeave = true;
private int mTotal;
- private Path mPressedPath;
public interface SelectionListener {
public void onSelectionModeChange(int mode);
}
}
- public void setPressedPath(Path path) {
- mPressedPath = path;
- }
-
- public boolean isPressedPath(Path path) {
- return path != null && path == mPressedPath;
- }
-
private static void expandMediaSet(ArrayList<Path> items, MediaSet set) {
int subCount = set.getSubMediaSetCount();
for (int i = 0; i < subCount; i++) {