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


Java Loader類代碼示例

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


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

示例1: onCreateLoader

import android.content.Loader; //導入依賴的package包/類
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    // Now create and return a CursorLoader that will take care of
    // creating a Cursor for the data being displayed.
    if(id == LOADER_ID_HISTORY) {
        return new CursorLoader(this, ActivityDiaryContract.Diary.CONTENT_URI,
                PROJECTION, SELECTION, null, null);
    }else{

        return new CursorLoader(HistoryActivity.this,
                ActivityDiaryContract.DiaryImage.CONTENT_URI,
                new String[] {ActivityDiaryContract.DiaryImage._ID,
                        ActivityDiaryContract.DiaryImage.URI},
                ActivityDiaryContract.DiaryImage.DIARY_ID + "=? AND "
                        + ActivityDiaryContract.DiaryImage._DELETED + "=0",
                new String[] {Long.toString(args.getLong("DiaryID"))},
                null);
    }
}
 
開發者ID:ramack,項目名稱:ActivityDiary,代碼行數:19,代碼來源:HistoryActivity.java

示例2: onCreateLoader

import android.content.Loader; //導入依賴的package包/類
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return new CursorLoader(this,
            // Retrieve data rows for the device user's 'profile' contact.
            Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,

            // Select only email addresses.
            ContactsContract.Contacts.Data.MIMETYPE +
                    " = ?", new String[]{ContactsContract.CommonDataKinds.Email
            .CONTENT_ITEM_TYPE},

            // Show primary email addresses first. Note that there won't be
            // a primary email address if the user hasn't specified one.
            ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
}
 
開發者ID:BobbyZhang93,項目名稱:BestBlog,代碼行數:17,代碼來源:LoginActivity.java

示例3: onCreateLoader

import android.content.Loader; //導入依賴的package包/類
@Override
public Loader onCreateLoader(final int id, final Bundle args) {
    switch (id) {
        case SavedEntriesQueryLoader.ID:
            return new SavedEntriesQueryLoader(getActivity(), getSortOrder());
        case SavedEntriesDeleteLoader.ID:
            return new SavedEntriesDeleteLoader(getActivity(),
                    args.getIntegerArrayList(KEY_POSITIONS));
        default:
            return null;
    }
}
 
開發者ID:Applications-Development,項目名稱:SimpleRssReader,代碼行數:13,代碼來源:SavedEntriesFragment.java

示例4: onLoadFinished

import android.content.Loader; //導入依賴的package包/類
@Override
public void onLoadFinished(final Loader<Address> loader, final Address currentAddress) {
    if (!currentAddress.equals(currentAddressQrAddress)) {
        currentAddressQrAddress = new AddressAndLabel(currentAddress, config.getOwnName());

        final String addressStr = BitcoinURI.convertToBitcoinURI(currentAddressQrAddress.address, null,
                currentAddressQrAddress.label, null);

        currentAddressQrBitmap = new BitmapDrawable(getResources(), Qr.bitmap(addressStr));
        currentAddressQrBitmap.setFilterBitmap(false);

        currentAddressUriRef.set(addressStr);

        updateView();
    }
}
 
開發者ID:guodroid,項目名稱:okwallet,代碼行數:17,代碼來源:WalletAddressFragment.java

示例5: onChange

import android.content.Loader; //導入依賴的package包/類
@Override
public void onChange(boolean selfChange) {
    if (!isAdded()) {
        return;
    }

    //clear map reload all data
    clearMap();
    setupMap(false);

    // reload data from loaders
    LoaderManager lm = getActivity().getLoaderManager();

    Loader<Cursor> loader =
            lm.getLoader(TOKEN_LOADER_MARKERS);
    if (loader != null) {
        loader.forceLoad();
    }

    loader = lm.getLoader(TOKEN_LOADER_TILES);
    if (loader != null) {
        loader.forceLoad();
    }
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:25,代碼來源:MapFragment.java

示例6: onLoadFinished

import android.content.Loader; //導入依賴的package包/類
@Override
public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
    if (!isAdded()) {
        if (cursor != null) {
            cursor.close();
        }
        return;
    }

    mCursor = cursor;
    if (mCursor != null && !mCursor.moveToFirst()) {
        Log.e(TAG, "Error reading item detail cursor");
        mCursor.close();
        mCursor = null;
    }

    bindViews();
}
 
開發者ID:rashikaranpuria,項目名稱:xyz-reader-2,代碼行數:19,代碼來源:ArticleDetailFragment.java

示例7: onCreateLoader

import android.content.Loader; //導入依賴的package包/類
@Override
public Loader onCreateLoader(final int id, final Bundle args) {
    switch (id) {
        case IsFeedUpdateAvailableLoader.ID:
            return new IsFeedUpdateAvailableLoader(this);
        case OPMLImportLoader.ID:
            return new OPMLImportLoader(this,
                    Uri.parse(args.getString(KEY_OPML_IMPORT)));
        case SavedEntriesSaveLoader.ID:
            return new SavedEntriesSaveLoader(this,
                    args.getStringArrayList(KEY_ENTRY_URLS),
                    args.getStringArrayList(KEY_ENTRY_TITLES));
        default:
            return null;
    }
}
 
開發者ID:Applications-Development,項目名稱:SimpleRssReader,代碼行數:17,代碼來源:MainActivity.java

