當前位置: 首頁>>代碼示例>>Java>>正文


Java Images類代碼示例

本文整理匯總了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;
}
 
開發者ID:Bilibili,項目名稱:boxing,代碼行數:18,代碼來源:ImageTask.java

示例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;
}
 
開發者ID:mayurkaul,項目名稱:medialibrary,代碼行數:22,代碼來源:BucketHelper.java

示例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;
}
 
開發者ID:gigabytedevelopers,項目名稱:FireFiles,代碼行數:20,代碼來源:StorageProvider.java

示例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();
        }
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:ImageTask.java

示例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;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:26,代碼來源:ImageTask.java

示例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;
}
 
開發者ID:Bilibili,項目名稱:boxing,代碼行數:26,代碼來源:ImageTask.java

示例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);
    }
}
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:18,代碼來源:StorageProvider.java

示例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();
    }
}
 
開發者ID:mayurkaul,項目名稱:medialibrary,代碼行數:20,代碼來源:LocalImage.java

示例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)});
}
 
開發者ID:mayurkaul,項目名稱:medialibrary,代碼行數:22,代碼來源:LocalImage.java

示例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;
}
 
開發者ID:mangestudio,項目名稱:GCSApp,代碼行數:23,代碼來源:MyBitmapUtil.java

示例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;
	}
 
開發者ID:xulailing,項目名稱:android-open-project-demo-master,代碼行數:27,代碼來源:UserPhotosFragment.java

示例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.
    }
}
 
開發者ID:goodev,項目名稱:droidddle,代碼行數:25,代碼來源:BitmapManager.java

示例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();
        }
    }
}
 
開發者ID:goodev,項目名稱:droidddle,代碼行數:26,代碼來源:BitmapManager.java

示例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;
	}

}
 
開發者ID:hubert1002,項目名稱:WiCamera3D,代碼行數:26,代碼來源:OperationFile.java

示例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;
  }
}
 
開發者ID:Last-Mile-Health,項目名稱:ODK-Liberia,代碼行數:21,代碼來源:PreferencesActivity.java


注:本文中的android.provider.MediaStore.Images類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。