Search in sources :

Example 11 with CursorLoader

use of android.support.v4.content.CursorLoader in project android_packages_apps_Gallery2 by LineageOS.

the class MediaPickerFragment method onCreateLoader.

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle bundle) {
    Uri uri = Uri.parse(bundle.getString(LOADER_EXTRA_URI));
    String[] projects = bundle.getStringArray(LOADER_EXTRA_PROJECT);
    String order = MediaColumns.DATE_ADDED + " DESC";
    return new CursorLoader(mContext, uri, projects, null, null, order);
}
Also used : CursorLoader(android.support.v4.content.CursorLoader) Uri(android.net.Uri)

Example 12 with CursorLoader

use of android.support.v4.content.CursorLoader in project Brion-Learns-OAuth by brione.

the class BloaUserTimelineFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    this.setEmptyText(this.getString(R.string.empty));
    // No cursor yet. Will be assigned when the CursorLoader query is complete
    SimpleCursorAdapter adapter = new SimpleCursorAdapter(this.getActivity(), android.R.layout.simple_list_item_2, null, App.USER_STATUS_PROJECTION, IDS, 0);
    setListAdapter(adapter);
    // Set up our cursor loader. It manages the cursors from now on
    getLoaderManager().initLoader(App.LIST_LOADER_ID, null, this);
}
Also used : SimpleCursorAdapter(android.support.v4.widget.SimpleCursorAdapter)

Example 13 with CursorLoader

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;
    LogUtils.i(TAG, "method -> getRealPathBelowVersion " + uri + "   path:" + uri.getPath() + "    getAuthority:" + uri.getAuthority());
    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();
    }
    if (filePath == null) {
        filePath = uri.getPath();
    }
    return filePath;
}
Also used : CursorLoader(android.support.v4.content.CursorLoader) SpannableString(android.text.SpannableString) Cursor(android.database.Cursor)

Example 14 with CursorLoader

use of android.support.v4.content.CursorLoader in project Sunshine-Version-2 by udacity.

the class ForecastFragment method onCreateLoader.

@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    // This is called when a new Loader needs to be created.  This
    // fragment only uses one loader, so we don't care about checking the id.
    // To only show current and future dates, filter the query to return weather only for
    // dates after or including today.
    // Sort order:  Ascending, by date.
    String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC";
    String locationSetting = Utility.getPreferredLocation(getActivity());
    Uri weatherForLocationUri = WeatherContract.WeatherEntry.buildWeatherLocationWithStartDate(locationSetting, System.currentTimeMillis());
    return new CursorLoader(getActivity(), weatherForLocationUri, FORECAST_COLUMNS, null, null, sortOrder);
}
Also used : CursorLoader(android.support.v4.content.CursorLoader) Uri(android.net.Uri)

Example 15 with CursorLoader

use of android.support.v4.content.CursorLoader in project android-ui-design-pattern by MathieuCalba.

the class FeedItemActivity method onCreateLoader.

@Override
public Loader<Cursor> onCreateLoader(int id, Bundle b) {
    final int realId = id - mFeedId * 100 - mCategoryId;
    if (realId == LOADER_ID_FEED_LIST) {
        if (b != null) {
            final int feedId = b.getInt(EXTRA_FEED_ID, -1);
            if (feedId != -1) {
                final int categoryId = b.getInt(EXTRA_CATEGORY_ID, -1);
                Uri uri = null;
                if (categoryId == -1) {
                    uri = YANAContract.ArticleTable.buildUriWithFeedId(feedId);
                } else {
                    uri = YANAContract.ArticleTable.buildUriWithFeedIdAndCategoryId(feedId, categoryId);
                }
                return new CursorLoader(this, uri, YANAContract.ArticleTable.PROJ_LIST.COLS, null, null, YANAContract.ArticleTable.DEFAULT_SORT);
            }
        }
    }
    return null;
}
Also used : CursorLoader(android.support.v4.content.CursorLoader) Uri(android.net.Uri)

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