androidx.loader.content.Loader Java Examples
The following examples show how to use
androidx.loader.content.Loader.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TVShowProgressFragment.java From Kore with Apache License 2.0 | 6 votes |
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { Uri uri; int hostId = HostManager.getInstance(getActivity()).getHostInfo().getId(); switch (id) { case LOADER_NEXT_EPISODES: // Load seasons uri = MediaContract.Episodes.buildTVShowEpisodesListUri(hostId, itemId, NEXT_EPISODES_COUNT); String selection = MediaContract.EpisodesColumns.PLAYCOUNT + "=0"; return new CursorLoader(getActivity(), uri, NextEpisodesListQuery.PROJECTION, selection, null, NextEpisodesListQuery.SORT); case LOADER_SEASONS: // Load seasons uri = MediaContract.Seasons.buildTVShowSeasonsListUri(hostId, itemId); return new CursorLoader(getActivity(), uri, SeasonsListQuery.PROJECTION, null, null, SeasonsListQuery.SORT); default: return null; } }
Example #2
Source File: BlankFragment.java From AndroidAnimationExercise with Apache License 2.0 | 6 votes |
@NonNull @Override public Loader onCreateLoader(int id, @Nullable Bundle args) { Uri baseUri; if (mCurFilter != null) { baseUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_FILTER_URI, Uri.encode(mCurFilter)); } else { baseUri = ContactsContract.Contacts.CONTENT_URI; } // Now create and return a CursorLoader that will take care of // creating a Cursor for the data being displayed. String select = "((" + ContactsContract.Contacts.DISPLAY_NAME + " NOTNULL) AND (" + ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1) AND (" + ContactsContract.Contacts.DISPLAY_NAME + " != '' ))"; return new CursorLoader(getActivity(), baseUri, CONTACTS_SUMMARY_PROJECTION, select, null, ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"); }
Example #3
Source File: ConversationListFragment.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
@Override public void onLoadFinished(@NonNull Loader<Cursor> arg0, Cursor cursor) { if (cursor == null || cursor.getCount() <= 0) { list.setVisibility(View.INVISIBLE); emptyState.setVisibility(View.VISIBLE); emptyImage.setImageResource(EMPTY_IMAGES[(int) (Math.random() * EMPTY_IMAGES.length)]); fab.startPulse(3 * 1000); cameraFab.startPulse(3 * 1000); } else { list.setVisibility(View.VISIBLE); emptyState.setVisibility(View.GONE); fab.stopPulse(); cameraFab.stopPulse(); } defaultAdapter.changeCursor(cursor); }
Example #4
Source File: RecipientPreferenceActivity.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
@Override public void onLoadFinished(@NonNull Loader<Cursor> loader, Cursor data) { if (data != null && data.getCount() > 0) { this.threadPhotoRailLabel.setVisibility(View.VISIBLE); this.threadPhotoRailView.setVisibility(View.VISIBLE); } else { this.threadPhotoRailLabel.setVisibility(View.GONE); this.threadPhotoRailView.setVisibility(View.GONE); } this.threadPhotoRailView.setCursor(glideRequests, data); Bundle bundle = new Bundle(); bundle.putParcelable(RECIPIENT_ID, recipientId); initFragment(R.id.preference_fragment, new RecipientPreferenceFragment(), null, bundle); }
Example #5
Source File: SearchFragment.java From tv-samples with Apache License 2.0 | 6 votes |
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { int titleRes; if (cursor != null && cursor.moveToFirst()) { mResultsFound = true; titleRes = R.string.search_results; } else { mResultsFound = false; titleRes = R.string.no_search_results; } mVideoCursorAdapter.changeCursor(cursor); HeaderItem header = new HeaderItem(getString(titleRes, mQuery)); mRowsAdapter.clear(); ListRow row = new ListRow(header, mVideoCursorAdapter); mRowsAdapter.add(row); }
Example #6
Source File: ArtistInfoFragment.java From Kore with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override public Loader<Cursor> onCreateLoader(int i, Bundle bundle) { Uri uri; switch (i) { case LOADER_ARTIST: uri = MediaContract.Artists.buildArtistUri(getHostInfo().getId(), getDataHolder().getId()); return new CursorLoader(getActivity(), uri, DetailsQuery.PROJECTION, null, null, null); case LOADER_SONGS: uri = MediaContract.Songs.buildArtistSongsListUri(getHostInfo().getId(), getDataHolder().getId()); return new CursorLoader(getActivity(), uri, SongsListQuery.PROJECTION, null, null, SongsListQuery.SORT); default: return null; } }
Example #7
Source File: FashionFragment.java From android-news-app with MIT License | 5 votes |
@NonNull @Override public Loader<List<News>> onCreateLoader(int i, Bundle bundle) { String fashionUrl = NewsPreferences.getPreferredUrl(getContext(), getString(R.string.fashion)); Log.e(LOG_TAG, fashionUrl); // Create a new loader for the given URL return new NewsLoader(getActivity(), fashionUrl); }
Example #8
Source File: MusicVideoInfoFragment.java From Kore with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override public Loader<Cursor> onCreateLoader(int i, Bundle bundle) { Uri uri; switch (i) { case LOADER_MUSIC_VIDEO: uri = MediaContract.MusicVideos.buildMusicVideoUri(getHostInfo().getId(), getDataHolder().getId()); return new CursorLoader(getActivity(), uri, MusicVideoDetailsQuery.PROJECTION, null, null, null); default: return null; } }
Example #9
Source File: NfcProvisioningFragment.java From enterprise-samples with Apache License 2.0 | 5 votes |
@Override public Loader<Map<String, String>> onCreateLoader(int id, Bundle args) { if (id == LOADER_PROVISIONING_VALUES) { return new ProvisioningValuesLoader(getActivity()); } return null; }
Example #10
Source File: MessagesAdapter.java From tindroid with Apache License 2.0 | 5 votes |
@NonNull @Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { if (id == MESSAGES_QUERY_ID) { if (args != null) { mHardReset = args.getBoolean(HARD_RESET, false); } return new MessageDb.Loader(mActivity, mTopicName, mPagesToLoad, MESSAGES_TO_LOAD); } throw new IllegalArgumentException("Unknown loader id " + id); }
Example #11
Source File: AlbumMediaCollection.java From Matisse with Apache License 2.0 | 5 votes |
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { Context context = mContext.get(); if (context == null) { return; } mCallbacks.onAlbumMediaLoad(data); }
Example #12
Source File: ChannelFragment.java From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void onLoaderReset(Loader<Cursor> loader) { if (loader.getId() == QUERY_ID) { // When the loader is being reset, clear the cursor from the adapter. This allows the // cursor resources to be freed. mAdapter.swapCursor(null); } }
Example #13
Source File: ContactSelectionFragment.java From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // This swaps the new cursor into the adapter. if (loader.getId() == ContactsQuery.QUERY_ID) { mAdapter.swapCursor(data); } }
Example #14
Source File: MediaItemsDataSource.java From YImagePicker with Apache License 2.0 | 5 votes |
@NonNull @Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { Context context = mContext.get(); if (context == null) { return null; } return MediaItemsLoader.newInstance(context, set, mimeTypeSet); }
Example #15
Source File: CultureFragment.java From android-news-app with MIT License | 5 votes |
@NonNull @Override public Loader<List<News>> onCreateLoader(int i, Bundle bundle) { String cultureUrl = NewsPreferences.getPreferredUrl(getContext(), getString(R.string.culture)); Log.e(LOG_TAG, cultureUrl); // Create a new loader for the given URL return new NewsLoader(getActivity(), cultureUrl); }
Example #16
Source File: MediaItemsDataSource.java From YImagePicker with Apache License 2.0 | 5 votes |
@Override public void onLoadFinished(@NonNull Loader<Cursor> loader, final Cursor cursor) { final FragmentActivity context = mContext.get(); if (context == null | cursor == null || cursor.isClosed()) { return; } this.cursor = cursor; if (thread != null && thread.isAlive()) { return; } thread = new Thread(runnable); thread.start(); }
Example #17
Source File: CountryPickerFragment.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
@Override public void onLoadFinished(@NonNull Loader<ArrayList<Map<String, String>>> loader, @NonNull ArrayList<Map<String, String>> results) { ((TextView) getListView().getEmptyView()).setText( R.string.country_selection_fragment__no_matching_countries); String[] from = { "country_name", "country_code" }; int[] to = { R.id.country_name, R.id.country_code }; setListAdapter(new SimpleAdapter(getActivity(), results, R.layout.country_list_item, from, to)); applyFilter(countryFilter.getText()); }
Example #18
Source File: AlbumCollection.java From Matisse with Apache License 2.0 | 5 votes |
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { Context context = mContext.get(); if (context == null) { return null; } mLoadFinished = false; return AlbumLoader.newInstance(context); }
Example #19
Source File: ArtistInfoFragment.java From Kore with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) { if (cursor != null && cursor.getCount() > 0) { switch (cursorLoader.getId()) { case LOADER_ARTIST: cursor.moveToFirst(); FileDownloadHelper.SongInfo songInfo = new FileDownloadHelper.SongInfo( cursor.getString(DetailsQuery.ARTIST),null, -1, -1, null, null); setDownloadButtonState(songInfo.downloadDirectoryExists()); DataHolder dataHolder = getDataHolder(); dataHolder.setTitle(cursor.getString(DetailsQuery.ARTIST)); dataHolder.setUndertitle(cursor.getString(DetailsQuery.GENRE)); dataHolder.setDescription(cursor.getString(DetailsQuery.DESCRIPTION)); dataHolder.setPosterUrl(cursor.getString(DetailsQuery.THUMBNAIL)); dataHolder.setFanArtUrl(cursor.getString(DetailsQuery.FANART)); updateView(dataHolder); break; case LOADER_SONGS: final ArrayList<FileDownloadHelper.SongInfo> songInfoList = new ArrayList<>(cursor.getCount()); if (cursor.moveToFirst()) { do { songInfoList.add(createSongInfo(cursor)); } while (cursor.moveToNext()); } UIUtils.downloadSongs(getActivity(), songInfoList, getHostInfo(), callbackHandler); } } }
Example #20
Source File: PlaybackFragment.java From tv-samples with Apache License 2.0 | 5 votes |
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { // When loading related videos or videos for the playlist, query by category. String category = args.getString(VideoContract.VideoEntry.COLUMN_CATEGORY); return new CursorLoader( getActivity(), VideoContract.VideoEntry.CONTENT_URI, null, VideoContract.VideoEntry.COLUMN_CATEGORY + " = ?", new String[] {category}, null); }
Example #21
Source File: TVShowProgressFragment.java From Kore with Apache License 2.0 | 5 votes |
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { if (data != null) { switch (loader.getId()) { case LOADER_NEXT_EPISODES: displayNextEpisodeList(data); break; case LOADER_SEASONS: displaySeasonList(data); break; } } }
Example #22
Source File: ConversationListArchiveFragment.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
@Override public void onLoadFinished(@NonNull Loader<Cursor> arg0, Cursor cursor) { super.onLoadFinished(arg0, cursor); list.setVisibility(View.VISIBLE); emptyState.setVisibility(View.GONE); }
Example #23
Source File: ContactSelectionFragment.java From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void onLoaderReset(Loader<Cursor> loader) { if (loader.getId() == ContactsQuery.QUERY_ID) { // When the loader is being reset, clear the cursor from the adapter. This allows the // cursor resources to be freed. mAdapter.swapCursor(null); } }
Example #24
Source File: TVShowEpisodeInfoFragment.java From Kore with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) { if (cursor != null && cursor.getCount() > 0) { switch (cursorLoader.getId()) { case LOADER_EPISODE: cursor.moveToFirst(); this.cursor = cursor; DataHolder dataHolder = getDataHolder(); dataHolder.setPosterUrl(cursor.getString(EpisodeDetailsQuery.THUMBNAIL)); dataHolder.setRating(cursor.getDouble(EpisodeDetailsQuery.RATING)); dataHolder.setMaxRating(10); String director = cursor.getString(EpisodeDetailsQuery.DIRECTOR); if (!TextUtils.isEmpty(director)) { director = getActivity().getResources().getString(R.string.directors) + " " + director; } int runtime = cursor.getInt(EpisodeDetailsQuery.RUNTIME) / 60; String durationPremiered = runtime > 0 ? String.format(getString(R.string.minutes_abbrev), String.valueOf(runtime)) + " | " + cursor.getString(EpisodeDetailsQuery.FIRSTAIRED) : cursor.getString(EpisodeDetailsQuery.FIRSTAIRED); String season = String.format(getString(R.string.season_episode), cursor.getInt(EpisodeDetailsQuery.SEASON), cursor.getInt(EpisodeDetailsQuery.EPISODE)); dataHolder.setDetails(durationPremiered + "\n" + season + "\n" + director); fileDownloadHelper = new FileDownloadHelper.TVShowInfo( cursor.getString(EpisodeDetailsQuery.SHOWTITLE), cursor.getInt(EpisodeDetailsQuery.SEASON), cursor.getInt(EpisodeDetailsQuery.EPISODE), cursor.getString(EpisodeDetailsQuery.TITLE), cursor.getString(EpisodeDetailsQuery.FILE)); setDownloadButtonState(fileDownloadHelper.downloadFileExists()); setSeenButtonState(cursor.getInt(EpisodeDetailsQuery.PLAYCOUNT) > 0); getDataHolder().setTitle(cursor.getString(EpisodeDetailsQuery.TITLE)); getDataHolder().setUndertitle(cursor.getString(EpisodeDetailsQuery.SHOWTITLE)); setExpandDescription(true); getDataHolder().setDescription(cursor.getString(EpisodeDetailsQuery.PLOT)); updateView(dataHolder); break; } } getFabButton().enableLocalPlay(fileDownloadHelper != null); }
Example #25
Source File: ArtistsFragment.java From VinylMusicPlayer with GNU General Public License v3.0 | 4 votes |
@Override public Loader<ArrayList<Artist>> onCreateLoader(int id, Bundle args) { return new AsyncArtistLoader(getActivity()); }
Example #26
Source File: VerticalGridFragment.java From tv-samples with Apache License 2.0 | 4 votes |
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { if (loader.getId() == ALL_VIDEOS_LOADER && cursor != null && cursor.moveToFirst()) { mVideoCursorAdapter.changeCursor(cursor); } }
Example #27
Source File: ManualNetworkEntryActivity.java From particle-android with Apache License 2.0 | 4 votes |
@Override public void onLoaderReset(Loader<Set<ScanAPCommandResult>> loader) { // no-op }
Example #28
Source File: ProfileDocumentsFragment.java From deltachat-android with GNU General Public License v3.0 | 4 votes |
@Override public void onLoaderReset(Loader<BucketedThreadMediaLoader.BucketedThreadMedia> cursorLoader) { ((ProfileDocumentsAdapter) recyclerView.getAdapter()).setMedia(new BucketedThreadMediaLoader.BucketedThreadMedia(getContext())); }
Example #29
Source File: MessagesAdapter.java From tindroid with Apache License 2.0 | 4 votes |
@Override public void onLoaderReset(@NonNull Loader<Cursor> loader) { if (loader.getId() == MESSAGES_QUERY_ID) { swapCursor(null, mHardReset ? REFRESH_HARD : REFRESH_SOFT); } }
Example #30
Source File: AlbumsFragment.java From VinylMusicPlayer with GNU General Public License v3.0 | 4 votes |
@Override public void onLoadFinished(Loader<ArrayList<Album>> loader, ArrayList<Album> data) { getAdapter().swapDataSet(data); }