示例8: onCreateLoader

import android.content.Loader; //導入依賴的package包/類
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    if (id == LOADER_ID_LAST_ADDED) {
        return new LastAddedLoader(getActivity());
    }
    else if (id == LOADER_ID_LAST_PLAYED) {
        return new LastPlayedLoader(getActivity());
    }
    else if (id == LOADER_ID_ALL_TV_SHOWS) {
        if (args == null) {
            return new AllTvshowsLoader(getActivity());
        } else {
            return new AllTvshowsLoader(getActivity(), args.getString("sort"));
        }
    }
    else if (id == LOADER_ID_NON_SCRAPED_VIDEOS_COUNT) {
        return new NonScrapedVideosCountLoader(getActivity());
    }
    else return null;
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:21,代碼來源:MainFragment.java

示例9: onLoadFinished

import android.content.Loader; //導入依賴的package包/類
@Override
public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor c) {
    // List of categories
    if (cursorLoader.getId() == -1) {

        // Empty view visibility
        mEmptyView.setVisibility(c.getCount() > 0 ? View.GONE : View.VISIBLE);

        if (mCurrentCategoriesCursor != null) {
            if (!isCategoriesListModified(mCurrentCategoriesCursor, c)) {
                // no actual modification, no need to rebuild all the rows
                mCurrentCategoriesCursor = c; // keep the reference to the new cursor because the old one won't be valid anymore
                return;
            }
        }
        mCurrentCategoriesCursor = c;
        loadCategoriesRows(c);
    }
    // One of the row
    else {
        CursorObjectAdapter adapter = mAdaptersMap.get(cursorLoader.getId());
        if (adapter != null) {
            adapter.changeCursor(c);
        }
    }
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:27,代碼來源:MoviesByFragment.java

示例10: onCreateLoader

import android.content.Loader; //導入依賴的package包/類
@Override
public Loader<List<Book>> onCreateLoader(int i, Bundle bundle) {
    Log.v(LOG_TAG, "TEST: New Loader initialised for the url provided");

    //setting a progress bar whiloe the loader load data
    mProgressBarView.setVisibility(View.VISIBLE);
    bookListView.setVisibility(View.INVISIBLE);
    mEmptyStateTextView.setVisibility(View.GONE);


    String requestUrl = "";
    if (mQuery != null && mQuery != "") {
        requestUrl = GOOGLE_BOOKS_REQUEST_URL + mQuery;
    } else {
        String defaultQuery = "android";
        requestUrl = GOOGLE_BOOKS_REQUEST_URL + defaultQuery;
    }

    // Create a new loader for the given URL
    return new BookListingLoader(this, requestUrl);
}
 
開發者ID:Cherudek,項目名稱:Book_Listing,代碼行數:22,代碼來源:BookListingActivity.java

示例11: onLoadFinished

import android.content.Loader; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public void onLoadFinished(final Loader loader, final Object data) {
    final int id = loader.getId();

    switch (id) {
        case SavedEntriesQueryLoader.ID:
            onDbQueryResult();
            break;
        case SavedEntriesDeleteLoader.ID:
            onSavedEntriesDeleted((List<Integer>) data);
            break;
    }

    getLoaderManager().destroyLoader(id);
}
 
開發者ID:Applications-Development,項目名稱:SimpleRssReader,代碼行數:17,代碼來源:SavedEntriesFragment.java

示例12: onLoadFinished

import android.content.Loader; //導入依賴的package包/類
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    // Swap the new cursor in.  (The framework will take care of closing the
    // old cursor once we return.)
    int i = loader.getId();
    if(i == LOADER_ID_HISTORY) {
        historyAdapter.swapCursor(data);
    }else{
        detailAdapters[i].swapCursor(data);
    }

}
 
開發者ID:ramack,項目名稱:ActivityDiary,代碼行數:12,代碼來源:HistoryActivity.java

示例13: onLoadFinished

import android.content.Loader; //導入依賴的package包/類
@Override
public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
    List<String> user = new ArrayList<>();
    cursor.moveToFirst();
    while (!cursor.isAfterLast()) {
        user.add(cursor.getString(ProfileQuery.ADDRESS));
        cursor.moveToNext();
    }

    addEmailsToAutoComplete(user);
}
 
開發者ID:hacktoberfest17,項目名稱:programming,代碼行數:12,代碼來源:Login.java

示例14: onCreateLoader

import android.content.Loader; //導入依賴的package包/類
@Override
public Loader<LocalMessage> onCreateLoader(int id, Bundle args) {
    if (id != LOCAL_MESSAGE_LOADER_ID) {
        throw new IllegalStateException("loader id must be message loader id");
    }

    return new LocalMessageLoader(context, MessagingController.getInstance(context), account, messageReference);
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:9,代碼來源:MessageLoaderHelper.java

示例15: onLoadFinished

import android.content.Loader; //導入依賴的package包/類
@Override
public void onLoadFinished(Loader<LocalMessage> loader, LocalMessage message) {
    if (loader.getId() != LOCAL_MESSAGE_LOADER_ID) {
        throw new IllegalStateException("loader id must be message loader id");
    }

    localMessage = message;
    if (message == null) {
        onLoadMessageFromDatabaseFailed();
    } else {
        onLoadMessageFromDatabaseFinished();
    }
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:14,代碼來源:MessageLoaderHelper.java


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