@Override public void loadData(Priority priority, DataCallback<? super File> callback) { Cursor cursor = context .getContentResolver() .query( uri, PROJECTION, null /*selection*/, null /*selectionArgs*/, null /*sortOrder*/); String filePath = null; if (cursor != null) { try { if (cursor.moveToFirst()) { filePath = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA)); } } finally { cursor.close(); } } if (TextUtils.isEmpty(filePath)) { callback.onLoadFailed(new FileNotFoundException("Failed to find file path for: " + uri)); } else { callback.onDataReady(new File(filePath)); } }
@Override public final void loadData(Priority priority, DataCallback<? super T> callback) { try { data = loadResource(uri, contentResolver); } catch (FileNotFoundException e) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Failed to open Uri", e); } callback.onLoadFailed(e); return; } callback.onDataReady(data); }