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


Java CursorLoader類代碼示例

本文整理匯總了Java中android.support.v4.content.CursorLoader的典型用法代碼示例。如果您正苦於以下問題:Java CursorLoader類的具體用法?Java CursorLoader怎麽用?Java CursorLoader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CursorLoader類屬於android.support.v4.content包,在下文中一共展示了CursorLoader類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreateLoader

import android.support.v4.content.CursorLoader; //導入依賴的package包/類
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {

    String[]  projectionFields = new String[]{
        ContactsContract.Contacts._ID,
            ContactsContract.Contacts.DISPLAY_NAME,
            ContactsContract.Contacts.PHOTO_URI
    };


    CursorLoader cursorLoader = new CursorLoader(MainActivity.this,
            ContactsContract.Contacts.CONTENT_URI,
            projectionFields,
            null,
            null,
            null);

    return cursorLoader;
}
 
開發者ID:micromasterandroid,項目名稱:androidbeginners-Lesson3,代碼行數:20,代碼來源:MainActivity.java

示例2: onCreateLoader

import android.support.v4.content.CursorLoader; //導入依賴的package包/類
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    Uri uri;
    switch (id) {
        case LOADER_CAN_UPDATE:
            uri = AppProvider.getCanUpdateUri();
            break;

        case LOADER_KNOWN_VULN:
            uri = AppProvider.getInstalledWithKnownVulnsUri();
            break;

        default:
            throw new IllegalStateException("Unknown loader requested: " + id);
    }

    return new CursorLoader(
            activity, uri, Schema.AppMetadataTable.Cols.ALL, null, null, Schema.AppMetadataTable.Cols.NAME);
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:20,代碼來源:UpdatesAdapter.java

示例3: onCreateLoader

import android.support.v4.content.CursorLoader; //導入依賴的package包/類
@Override
public CursorLoader onCreateLoader(int id, Bundle args) {
    Uri uri;
    if (TextUtils.isEmpty(currentFilterString)) {
        uri = InstalledAppProvider.getContentUri();
    } else {
        uri = InstalledAppProvider.getSearchUri(currentFilterString);
    }
    return new CursorLoader(
            getActivity(),
            uri,
            InstalledAppTable.Cols.ALL,
            null,
            null,
            InstalledAppTable.Cols.APPLICATION_LABEL);
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:17,代碼來源:SelectAppsView.java

示例4: onCreateLoader

import android.support.v4.content.CursorLoader; //導入依賴的package包/類
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    //checking on rotate
    if (mAttachedFragment != null && mAttachedFragment.getActivity() != null) {


        if (favflag == 0) {
            return new CursorLoader(mAttachedFragment.getActivity(), NewsProvider.MyNews.CONTENT_URI,
                    null,
                    null,
                    null,
                    null);
        } else {
            if (favflag == 1) {
                return new CursorLoader(mAttachedFragment.getActivity(), NewsProvider.NewsFavourite.CONTENT_URI_FAVOURITE,
                        null,
                        null,
                        null,
                        null);

            }
        }
    }
    return null;
}
 
開發者ID:vikasdesale,項目名稱:News24x7-news-from-every-part-of-the-world,代碼行數:26,代碼來源:NewsLoader.java

示例5: onCreateLoader

import android.support.v4.content.CursorLoader; //導入依賴的package包/類
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    String selection = "";
    if (mOnlyWithPhoneNumbers) {
        selection = ContactsContract.Contacts.HAS_PHONE_NUMBER;
    }
    switch (id) {
        case CONTACTS_LOADER_ID:
            return new CursorLoader(this, CONTACTS_URI, CONTACTS_PROJECTION,
                    selection, null, CONTACTS_SORT);
        case CONTACT_DETAILS_LOADER_ID:
            return new CursorLoader(this, CONTACT_DETAILS_URI, CONTACT_DETAILS_PROJECTION,
                    selection, null, null);
        case GROUPS_LOADER_ID:
            return new CursorLoader(this, GROUPS_URI, GROUPS_PROJECTION, GROUPS_SELECTION, null, GROUPS_SORT);
    }
    return null;
}
 
開發者ID:adithya321,項目名稱:SOS-The-Healthcare-Companion,代碼行數:19,代碼來源:ContactPickerActivity.java

示例6: onCreateLoader

import android.support.v4.content.CursorLoader; //導入依賴的package包/類
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    CursorLoader loader = new CursorLoader(getContext());
    loader.setUri(ChuckContentProvider.TRANSACTION_URI);
    if (!TextUtils.isEmpty(currentFilter)) {
        if (TextUtils.isDigitsOnly(currentFilter)) {
            loader.setSelection("responseCode LIKE ?");
            loader.setSelectionArgs(new String[]{ currentFilter + "%" });
        } else {
            loader.setSelection("path LIKE ?");
            loader.setSelectionArgs(new String[]{ "%" + currentFilter + "%" });
        }
    }
    loader.setProjection(HttpTransaction.PARTIAL_PROJECTION);
    loader.setSortOrder("requestDate DESC");
    return loader;
}
 
開發者ID:jgilfelt,項目名稱:chuck,代碼行數:18,代碼來源:TransactionListFragment.java

示例7: getRealPathBelowVersion

import android.support.v4.content.CursorLoader; //導入依賴的package包/類
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;
}
 
開發者ID:Justson,項目名稱:AgentWeb,代碼行數:21,代碼來源:AgentWebUtils.java

示例8: onCreateLoader

