本文整理汇总了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();
}
}