本文整理汇总了Java中com.android.gallery3d.common.Utils类的典型用法代码示例。如果您正苦于以下问题:Java Utils类的具体用法?Java Utils怎么用?Java Utils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Utils类属于com.android.gallery3d.common包,在下文中一共展示了Utils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onClick
import com.android.gallery3d.common.Utils; //导入依赖的package包/类
@Override
public void onClick(final WallpaperPickerActivity a) {
a.setWallpaperButtonEnabled(false);
final BitmapRegionTileSource.ResourceBitmapSource bitmapSource =
new BitmapRegionTileSource.ResourceBitmapSource(mResources, mResId);
a.setCropViewTileSource(bitmapSource, false, false, new CropViewScaleProvider() {
@Override
public float getScale(TileSource src) {
Point wallpaperSize = WallpaperUtils.getDefaultWallpaperSize(
a.getResources(), a.getWindowManager());
RectF crop = Utils.getMaxCropRect(
src.getImageWidth(), src.getImageHeight(),
wallpaperSize.x, wallpaperSize.y, false);
return wallpaperSize.x / crop.width();
}
}, new Runnable() {
@Override
public void run() {
if (bitmapSource.getLoadingState() == BitmapSource.State.LOADED) {
a.setWallpaperButtonEnabled(true);
}
}
});
}
开发者ID:Mr-lin930819,项目名称:SimplOS,代码行数:27,代码来源:WallpaperPickerActivity.java
示例2: cropImageAndSetWallpaper
import com.android.gallery3d.common.Utils; //导入依赖的package包/类
protected void cropImageAndSetWallpaper(
Resources res, int resId, final boolean finishActivityWhenDone) {
// crop this image and scale it down to the default wallpaper size for
// this device
int rotation = BitmapUtils.getRotationFromExif(res, resId);
Point inSize = mCropView.getSourceDimensions();
Point outSize = WallpaperUtils.getDefaultWallpaperSize(getResources(),
getWindowManager());
RectF crop = Utils.getMaxCropRect(
inSize.x, inSize.y, outSize.x, outSize.y, false);
Runnable onEndCrop = new Runnable() {
public void run() {
// Passing 0, 0 will cause launcher to revert to using the
// default wallpaper size
updateWallpaperDimensions(0, 0);
if (finishActivityWhenDone) {
setResult(Activity.RESULT_OK);
finish();
}
}
};
BitmapCropTask cropTask = new BitmapCropTask(getContext(), res, resId,
crop, rotation, outSize.x, outSize.y, true, false, onEndCrop);
cropTask.execute();
}
开发者ID:Mr-lin930819,项目名称:SimplOS,代码行数:26,代码来源:WallpaperCropActivity.java
示例3: loadBitmapRegionDecoder
import com.android.gallery3d.common.Utils; //导入依赖的package包/类
@Override
public SimpleBitmapRegionDecoder loadBitmapRegionDecoder() {
try {
InputStream is = regenerateInputStream();
SimpleBitmapRegionDecoder regionDecoder =
SimpleBitmapRegionDecoderWrapper.newInstance(is, false);
Utils.closeSilently(is);
if (regionDecoder == null) {
is = regenerateInputStream();
regionDecoder = DumbBitmapRegionDecoder.newInstance(is);
Utils.closeSilently(is);
}
return regionDecoder;
} catch (FileNotFoundException e) {
Log.e("BitmapRegionTileSource", "Failed to load URI " + mUri, e);
return null;
}
}
开发者ID:Mr-lin930819,项目名称:SimplOS,代码行数:19,代码来源:BitmapRegionTileSource.java
示例4: updateBucketEntriesFromTable
import com.android.gallery3d.common.Utils; //导入依赖的package包/类
private static void updateBucketEntriesFromTable(JobContext jc,
ContentResolver resolver, Uri tableUri, HashMap<Integer, BucketEntry> buckets) {
Cursor cursor = resolver.query(tableUri, PROJECTION_BUCKET_IN_ONE_TABLE,
BUCKET_GROUP_BY_IN_ONE_TABLE, null, null);
if (cursor == null) {
Log.w(TAG, "cannot open media database: " + tableUri);
return;
}
try {
while (cursor.moveToNext()) {
int bucketId = cursor.getInt(INDEX_BUCKET_ID);
int dateTaken = cursor.getInt(INDEX_DATE_TAKEN);
BucketEntry entry = buckets.get(bucketId);
if (entry == null) {
entry = new BucketEntry(bucketId, cursor.getString(INDEX_BUCKET_NAME));
buckets.put(bucketId, entry);
entry.dateTaken = dateTaken;
} else {
entry.dateTaken = Math.max(entry.dateTaken, dateTaken);
}
}
} finally {
Utils.closeSilently(cursor);
}
}
开发者ID:asm-products,项目名称:nexus-gallery,代码行数:26,代码来源:BucketHelper.java
示例5: getBucketNameInTable
import com.android.gallery3d.common.Utils; //导入依赖的package包/类
private static String getBucketNameInTable(
ContentResolver resolver, Uri tableUri, int bucketId) {
String selectionArgs[] = new String[] {String.valueOf(bucketId)};
Uri uri = tableUri.buildUpon()
.appendQueryParameter("limit", "1")
.build();
Cursor cursor = resolver.query(uri, PROJECTION_BUCKET_IN_ONE_TABLE,
"bucket_id = ?", selectionArgs, null);
try {
if (cursor != null && cursor.moveToNext()) {
return cursor.getString(INDEX_BUCKET_NAME);
}
} finally {
Utils.closeSilently(cursor);
}
return null;
}
开发者ID:asm-products,项目名称:nexus-gallery,代码行数:18,代码来源:BucketHelper.java
示例6: advanceAnimation
import com.android.gallery3d.common.Utils; //导入依赖的package包/类
private void advanceAnimation() {
if (mAnimationStartTime == NO_ANIMATION) return;
float delta = (float) (AnimationTime.get() - mAnimationStartTime) /
ANIM_TIME;
mAlpha = mFromAlpha + ((mToAlpha > mFromAlpha) ? delta : -delta);
mAlpha = Utils.clamp(mAlpha, 0f, 1f);
if (mAlpha == mToAlpha) {
mAnimationStartTime = NO_ANIMATION;
if (mAlpha == 0) {
super.setVisibility(INVISIBLE);
}
}
invalidate();
}
开发者ID:asm-products,项目名称:nexus-gallery,代码行数:17,代码来源:UndoBarView.java
示例7: getImageData
import com.android.gallery3d.common.Utils; //导入依赖的package包/类
/**
* Gets the cached image data for the given <code>path</code>,
* <code>timeModified</code> and <code>type</code>.
*
* The image data will be stored in <code>buffer.data</code>, started from
* <code>buffer.offset</code> for <code>buffer.length</code> bytes. If the
* buffer.data is not big enough, a new byte array will be allocated and returned.
*
* @return true if the image data is found; false if not found.
*/
public boolean getImageData(Path path, long timeModified, int type, BytesBuffer buffer) {
byte[] key = makeKey(path, timeModified, type);
long cacheKey = Utils.crc64Long(key);
try {
LookupRequest request = new LookupRequest();
request.key = cacheKey;
request.buffer = buffer.data;
synchronized (mCache) {
if (!mCache.lookup(request)) return false;
}
if (isSameKey(key, request.buffer)) {
buffer.data = request.buffer;
buffer.offset = key.length;
buffer.length = request.length - buffer.offset;
return true;
}
} catch (IOException ex) {
// ignore.
}
return false;
}
开发者ID:asm-products,项目名称:nexus-gallery,代码行数:32,代码来源:ImageCacheService.java
示例8: onGLIdle
import com.android.gallery3d.common.Utils; //导入依赖的package包/类
@Override
public boolean onGLIdle(GLCanvas canvas, boolean renderRequested) {
// Skips uploading if there is a pending rendering request.
// Returns true to keep uploading in next rendering loop.
if (renderRequested) return true;
int quota = UPLOAD_LIMIT;
Tile tile = null;
while (quota > 0) {
synchronized (TileImageView.this) {
tile = mUploadQueue.pop();
}
if (tile == null) break;
if (!tile.isContentValid()) {
boolean hasBeenLoaded = tile.isLoaded();
Utils.assertTrue(tile.mTileState == STATE_DECODED);
tile.updateContent(canvas);
if (!hasBeenLoaded) tile.draw(canvas, 0, 0);
--quota;
}
}
if (tile == null) mActive.set(false);
return tile != null;
}
开发者ID:asm-products,项目名称:nexus-gallery,代码行数:24,代码来源:TileImageView.java
示例9: getScreenNail
import com.android.gallery3d.common.Utils; //导入依赖的package包/类
@Override
public ScreenNail getScreenNail(int offset) {
int index = mCurrentIndex + offset;
if (index < 0 || index >= mSize || !mIsActive) return null;
Utils.assertTrue(index >= mActiveStart && index < mActiveEnd);
MediaItem item = getItem(index);
if (item == null) return null;
ImageEntry entry = mImageCache.get(item.getPath());
if (entry == null) return null;
// Create a default ScreenNail if the real one is not available yet,
// except for camera that a black screen is better than a gray tile.
if (entry.screenNail == null && !isCamera(offset)) {
entry.screenNail = newPlaceholderScreenNail(item);
if (offset == 0) updateTileProvider(entry);
}
return entry.screenNail;
}
开发者ID:asm-products,项目名称:nexus-gallery,代码行数:22,代码来源:PhotoDataAdapter.java
示例10: run
import com.android.gallery3d.common.Utils; //导入依赖的package包/类
@Override
public Void run(JobContext jc) {
jc.setMode(ThreadPool.MODE_NONE);
jc.setCancelListener(mNotifier);
while (!jc.isCancelled()) {
Tile tile = null;
synchronized(TileImageView.this) {
tile = mDecodeQueue.pop();
if (tile == null && !jc.isCancelled()) {
Utils.waitWithoutInterrupt(TileImageView.this);
}
}
if (tile == null) continue;
if (decodeTile(tile)) queueForUpload(tile);
}
return null;
}
开发者ID:asm-products,项目名称:nexus-gallery,代码行数:18,代码来源:TileImageView.java
示例11: onClick
import com.android.gallery3d.common.Utils; //导入依赖的package包/类
@Override
public void onClick(View view) {
Utils.assertTrue(view.getId() == R.id.done);
GLRoot root = mActivity.getGLRoot();
root.lockRenderThread();
try {
ArrayList<Path> ids = mSelectionManager.getSelected(false);
if (ids.size() == 0) {
onBackPressed();
return;
}
showToast();
MenuExecutor menuExecutor = new MenuExecutor(mActivity, mSelectionManager);
menuExecutor.startAction(R.id.action_toggle_full_caching,
R.string.process_caching_requests, this);
} finally {
root.unlockRenderThread();
}
}
开发者ID:asm-products,项目名称:nexus-gallery,代码行数:21,代码来源:ManageCachePage.java
示例12: onSyncDone
import com.android.gallery3d.common.Utils; //导入依赖的package包/类
@Override
public void onSyncDone(final MediaSet mediaSet, final int resultCode) {
Log.d(TAG, "onSyncDone: " + Utils.maskDebugInfo(mediaSet.getName()) + " result="
+ resultCode);
((Activity) mActivity).runOnUiThread(new Runnable() {
@Override
public void run() {
GLRoot root = mActivity.getGLRoot();
root.lockRenderThread();
mSyncResult = resultCode;
try {
if (resultCode == MediaSet.SYNC_RESULT_SUCCESS) {
mInitialSynced = true;
}
clearLoadingBit(BIT_LOADING_SYNC);
showSyncErrorIfNecessary(mLoadingFailed);
} finally {
root.unlockRenderThread();
}
}
});
}
开发者ID:asm-products,项目名称:nexus-gallery,代码行数:23,代码来源:AlbumPage.java
示例13: SinglePhotoDataAdapter
import com.android.gallery3d.common.Utils; //导入依赖的package包/类
public SinglePhotoDataAdapter(
AbstractGalleryActivity activity, PhotoView view, MediaItem item) {
mItem = Utils.checkNotNull(item);
mHasFullImage = (item.getSupportedOperations() &
MediaItem.SUPPORT_FULL_IMAGE) != 0;
mPhotoView = Utils.checkNotNull(view);
mHandler = new SynchronizedHandler(activity.getGLRoot()) {
@Override
@SuppressWarnings("unchecked")
public void handleMessage(Message message) {
Utils.assertTrue(message.what == MSG_UPDATE_IMAGE);
if (mHasFullImage) {
onDecodeLargeComplete((ImageBundle) message.obj);
} else {
onDecodeThumbComplete((Future<Bitmap>) message.obj);
}
}
};
mThreadPool = activity.getThreadPool();
}
开发者ID:asm-products,项目名称:nexus-gallery,代码行数:21,代码来源:SinglePhotoDataAdapter.java
示例14: openPipeHelper
import com.android.gallery3d.common.Utils; //导入依赖的package包/类
private static <T> ParcelFileDescriptor openPipeHelper(
final T args, final PipeDataWriter<T> func) throws FileNotFoundException {
try {
final ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
AsyncTask<Object, Object, Object> task = new AsyncTask<Object, Object, Object>() {
@Override
protected Object doInBackground(Object... params) {
try {
func.writeDataToPipe(pipe[1], args);
return null;
} finally {
Utils.closeSilently(pipe[1]);
}
}
};
AsyncTaskUtil.executeInParallel(task, (Object[]) null);
return pipe[0];
} catch (IOException e) {
throw new FileNotFoundException("failure making pipe");
}
}
开发者ID:asm-products,项目名称:nexus-gallery,代码行数:22,代码来源:GalleryProvider.java
示例15: onSurfaceChanged
import com.android.gallery3d.common.Utils; //导入依赖的package包/类
/**
* Called when the OpenGL surface is recreated without destroying the
* context.
*/
// This is a GLSurfaceView.Renderer callback
@Override
public void onSurfaceChanged(GL10 gl1, int width, int height) {
Log.i(TAG, "onSurfaceChanged: " + width + "x" + height
+ ", gl10: " + gl1.toString());
Process.setThreadPriority(Process.THREAD_PRIORITY_DISPLAY);
GalleryUtils.setRenderThread();
if (DEBUG_PROFILE) {
Log.d(TAG, "Start profiling");
Profile.enable(20); // take a sample every 20ms
}
GL11 gl = (GL11) gl1;
Utils.assertTrue(mGL == gl);
mCanvas.setSize(width, height);
}
开发者ID:asm-products,项目名称:nexus-gallery,代码行数:21,代码来源:GLRootView.java
示例16: isContentSound
import com.android.gallery3d.common.Utils; //导入依赖的package包/类
private boolean isContentSound(int totalCount) {
if (mPhotos.size() < Math.min(totalCount, MAX_PHOTO_COUNT)) return false;
if (mPhotos.size() == 0) return true; // totalCount is also 0
StringBuilder builder = new StringBuilder();
for (Long imageId : mPhotos) {
if (builder.length() > 0) builder.append(",");
builder.append(imageId);
}
Cursor cursor = mContext.getContentResolver().query(
CONTENT_URI, COUNT_PROJECTION,
String.format("%s in (%s)", Media._ID, builder.toString()),
null, null);
if (cursor == null) return false;
try {
Utils.assertTrue(cursor.moveToNext());
return cursor.getInt(0) == mPhotos.size();
} finally {
cursor.close();
}
}
开发者ID:asm-products,项目名称:nexus-gallery,代码行数:22,代码来源:LocalPhotoSource.java
示例17: dumpToFile
import com.android.gallery3d.common.Utils; //导入依赖的package包/类
public void dumpToFile(String filename) {
try {
mOut = new DataOutputStream(new FileOutputStream(filename));
// Start record
writeInt(0);
writeInt(3);
writeInt(1);
writeInt(20000); // Sampling period: 20ms
writeInt(0);
// Samples
writeAllStacks(mRoot, 0);
// End record
writeInt(0);
writeInt(1);
writeInt(0);
writeAllSymbols();
} catch (IOException ex) {
Log.w("Failed to dump to file", ex);
} finally {
Utils.closeSilently(mOut);
}
}
开发者ID:asm-products,项目名称:nexus-gallery,代码行数:25,代码来源:ProfileData.java
示例18: setColorMode
import com.android.gallery3d.common.Utils; //导入依赖的package包/类
public void setColorMode(int color, float alpha) {
setBlendEnabled(!Utils.isOpaque(color) || alpha < OPAQUE_ALPHA);
// Set mTextureAlpha to an invalid value, so that it will reset
// again in setTextureAlpha(float) later.
mTextureAlpha = -1.0f;
setTextureTarget(0);
float prealpha = (color >>> 24) * alpha * 65535f / 255f / 255f;
mGL.glColor4x(
Math.round(((color >> 16) & 0xFF) * prealpha),
Math.round(((color >> 8) & 0xFF) * prealpha),
Math.round((color & 0xFF) * prealpha),
Math.round(255 * prealpha));
}
开发者ID:asm-products,项目名称:nexus-gallery,代码行数:17,代码来源:GLES11Canvas.java
示例19: setActiveWindow
import com.android.gallery3d.common.Utils; //导入依赖的package包/类
public void setActiveWindow(int start, int end) {
if (!(start <= end && end - start <= mData.length && end <= mSize)) {
Utils.fail("%s, %s, %s, %s", start, end, mData.length, mSize);
}
AlbumEntry data[] = mData;
mActiveStart = start;
mActiveEnd = end;
int contentStart = Utils.clamp((start + end) / 2 - data.length / 2,
0, Math.max(0, mSize - data.length));
int contentEnd = Math.min(contentStart + data.length, mSize);
setContentWindow(contentStart, contentEnd);
updateTextureUploadQueue();
if (mIsActive) updateAllImageRequests();
}
开发者ID:asm-products,项目名称:nexus-gallery,代码行数:17,代码来源:AlbumSlidingWindow.java
示例20: AlbumSetSlidingWindow
import com.android.gallery3d.common.Utils; //导入依赖的package包/类
public AlbumSetSlidingWindow(AbstractGalleryActivity activity,
AlbumSetDataLoader source, AlbumSetSlotRenderer.LabelSpec labelSpec, int cacheSize) {
source.setModelListener(this);
mSource = source;
mData = new AlbumSetEntry[cacheSize];
mSize = source.size();
mThreadPool = activity.getThreadPool();
mLabelMaker = new AlbumLabelMaker(activity.getAndroidContext(), labelSpec);
mLoadingText = activity.getAndroidContext().getString(R.string.loading);
mContentUploader = new TiledTexture.Uploader(activity.getGLRoot());
mLabelUploader = new TextureUploader(activity.getGLRoot());
mHandler = new SynchronizedHandler(activity.getGLRoot()) {
@Override
public void handleMessage(Message message) {
Utils.assertTrue(message.what == MSG_UPDATE_ALBUM_ENTRY);
((EntryUpdater) message.obj).updateEntry();
}
};
}
开发者ID:asm-products,项目名称:nexus-gallery,代码行数:22,代码来源:AlbumSetSlidingWindow.java
注:本文中的com.android.gallery3d.common.Utils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论