import android.support.v4.content.CursorLoader; //導入依賴的package包/類
/**
 * Creates and returns a CursorLoader that loads the data for our URI and stores it in a Cursor.
 *
 * @param loaderId The loader ID for which we need to create a loader
 * @param loaderArgs Any arguments supplied by the caller
 *
 * @return A new Loader instance that is ready to start loading.
 */
@Override
public Loader<Cursor> onCreateLoader(int loaderId, Bundle loaderArgs) {

    switch (loaderId) {

        case ID_DETAIL_LOADER:

            return new CursorLoader(this,
                    mUri,
                    WEATHER_DETAIL_PROJECTION,
                    null,
                    null,
                    null);

        default:
            throw new RuntimeException("Loader Not Implemented: " + loaderId);
    }
}
 
開發者ID:gmontoya2483,項目名稱:GoUbiquitous,代碼行數:27,代碼來源:DetailActivity.java

示例9: getRealPathFromURI_API11to18

import android.support.v4.content.CursorLoader; //導入依賴的package包/類
@SuppressLint("NewApi")
public static String getRealPathFromURI_API11to18(Context context, Uri contentUri) {
    String[] proj = { MediaStore.Images.Media.DATA };
    String result = null;
    try {
        CursorLoader cursorLoader = new CursorLoader(context, contentUri, proj, null, null, null);
        Cursor cursor = cursorLoader.loadInBackground();

        if (cursor != null) {
            int column_index =
                    cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
            cursor.moveToFirst();
            result = cursor.getString(column_index);
        }
    }
    catch (Exception e){
        e.printStackTrace();
    }
    return result;
}
 
開發者ID:afiqiqmal,項目名稱:MVP-Android,代碼行數:21,代碼來源:RealPathUtils.java

示例10: onCreateLoader

import android.support.v4.content.CursorLoader; //導入依賴的package包/類
@Override
public Loader<Cursor> onCreateLoader(int loaderId, Bundle bundle) {

    switch (loaderId) {

        case ID_FORECAST_LOADER:
            Uri forecastQueryUri = WeatherContract.WeatherEntry.CONTENT_URI;
            String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC";
            String selection = WeatherContract.WeatherEntry.getSqlSelectForTodayOnwards();

            return new CursorLoader(this,
                    forecastQueryUri,
                    MAIN_FORECAST_PROJECTION,
                    selection,
                    null,
                    sortOrder);

        default:
            throw new RuntimeException("Loader Not Implemented: " + loaderId);
    }
}
 
開發者ID:changja88,項目名稱:Android_Sunshine_Watch,代碼行數:22,代碼來源:MainActivity.java

示例11: newInstance

import android.support.v4.content.CursorLoader; //導入依賴的package包/類
public static CursorLoader newInstance(Context context, Album album, boolean capture) {
    if (album.isAll()) {
        return new AlbumMediaLoader(
                context,
                QUERY_URI,
                PROJECTION,
                SELECTION_ALL,
                SELECTION_ALL_ARGS,
                ORDER_BY,
                capture);
    } else {
        return new AlbumMediaLoader(
                context,
                QUERY_URI,
                PROJECTION,
                SELECTION_ALBUM,
                getSelectionAlbumArgs(album.getId()),
                ORDER_BY,
                false);
    }
}
 
開發者ID:GitPhoenix,項目名稱:VanGogh,代碼行數:22,代碼來源:AlbumMediaLoader.java

示例12: onCreateLoader

import android.support.v4.content.CursorLoader; //導入依賴的package包/類
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    String[] projection = {
            PlantEntry._ID,
            PlantEntry.COLUMN_NAME,
            PlantEntry.COLUMN_PRICE,
            PlantEntry.COLUMN_CART_QUANTITY
    };
    String selection = PlantEntry.COLUMN_CART_QUANTITY + " > 0";
    return new CursorLoader(this,
            PlantEntry.CONTENT_URI,
            projection,
            selection,
            null,
            null);
}
 
開發者ID:laramartin,項目名稱:android_firebase_green_thumb,代碼行數:17,代碼來源:ShoppingCartActivity.java

示例13: onCreateLoader

import android.support.v4.content.CursorLoader; //導入依賴的package包/類
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    String[] projection = {
            PlantEntry._ID,
            PlantEntry.COLUMN_NAME,
            PlantEntry.COLUMN_DESCRIPTION,
            PlantEntry.COLUMN_PRICE
    };
    String selection = PlantEntry._ID + " = " + mItemId;
    return new CursorLoader(this,
            PlantEntry.CONTENT_URI,
            projection,
            selection,
            null,
            null);
}
 
開發者ID:laramartin,項目名稱:android_firebase_green_thumb,代碼行數:17,代碼來源:PlantDetailActivity.java

示例14: onCreateLoader

import android.support.v4.content.CursorLoader; //導入依賴的package包/類
@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);
}
 
開發者ID:changja88,項目名稱:Udacity_Sunshine,代碼行數:23,代碼來源:ForecastFragment.java

示例15: onCreateLoader

import android.support.v4.content.CursorLoader; //導入依賴的package包/類
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    if (id == CHANNELS_LOADER) {
        return new CursorLoader(
                getActivity(),
                ChannelEntry.CONTENT_URI,
                CHANNEL_COLUMNS,
                TextUtils.isEmpty(category) ? null
                        : ChannelEntry.TABLE_NAME + "."
                        + ChannelEntry.COLUMN_CHANNEL_CATEGORY_ID + " = ?",
                TextUtils.isEmpty(category) ? null :
                        new String[]{String.valueOf(category)},
                Utility.getPrefSortChannelOrder(sortBy));
    }
    return null;
}
 
開發者ID:graviton57,項目名稱:TVGuide,代碼行數:17,代碼來源:ChannelFragment.java


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