use of android.support.v4.content.CursorLoader in project WordPress-Android by wordpress-mobile.
the class EditPostActivity method getRealPathFromContentURI.
private String getRealPathFromContentURI(Uri contentUri) {
if (contentUri == null)
return null;
String[] proj = { android.provider.MediaStore.Images.Media.DATA };
CursorLoader loader = new CursorLoader(this, contentUri, proj, null, null, null);
Cursor cursor = loader.loadInBackground();
if (cursor == null)
return null;
int column_index = cursor.getColumnIndex(proj[0]);
if (column_index == -1) {
cursor.close();
return null;
}
String path;
if (cursor.moveToFirst()) {
path = cursor.getString(column_index);
} else {
path = null;
}
cursor.close();
return path;
}
use of android.support.v4.content.CursorLoader in project robolectric by robolectric.
the class ShadowCursorLoaderTest method testGetters.
@Test
public void testGetters() {
Uri uri = Uri.parse("http://robolectric.org");
String[] projection = new String[] { "_id", "TestColumn" };
String selection = "_id = ?";
String[] selectionArgs = new String[] { "5" };
String sortOrder = "_id";
CursorLoader cursorLoader = new CursorLoader(RuntimeEnvironment.application, uri, projection, selection, selectionArgs, sortOrder);
assertThat(cursorLoader.getUri()).isEqualTo(uri);
assertThat(cursorLoader.getProjection()).isEqualTo(projection);
assertThat(cursorLoader.getSelection()).isEqualTo(selection);
assertThat(cursorLoader.getSelectionArgs()).isEqualTo(selectionArgs);
assertThat(cursorLoader.getSortOrder()).isEqualTo(sortOrder);
}
use of android.support.v4.content.CursorLoader in project AgentWeb by Justson.
the class AgentWebUtils method getRealPathBelowVersion.
private static String getRealPathBelowVersion(Context context, Uri uri) {
String filePath = null;
String[] projection = { MediaStore.Images.Media.DATA };
CursorLoader loader = new CursorLoader(context, uri, projection, null, null, null);
Cursor cursor = loader.loadInBackground();
if (cursor != null) {
cursor.moveToFirst();
filePath = cursor.getString(cursor.getColumnIndex(projection[0]));
cursor.close();
}
return filePath;
}
use of android.support.v4.content.CursorLoader in project AmazeFileManager by TeamAmaze.
the class MainActivity method onCreateLoader.
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
if (cloudSyncTask != null && cloudSyncTask.getStatus() == AsyncTask.Status.RUNNING) {
cloudSyncTask.cancel(true);
}
Uri uri = Uri.withAppendedPath(Uri.parse("content://" + CloudContract.PROVIDER_AUTHORITY), "/keys.db/secret_keys");
String[] projection = new String[] { CloudContract.COLUMN_ID, CloudContract.COLUMN_CLIENT_ID, CloudContract.COLUMN_CLIENT_SECRET_KEY };
switch(id) {
case REQUEST_CODE_CLOUD_LIST_KEY:
Uri uriAppendedPath = uri;
switch(OpenMode.getOpenMode(args.getInt(ARGS_KEY_LOADER, 2))) {
case GDRIVE:
uriAppendedPath = ContentUris.withAppendedId(uri, 2);
break;
case DROPBOX:
uriAppendedPath = ContentUris.withAppendedId(uri, 3);
break;
case BOX:
uriAppendedPath = ContentUris.withAppendedId(uri, 4);
break;
case ONEDRIVE:
uriAppendedPath = ContentUris.withAppendedId(uri, 5);
break;
}
return new CursorLoader(this, uriAppendedPath, projection, null, null, null);
case REQUEST_CODE_CLOUD_LIST_KEYS:
try {
List<CloudEntry> cloudEntries = cloudHandler.getAllEntries();
// we want keys for services saved in database, and the cloudrail app key which
// is at index 1
String[] ids = new String[cloudEntries.size() + 1];
ids[0] = 1 + "";
for (int i = 1; i <= cloudEntries.size(); i++) {
// we need to get only those cloud details which user wants
switch(cloudEntries.get(i - 1).getServiceType()) {
case GDRIVE:
ids[i] = 2 + "";
break;
case DROPBOX:
ids[i] = 3 + "";
break;
case BOX:
ids[i] = 4 + "";
break;
case ONEDRIVE:
ids[i] = 5 + "";
break;
}
}
return new CursorLoader(this, uri, projection, CloudContract.COLUMN_ID, ids, null);
} catch (CloudPluginException e) {
e.printStackTrace();
Toast.makeText(this, getResources().getString(R.string.cloud_error_plugin), Toast.LENGTH_LONG).show();
}
default:
return null;
}
}
use of android.support.v4.content.CursorLoader in project fdroidclient by f-droid.
the class ManageReposActivity method onCreateLoader.
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
Uri uri = RepoProvider.allExceptSwapUri();
final String[] projection = { RepoTable.Cols._ID, RepoTable.Cols.NAME, RepoTable.Cols.SIGNING_CERT, RepoTable.Cols.FINGERPRINT, RepoTable.Cols.IN_USE };
return new CursorLoader(this, uri, projection, null, null, null);
}
Aggregations