本文整理汇总了Java中android.provider.MediaStore.Images类的典型用法代码示例。如果您正苦于以下问题:Java Images类的具体用法?Java Images怎么用?Java Images使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Images类属于android.provider.MediaStore包,在下文中一共展示了Images类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: query
import android.provider.MediaStore.Images; //导入依赖的package包/类
private Cursor query(ContentResolver cr, String bucketId, String[] columns, boolean isDefaultAlbum,
boolean isNeedGif, String imageMimeType, String[] args, String order, String selectionId) {
Cursor resultCursor;
if (isDefaultAlbum) {
resultCursor = cr.query(Images.Media.EXTERNAL_CONTENT_URI, columns, imageMimeType,
args, order);
} else {
if (isNeedGif) {
resultCursor = cr.query(Images.Media.EXTERNAL_CONTENT_URI, columns, selectionId,
new String[]{bucketId, args[0], args[1], args[2], args[3]}, order);
} else {
resultCursor = cr.query(Images.Media.EXTERNAL_CONTENT_URI, columns, selectionId,
new String[]{bucketId, args[0], args[1], args[2]}, order);
}
}
return resultCursor;
}
示例2: loadBucketEntriesFromImagesAndVideoTable
import android.provider.MediaStore.Images; //导入依赖的package包/类
private static BucketEntry[] loadBucketEntriesFromImagesAndVideoTable(
ThreadPool.JobContext jc, ContentResolver resolver, int type) {
HashMap<Integer, BucketEntry> buckets = new HashMap<Integer, BucketEntry>(64);
if ((type & MediaObject.MEDIA_TYPE_IMAGE) != 0) {
updateBucketEntriesFromTable(
jc, resolver, Images.Media.EXTERNAL_CONTENT_URI, buckets);
}
if ((type & MediaObject.MEDIA_TYPE_VIDEO) != 0) {
updateBucketEntriesFromTable(
jc, resolver, Video.Media.EXTERNAL_CONTENT_URI, buckets);
}
BucketEntry[] entries = buckets.values().toArray(new BucketEntry[buckets.size()]);
Arrays.sort(entries, new Comparator<BucketEntry>() {
@Override
public int compare(BucketEntry a, BucketEntry b) {
// sorted by dateTaken in descending order
return b.dateTaken - a.dateTaken;
}
});
return entries;
}
示例3: openImageThumbnailCleared
import android.provider.MediaStore.Images; //导入依赖的package包/类
protected ParcelFileDescriptor openImageThumbnailCleared(long id, CancellationSignal signal)
throws FileNotFoundException {
final ContentResolver resolver = getContext().getContentResolver();
Cursor cursor = null;
try {
cursor = resolver.query(Images.Thumbnails.EXTERNAL_CONTENT_URI,
ImageThumbnailQuery.PROJECTION, Images.Thumbnails.IMAGE_ID + "=" + id, null,
null);
if (cursor.moveToFirst()) {
final String data = cursor.getString(ImageThumbnailQuery._DATA);
return ParcelFileDescriptor.open(
new File(data), ParcelFileDescriptor.MODE_READ_ONLY);
}
} finally {
IoUtils.closeQuietly(cursor);
}
return null;
}
示例4: queryThumbnails
import android.provider.MediaStore.Images; //导入依赖的package包/类
private void queryThumbnails(ContentResolver cr, String[] projection) {
Cursor cur = null;
try {
cur = Images.Thumbnails.queryMiniThumbnails(cr, Images.Thumbnails.EXTERNAL_CONTENT_URI,
Images.Thumbnails.MINI_KIND, projection);
if (cur != null && cur.moveToFirst()) {
do {
String imageId = cur.getString(cur.getColumnIndex(Images.Thumbnails.IMAGE_ID));
String imagePath = cur.getString(cur.getColumnIndex(Images.Thumbnails.DATA));
mThumbnailMap.put(imageId, imagePath);
} while (cur.moveToNext() && !cur.isLast());
}
} finally {
if (cur != null) {
cur.close();
}
}
}
示例5: buildAlbumList
import android.provider.MediaStore.Images; //导入依赖的package包/类
private List<ImageMedia> buildAlbumList(ContentResolver cr, String bucketId, int page,
@NonNull final IMediaTaskCallback<ImageMedia> callback) {
List<ImageMedia> result = new ArrayList<>();
String columns[] = getColumns();
Cursor cursor = null;
try {
boolean isDefaultAlbum = TextUtils.isEmpty(bucketId);
boolean isNeedPaging = mPickerConfig == null || mPickerConfig.isNeedPaging();
boolean isNeedGif = mPickerConfig != null && mPickerConfig.isNeedGif();
int totalCount = getTotalCount(cr, bucketId, columns, isDefaultAlbum, isNeedGif);
String imageMimeType = isNeedGif ? SELECTION_IMAGE_MIME_TYPE : SELECTION_IMAGE_MIME_TYPE_WITHOUT_GIF;
String[] args = isNeedGif ? SELECTION_ARGS_IMAGE_MIME_TYPE : SELECTION_ARGS_IMAGE_MIME_TYPE_WITHOUT_GIF;
String order = isNeedPaging ? Images.Media.DATE_MODIFIED + " desc" + " LIMIT "
+ page * IMediaTask.PAGE_LIMIT + " , " + IMediaTask.PAGE_LIMIT : Images.Media.DATE_MODIFIED + " desc";
String selectionId = isNeedGif ? SELECTION_ID : SELECTION_ID_WITHOUT_GIF;
cursor = query(cr, bucketId, columns, isDefaultAlbum, isNeedGif, imageMimeType, args, order, selectionId);
addItem(totalCount, result, cursor, callback);
} finally {
if (cursor != null) {
cursor.close();
}
}
return result;
}
示例6: buildAlbumList
import android.provider.MediaStore.Images; //导入依赖的package包/类
private List<ImageMedia> buildAlbumList(ContentResolver cr, String bucketId, int page,
@NonNull final IMediaTaskCallback<ImageMedia> callback) {
List<ImageMedia> result = new ArrayList<>();
String columns[] = getColumns();
Cursor cursor = null;
try {
boolean isDefaultAlbum = TextUtils.isEmpty(bucketId);
boolean isNeedPaging = mPickerConfig == null || mPickerConfig.isNeedPaging();
boolean isNeedGif = mPickerConfig != null && mPickerConfig.isNeedGif();
int totalCount = getTotalCount(cr, bucketId, columns, isDefaultAlbum, isNeedGif);
String imageMimeType = isNeedGif ? SELECTION_IMAGE_MIME_TYPE : SELECTION_IMAGE_MIME_TYPE_WITHOUT_GIF;
String[] args = isNeedGif ? SELECTION_ARGS_IMAGE_MIME_TYPE : SELECTION_ARGS_IMAGE_MIME_TYPE_WITHOUT_GIF;
String order = isNeedPaging ? Images.Media.DATE_MODIFIED + DESC + " LIMIT "
+ page * IMediaTask.PAGE_LIMIT + " , " + IMediaTask.PAGE_LIMIT : Images.Media.DATE_MODIFIED + DESC;
String selectionId = isNeedGif ? SELECTION_ID : SELECTION_ID_WITHOUT_GIF;
cursor = query(cr, bucketId, columns, isDefaultAlbum, isNeedGif, imageMimeType, args, order, selectionId);
addItem(totalCount, result, cursor, callback);
} finally {
if (cursor != null) {
cursor.close();
}
}
return result;
}
示例7: queryOrientationForImage
import android.provider.MediaStore.Images; //导入依赖的package包/类
protected int queryOrientationForImage(long id, CancellationSignal signal) {
final ContentResolver resolver = getContext().getContentResolver();
Cursor cursor = null;
try {
cursor = resolver.query(Images.Media.EXTERNAL_CONTENT_URI,
ImageOrientationQuery.PROJECTION, ImageColumns._ID + "=" + id, null, null);
if (cursor.moveToFirst()) {
return cursor.getInt(ImageOrientationQuery.ORIENTATION);
} else {
Log.w(TAG, "Missing orientation data for " + id);
return 0;
}
} finally {
IoUtils.closeQuietly(cursor);
}
}
示例8: LocalImage
import android.provider.MediaStore.Images; //导入依赖的package包/类
public LocalImage(Path path, MediaDataContext application, int id) {
super(path, nextVersionNumber());
mApplication = application;
ContentResolver resolver = mApplication.getContentResolver();
Uri uri = Images.Media.EXTERNAL_CONTENT_URI;
Cursor cursor = LocalAlbum.getItemCursor(resolver, uri, PROJECTION, id);
if (cursor == null) {
throw new RuntimeException("cannot get cursor for: " + path);
}
try {
if (cursor.moveToNext()) {
loadFromCursor(cursor);
} else {
throw new RuntimeException("cannot find data for: " + path);
}
} finally {
cursor.close();
}
}
示例9: rotate
import android.provider.MediaStore.Images; //导入依赖的package包/类
@Override
public void rotate(int degrees) throws Exception {
GalleryUtils.assertNotInRenderThread();
Uri baseUri = Images.Media.EXTERNAL_CONTENT_URI;
ContentValues values = new ContentValues();
int rotation = (this.rotation + degrees) % 360;
if (rotation < 0) rotation += 360;
if (mimeType.equalsIgnoreCase("image/jpeg")) {
ExifInterface exifInterface = new ExifInterface(filePath);
exifInterface.setAttribute(ExifInterface.TAG_ORIENTATION,
String.valueOf(rotation));
exifInterface.saveAttributes();
fileSize = new File(filePath).length();
values.put(Images.Media.SIZE, fileSize);
}
values.put(Images.Media.ORIENTATION, rotation);
mApplication.getContentResolver().update(baseUri, values, "_id=?",
new String[]{String.valueOf(id)});
}
示例10: getFilePath
import android.provider.MediaStore.Images; //导入依赖的package包/类
/**
* 获取文件的路径
*
* @param
* @return
*/
public static String getFilePath(Context context, Uri uri) {
String filePath = null;
if (!TextUtils.isEmpty(uri.getAuthority())) {
String[] projection = {MediaStore.Images.Media.DATA};
Cursor cursor = context.getContentResolver().query(uri, projection, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
filePath = cursor.getString(column_index);
} else {
filePath = uri.getPath();
}
return filePath;
}
示例11: onCreateLoader
import android.provider.MediaStore.Images; //导入依赖的package包/类
public Loader<Cursor> onCreateLoader(final int id, Bundle bundle) {
CursorLoader cursorLoader = null;
switch (id) {
case LOADER_USER_PHOTOS_EXTERNAL:
String selection = null;
String[] selectionArgs = null;
if (null != bundle
&& bundle.containsKey(LOADER_PHOTOS_BUCKETS_PARAM)) {
selection = Images.Media.BUCKET_ID + " = ?";
selectionArgs = new String[] { bundle
.getString(LOADER_PHOTOS_BUCKETS_PARAM) };
}
cursorLoader = new PhotupCursorLoader(getActivity(),
MediaStoreCursorHelper.MEDIA_STORE_CONTENT_URI,
MediaStoreCursorHelper.PHOTOS_PROJECTION, selection,
selectionArgs, MediaStoreCursorHelper.PHOTOS_ORDER_BY,
false);
break;
}
return cursorLoader;
}
示例12: cancelThreadDecoding
import android.provider.MediaStore.Images; //导入依赖的package包/类
public synchronized void cancelThreadDecoding(Thread t, ContentResolver cr) {
ThreadStatus status = getOrCreateThreadStatus(t);
status.mState = State.CANCEL;
if (status.mOptions != null) {
status.mOptions.requestCancelDecode();
}
// Wake up threads in waiting list
notifyAll();
// Since our cancel request can arrive MediaProvider earlier than getThumbnail request,
// we use mThumbRequesting flag to make sure our request does cancel the request.
try {
synchronized (status) {
while (status.mThumbRequesting) {
Images.Thumbnails.cancelThumbnailRequest(cr, -1, t.getId());
Video.Thumbnails.cancelThumbnailRequest(cr, -1, t.getId());
status.wait(200);
}
}
} catch (InterruptedException ex) {
// ignore it.
}
}
示例13: getThumbnail
import android.provider.MediaStore.Images; //导入依赖的package包/类
public Bitmap getThumbnail(ContentResolver cr, long origId, int kind, BitmapFactory.Options options, boolean isVideo) {
Thread t = Thread.currentThread();
ThreadStatus status = getOrCreateThreadStatus(t);
if (!canThreadDecoding(t)) {
Log.d(TAG, "Thread " + t + " is not allowed to decode.");
return null;
}
try {
synchronized (status) {
status.mThumbRequesting = true;
}
if (isVideo) {
return Video.Thumbnails.getThumbnail(cr, origId, t.getId(), kind, null);
} else {
return Images.Thumbnails.getThumbnail(cr, origId, t.getId(), kind, null);
}
} finally {
synchronized (status) {
status.mThumbRequesting = false;
status.notifyAll();
}
}
}
示例14: deleteFile
import android.provider.MediaStore.Images; //导入依赖的package包/类
public synchronized static boolean deleteFile(Context context, String path) {
File file = new File(path);
boolean issucc = false;
if (file.exists()) {
issucc = file.delete();
if (issucc) {
String where = MediaColumns.DATA + "=?";
String[] selectionArgs = new String[] { path };
int columnsNum = context.getContentResolver()
.delete(Images.Media.EXTERNAL_CONTENT_URI, where,
selectionArgs);
if (columnsNum > 0) {
return issucc;
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
}
示例15: onActivityResult
import android.provider.MediaStore.Images; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
if (resultCode == RESULT_CANCELED) {
// request was canceled, so do nothing
return;
}
switch (requestCode) {
case IMAGE_CHOOSER:
// get gp of chosen file
Uri selectedMedia = intent.getData();
String sourceMediaPath = MediaUtils.getPathFromUri(this, selectedMedia, Images.Media.DATA);
// setting image path
setSplashPath(sourceMediaPath);
break;
}
}