Search in sources :

Example 16 with CursorLoader

use of android.support.v4.content.CursorLoader in project chuck by jgilfelt.

the class TransactionActivity method onCreateLoader.

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    CursorLoader loader = new CursorLoader(this);
    loader.setUri(ContentUris.withAppendedId(ChuckContentProvider.TRANSACTION_URI, transactionId));
    return loader;
}
Also used : CursorLoader(android.support.v4.content.CursorLoader)

Example 17 with CursorLoader

use of android.support.v4.content.CursorLoader in project BBS-Android by bdpqchen.

the class PathUtil method getRealPathFromURI.

public static String getRealPathFromURI(Context context, Uri contentUri) {
    String[] proj = { MediaStore.Images.Media.DATA };
    CursorLoader loader = new CursorLoader(context, contentUri, proj, null, null, null);
    Cursor cursor = loader.loadInBackground();
    int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
    cursor.moveToFirst();
    String result = cursor.getString(column_index);
    cursor.close();
    // LogUtil.dd("realpath ", result);
    return result;
}
Also used : CursorLoader(android.support.v4.content.CursorLoader) Cursor(android.database.Cursor)

Example 18 with CursorLoader

use of android.support.v4.content.CursorLoader in project WordPress-Android by wordpress-mobile.

the class MediaBrowserActivity 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;
}
Also used : CursorLoader(android.support.v4.content.CursorLoader) Cursor(android.database.Cursor) SuppressLint(android.annotation.SuppressLint)

Example 19 with CursorLoader

use of android.support.v4.content.CursorLoader in project WordPress-Android by wordpress-mobile.

the class MeFragment method getRealPathFromContentURI.

private String getRealPathFromContentURI(Uri contentUri) {
    if (contentUri == null)
        return null;
    String[] proj = { MediaStore.Images.Media.DATA };
    CursorLoader loader = new CursorLoader(getActivity(), contentUri, proj, null, null, null);
    Cursor cursor = loader.loadInBackground();
    if (cursor == null)
        return null;
    int column_index = cursor.getColumnIndex(MediaStore.Images.Media.DATA);
    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;
}
Also used : CursorLoader(android.support.v4.content.CursorLoader) Cursor(android.database.Cursor)

Example 20 with CursorLoader

use of android.support.v4.content.CursorLoader in project robolectric by robolectric.

the class ShadowCursorLoaderTest method testSetters.

@Test
public void testSetters() {
    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);
    cursorLoader.setUri(uri);
    cursorLoader.setProjection(projection);
    cursorLoader.setSelection(selection);
    cursorLoader.setSelectionArgs(selectionArgs);
    cursorLoader.setSortOrder(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);
}
Also used : CursorLoader(android.support.v4.content.CursorLoader) Uri(android.net.Uri) Test(org.junit.Test)

Aggregations

CursorLoader (android.support.v4.content.CursorLoader)36 Uri (android.net.Uri)18 Cursor (android.database.Cursor)13 Test (org.junit.Test)8 SmallTest (android.test.suitebuilder.annotation.SmallTest)6 SpannableString (android.text.SpannableString)5 TagMetadataTest (com.google.samples.apps.iosched.model.TagMetadataTest)5 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 Context (android.content.Context)4 Matchers.anyString (org.mockito.Matchers.anyString)4 SettingsMockContext (com.google.samples.apps.iosched.testutils.SettingsMockContext)3 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)2 ArrayList (java.util.ArrayList)2 SuppressLint (android.annotation.SuppressLint)1 SharedPreferences (android.content.SharedPreferences)1 Bundle (android.os.Bundle)1 Loader (android.support.v4.content.Loader)1 SimpleCursorAdapter (android.support.v4.widget.SimpleCursorAdapter)1 CloudEntry (com.amaze.filemanager.database.models.CloudEntry)1 CloudPluginException (com.amaze.filemanager.exceptions.CloudPluginException)1