本文整理匯總了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);
}
}
示例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");
}
示例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;
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
示例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;
}
}
示例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;
}
示例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);
}
}
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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();
}
}