Java 类android.content.Loader 实例源码
项目:ActivityDiary
文件:HistoryActivity.java
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);
}
}
项目:BestBlog
文件:LoginActivity.java
@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");
}
项目:SimpleRssReader
文件:SavedEntriesFragment.java
@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;
}
}
项目:okwallet
文件:WalletAddressFragment.java
@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();
}
}
项目:iosched-reader
文件:MapFragment.java
@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();
}
}
项目:xyz-reader-2
文件:ArticleDetailFragment.java
@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();
}
项目:maklib
文件:LoginActivity.java
@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");
}
项目:SimpleRssReader
文件:MainActivity.java
@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;
}
}
项目:Shared-Route
文件:PayBillActivity.java
@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");
}
项目:aos-Video
文件:MainFragment.java
@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;
}
项目:changApp
文件:LoginActivity.java
@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");
}
项目:aos-Video
文件:MoviesByFragment.java
@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);
}
}
}
项目:Book_Listing
文件:BookListingActivity.java
@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);
}
项目:SimpleRssReader
文件:SavedEntriesFragment.java
@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);
}
项目:ActivityDiary
文件:HistoryActivity.java
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);
}
}
项目:programming
文件:Login.java
@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);
}
项目:q-mail
文件:MessageLoaderHelper.java
@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);
}
项目:q-mail
文件:MessageLoaderHelper.java
@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();
}
}
项目:q-mail
文件:MessageLoaderHelper.java
@Override
public Loader<MessageViewInfo> onCreateLoader(int id, Bundle args) {
if (id != DECODE_MESSAGE_LOADER_ID) {
throw new IllegalStateException("loader id must be message decoder id");
}
return new LocalMessageExtractorLoader(context, localMessage, messageCryptoAnnotations);
}
项目:aos-Video
文件:VideosByFragment.java
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
if (id == -1) {
// List of categories
return getSubsetLoader(getActivity());
} else {
// One of the row
return new MoviesSelectionLoader(getActivity(), args.getString("ids"), args.getString("sort"));
}
}
项目:q-mail
文件:AttachmentPresenter.java
private boolean hasLoadingAttachments() {
for (Attachment attachment : attachments.values()) {
Loader loader = loaderManager.getLoader(attachment.loaderId);
if (loader != null && loader.isStarted()) {
return true;
}
}
return false;
}
项目:iosched-reader
文件:VideoLibraryModelTest.java
@Test
public void createCursorLoader_UnknownLoaderId_CreatesNullCursorLoader() {
// When ran with an invalid query
Loader<Cursor> cursorLoader = mVideoLibraryModel
.createCursorLoader(InvalidEnum.INVALID.getId(), null, null);
// Then the returned cursor is null
assertThat(cursorLoader, nullValue());
}
项目:iosched-reader
文件:LoaderIdlingResource.java
/**
* Indicates the given {@code Loader} has finished loading. This is typically called from an
* {@link android.app.LoaderManager.LoaderCallbacks#onLoadFinished(android.content.Loader, Object)}
* and {@link android.app.LoaderManager.LoaderCallbacks#onLoaderReset(android.content.Loader)}.
*/
public void onLoaderFinished(Loader loader) {
mLoadersLoading.remove(loader.getId());
if (isIdleNow() && mResourceCallback != null) {
mResourceCallback.onTransitionToIdle();
}
}
项目:iosched-reader
文件:SessionFeedbackModel.java
@Override
public Loader<Cursor> createCursorLoader(int loaderId, Uri uri, Bundle args) {
CursorLoader loader = null;
if (loaderId == SessionFeedbackQueryEnum.SESSION.getId()) {
loader = getCursorLoaderInstance(mContext, uri,
SessionFeedbackQueryEnum.SESSION.getProjection(), null, null, null);
}
return loader;
}
项目:pets
文件:CatalogActivity.java
@Override
public void onLoaderReset(Loader<Cursor> loader) {
// This is called when the last Cursor provided to onLoadFinished()
// above is about to be closed. We need to make sure we are no
// longer using it.
mCursorAdapter.swapCursor(null);
}
项目:dapay
文件:Login_BT_Activity.java
@Override
public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
List<String> emails = new ArrayList<>();
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
emails.add(cursor.getString(ProfileQuery.ADDRESS));
cursor.moveToNext();
}
addEmailsToAutoComplete(emails);
}
项目:CodeWatch
文件:ProfileActivity.java
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
return new CursorLoader(this,
LeaderContract.LeaderEntry.buildProfileUri(userId),
null,
null,
null,
null);
}
项目:Shared-Route
文件:PayBillActivity.java
@Override
public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
// List<String> emails = new ArrayList<>();
// cursor.moveToFirst();
// while (!cursor.isAfterLast()) {
// emails.add(cursor.getString(ProfileQuery.ADDRESS));
// cursor.moveToNext();
// }
// addEmailsToAutoComplete(emails);
}
项目:iosched-reader
文件:SessionDetailModel.java
@Override
public Loader<Cursor> createCursorLoader(int loaderId, Uri uri, Bundle args) {
CursorLoader loader = null;
if (loaderId == SessionDetailQueryEnum.SESSIONS.getId()) {
mSessionUri = uri;
mSessionId = getSessionId(uri);
loader = getCursorLoaderInstance(mContext, uri,
SessionDetailQueryEnum.SESSIONS.getProjection(), null, null, null);
} else if (loaderId == SessionDetailQueryEnum.SPEAKERS.getId() && mSessionUri != null) {
Uri speakersUri = getSpeakersDirUri(mSessionId);
loader = getCursorLoaderInstance(mContext, speakersUri,
SessionDetailQueryEnum.SPEAKERS.getProjection(), null, null,
ScheduleContract.Speakers.DEFAULT_SORT);
} else if (loaderId == SessionDetailQueryEnum.FEEDBACK.getId()) {
Uri feedbackUri = getFeedbackUri(mSessionId);
loader = getCursorLoaderInstance(mContext, feedbackUri,
SessionDetailQueryEnum.FEEDBACK.getProjection(), null, null, null);
} else if (loaderId == SessionDetailQueryEnum.TAG_METADATA.getId()) {
loader = getTagMetadataLoader();
} else if (loaderId == SessionDetailQueryEnum.MY_VIEWED_VIDEOS.getId()) {
LOGD(TAG, "Starting My Viewed Videos query");
Uri myPlayedVideoUri = ScheduleContract.MyViewedVideos.buildMyViewedVideosUri(
AccountUtils.getActiveAccountName(mContext));
loader = getCursorLoaderInstance(mContext, myPlayedVideoUri,
SessionDetailQueryEnum.MY_VIEWED_VIDEOS.getProjection(), null, null, null);
}
return loader;
}
项目:NewsApp
文件:LoginActivity.java
@Override
public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
List<String> emails = new ArrayList<>();
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
emails.add(cursor.getString(ProfileQuery.ADDRESS));
cursor.moveToNext();
}
addEmailsToAutoComplete(emails);
}
项目:Shared-Route
文件:RegisterActivity.java
@Override
public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
// List<String> emails = new ArrayList<>();
// cursor.moveToFirst();
// while (!cursor.isAfterLast()) {
// emails.add(cursor.getString(ProfileQuery.ADDRESS));
// cursor.moveToNext();
// }
// addEmailsToAutoComplete(emails);
}
项目:atlas
文件:LoginActivity.java
@Override
public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
List<String> emails = new ArrayList<>();
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
emails.add(cursor.getString(ProfileQuery.ADDRESS));
cursor.moveToNext();
}
addEmailsToAutoComplete(emails);
}
项目:FlashCards
文件:LoginActivity.java
@Override
public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
List<String> emails = new ArrayList<>();
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
emails.add(cursor.getString(ProfileQuery.ADDRESS));
cursor.moveToNext();
}
addEmailsToAutoComplete(emails);
}
项目:iosched-reader
文件:ExploreSessionsFragment.java
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
switch (loader.getId()) {
case ExploreSessionsQuery.NORMAL_TOKEN: // fall through
case ExploreSessionsQuery.SEARCH_TOKEN:
reloadSessionData(cursor);
break;
case TAG_METADATA_TOKEN:
mTagMetadata = new TagMetadata(cursor);
break;
default:
cursor.close();
}
}
项目:androidtv-sample
文件:PlaybackOverlayFragment.java
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
if (cursor != null && cursor.moveToFirst()) {
switch (loader.getId()) {
case QUEUE_VIDEOS_LOADER: {
mQueue.clear();
while (!cursor.isAfterLast()) {
Video v = (Video) mVideoCursorMapper.convert(cursor);
// Set the queue index to the selected video.
if (v.id == mSelectedVideo.id) {
mQueueIndex = mQueue.size();
}
// Add the video to the queue.
MediaSessionCompat.QueueItem item = getQueueItem(v);
mQueue.add(item);
cursor.moveToNext();
}
mSession.setQueue(mQueue);
mSession.setQueueTitle(getString(R.string.queue_name));
break;
}
case RECOMMENDED_VIDEOS_LOADER: {
mVideoCursorAdapter.changeCursor(cursor);
break;
}
default: {
// Playing a specific video.
Video video = (Video) mVideoCursorMapper.convert(cursor);
playVideo(video, mAutoPlayExtras);
break;
}
}
}
}
项目:Android-DFU-App
文件:DfuActivity.java
@Override
public void onLoaderReset(final Loader<Cursor> loader) {
mFileNameView.setText(null);
mFileTypeView.setText(null);
mFileSizeView.setText(null);
mFilePath = null;
mFileStreamUri = null;
mStatusOk = false;
}
项目:okwallet
文件:SendingAddressesFragment.java
@Override
public Loader<Cursor> onCreateLoader(final int id, final Bundle args) {
final Uri uri = AddressBookProvider.contentUri(activity.getPackageName());
return new CursorLoader(activity, uri, null, AddressBookProvider.SELECTION_NOTIN,
new String[] { walletAddressesSelection != null ? walletAddressesSelection : "" },
AddressBookProvider.KEY_LABEL + " COLLATE LOCALIZED ASC");
}
项目:cordova-plugin-image-picker
文件:MultiImageChooserActivity.java
@Override
public void onLoaderReset(Loader<Cursor> loader) {
if (loader.getId() == CURSORLOADER_THUMBS) {
imagecursor = null;
} else if (loader.getId() == CURSORLOADER_REAL) {
actualimagecursor = null;
}
}
项目:aos-Video
文件:AllMoviesGridFragment.java
@Override
public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
if (cursorLoader.getId()==0) {
mMoviesAdapter.swapCursor(cursor);
setEmptyViewVisiblity(cursor.getCount()<1);
}
}
项目:Android-DFU-App
文件:DfuActivity.java
@Override
public Loader<Cursor> onCreateLoader(final int id, final Bundle args) {
final Uri uri = args.getParcelable(EXTRA_URI);
/*
* Some apps, f.e. Google Drive allow to select file that is not on the device. There is no "_data" column handled by that provider. Let's try to obtain
* all columns and than check which columns are present.
*/
// final String[] projection = new String[] { MediaStore.MediaColumns.DISPLAY_NAME, MediaStore.MediaColumns.SIZE, MediaStore.MediaColumns.DATA };
return new CursorLoader(this, uri, null /* all columns, instead of projection */, null, null, null);
}