本文整理汇总了Java中com.android.gallery3d.common.Utils类的典型用法代码示例。如果您正苦于以下问题:Java Utils类的具体用法?Java Utils怎么用?Java Utils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Utils类属于com.android.gallery3d.common包,在下文中一共展示了Utils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
});
}
示例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();
}
示例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;
}
}
示例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);
}
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}
示例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();
}
}
});
}
示例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();
}
示例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");
}
}
示例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);
}