@Override public Loader onCreateLoader(int id, Bundle args) { // If we don't have the video object if(mCurrentVideo==null){ if(mVideoIdFromPlayer!=-1){ return new SingleVideoLoader(getActivity(),mVideoIdFromPlayer).getV4CursorLoader(true, false); } if(mPath!=null){ return new SingleVideoLoader(getActivity(),mPath).getV4CursorLoader(true, false); } } else { if (mCurrentVideo.isIndexed()) { return new MultipleVideoLoader(getActivity(), mCurrentVideo.getId()).getV4CursorLoader(true, false); } else { return new MultipleVideoLoader(getActivity(), mCurrentVideo.getFilePath()).getV4CursorLoader(true, false); } } return null; }
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG, loader, cursor); if (mListAdapter == null) { if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG, "adapter is null, view is destroyed?"); return; } /* * Swapping instead of changing Cursor here, to keep the old one open. * Loader should release the old Cursor - see note in * {@link LoaderManager.LoaderCallbacks#onLoadFinished). */ mListAdapter.swapCursor(cursor); mActionModeListener.updateActionModeForSelection(mSelection.getCount(), new MyActionMode()); if (mListAdapter.getCount() > 0) { mViewFlipper.setDisplayedChild(0); } else { mViewFlipper.setDisplayedChild(1); } }
public <D> Loader<D> initLoader(int id, Bundle args, LoaderCallbacks<D> callback) { if (this.mCreatingLoader) { throw new IllegalStateException("Called while creating a loader"); } LoaderInfo info = (LoaderInfo) this.mLoaders.get(id); if (DEBUG) { Log.v(TAG, "initLoader in " + this + ": args=" + args); } if (info == null) { info = createAndInstallLoader(id, args, callback); if (DEBUG) { Log.v(TAG, " Created new loader " + info); } } else { if (DEBUG) { Log.v(TAG, " Re-using existing loader " + info); } info.mCallbacks = callback; } if (info.mHaveData && this.mStarted) { info.callOnLoadFinished(info.mLoader, info.mData); } return info.mLoader; }
void callOnLoadFinished(Loader<Object> loader, Object data) { if (this.mCallbacks != null) { String lastBecause = null; if (LoaderManagerImpl.this.mHost != null) { lastBecause = LoaderManagerImpl.this.mHost.mFragmentManager.mNoTransactionsBecause; LoaderManagerImpl.this.mHost.mFragmentManager.mNoTransactionsBecause = "onLoadFinished"; } try { if (LoaderManagerImpl.DEBUG) { Log.v(LoaderManagerImpl.TAG, " onLoadFinished in " + loader + ": " + loader.dataToString(data)); } this.mCallbacks.onLoadFinished(loader, data); this.mDeliveredData = true; } finally { if (LoaderManagerImpl.this.mHost != null) { LoaderManagerImpl.this.mHost.mFragmentManager.mNoTransactionsBecause = lastBecause; } } } }
/** * Creates and returns a CursorLoader that loads the data for our URI and stores it in a Cursor. * * @param loaderId The loader ID for which we need to create a loader * @param loaderArgs Any arguments supplied by the caller * * @return A new Loader instance that is ready to start loading. */ @Override public Loader<Cursor> onCreateLoader(int loaderId, Bundle loaderArgs) { switch (loaderId) { case ID_DETAIL_LOADER: return new CursorLoader(this, mUri, WEATHER_DETAIL_PROJECTION, null, null, null); default: throw new RuntimeException("Loader Not Implemented: " + loaderId); } }
@Override public Loader<List<BusStop>> onCreateLoader(int id, Bundle args) { Uri.Builder realTimeTransitInformationBuilder = new Uri.Builder(); realTimeTransitInformationBuilder.scheme("https") .authority("api.translink.ca") .appendPath("rttiapi") .appendPath("v1") .appendPath("stops") .appendQueryParameter("apikey", TRANSLINK_OPEN_API_KEY) .appendQueryParameter("lat", String.format(Locale.CANADA, "%.4f", mLastLocation.getLatitude())) .appendQueryParameter("long", String.format(Locale.CANADA, "%.4f", mLastLocation.getLongitude())) .appendQueryParameter("radius", "200"); Log.d(LOG_TAG, realTimeTransitInformationBuilder.build().toString()); return new BusStopRadiusLoader( getActivity(), realTimeTransitInformationBuilder.build().toString()); }
@Override public Loader<Cursor> onCreateLoader(int loaderId, Bundle bundle) { switch (loaderId) { case ID_FORECAST_LOADER: Uri forecastQueryUri = WeatherContract.WeatherEntry.CONTENT_URI; String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC"; String selection = WeatherContract.WeatherEntry.getSqlSelectForTodayOnwards(); return new CursorLoader(this, forecastQueryUri, MAIN_FORECAST_PROJECTION, selection, null, sortOrder); default: throw new RuntimeException("Loader Not Implemented: " + loaderId); } }
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { int numberOfDays = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); Calendar newCalendar = (Calendar) calendar.clone(); newCalendar.set(Calendar.DAY_OF_MONTH, 1); newCalendar.set(Calendar.HOUR_OF_DAY, 0); newCalendar.set(Calendar.MINUTE, 0); newCalendar.set(Calendar.SECOND, 0); Log.v(TAG, "numberOfDays = " + numberOfDays); long minDate = newCalendar.getTimeInMillis(); newCalendar.set(Calendar.DAY_OF_MONTH, numberOfDays); newCalendar.set(Calendar.HOUR_OF_DAY, 23); newCalendar.set(Calendar.MINUTE, 59); newCalendar.set(Calendar.SECOND, 59); long maxDate = newCalendar.getTimeInMillis(); return ContributionsDataLoader.newRangeLoader(getContext(), minDate, maxDate); }
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { return new CursorLoader(getActivity(), SipManager.FILTER_URI, new String[] { BaseColumns._ID, Filter.FIELD_ACCOUNT, Filter.FIELD_ACTION, Filter.FIELD_MATCHES, Filter.FIELD_PRIORITY, Filter.FIELD_REPLACE }, Filter.FIELD_ACCOUNT + "=?", new String[] {Long.toString(accountId)}, Filter.DEFAULT_ORDER); }
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { if (loader.getId() == CONTENT_LOADER) { if (data != null && isAdded()) { viewPagerAdapter = new ChannelsViewPagerAdapter(getActivity(), getChildFragmentManager()); viewPagerAdapter.swapCursor(data); if (viewPager != null) { viewPager.setAdapter(viewPagerAdapter); tabLayout.setupWithViewPager(viewPager); viewPager.setCurrentItem(selectedTabPosition); } } } }
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { if (data != null) { if (data.getCount() > 0) { RealmList<ImageBean> realmList = new RealmList<>(); data.moveToFirst(); do { String path = data.getString(data.getColumnIndexOrThrow(IMAGE_PROJECTION[0])); String name = data.getString(data.getColumnIndexOrThrow(IMAGE_PROJECTION[1])); long dateTime = data.getLong(data.getColumnIndexOrThrow(IMAGE_PROJECTION[2])); long id = data.getLong(data.getColumnIndexOrThrow(IMAGE_PROJECTION[5])); if (fileExist(path)) { ImageBean bean = new ImageBean(); bean.setId(id); bean.setPath(path); bean.setName(name); bean.setDate(dateTime); realmList.add(bean); } } while (data.moveToNext()); if (onLoadFinishedListener != null) { onLoadFinishedListener.onLoadFinished(realmList); } } } }
@Override public void onLoadFinished(Loader<List<Anime>> loader, List<Anime> data) { if (data != null && !data.isEmpty() && mAdapter.getItemCount() > 0) { mAdapter.clearData(); } mList = (ArrayList) data; mAdapter.setSectionType(1); mAdapter.addAnimeList(data); sortFavorites(); //mAdapter.getFilter().filter(null); }
@Override public Loader<String> onCreateLoader(int id, final Bundle args) { return new AsyncTaskLoader<String>(mContext) { private String mResponse; @Override protected void onStartLoading() { if (args == null) return; if (mResponse == null) { forceLoad(); } else { deliverResult(mResponse); } } @Nullable @Override public String loadInBackground() { URL url = (java.net.URL) args.getSerializable(URL_EXTRA); if (url != null) { try { Log.i(TAG, "Requesting Data From: " + url.toString()); return HTTPUtils.getHTTPResponse(url); } catch (IOException e) { Log.e(TAG, e.getMessage()); } } return null; } @Override public void deliverResult(@Nullable String data) { super.deliverResult(data); mResponse = data; } }; }
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { CursorLoader cursorLoader = new CursorLoader(CollectionActivity.this, CanvasDownloadTable.CONTENT_URI, // URI null, // projection fields null, // the selection criteria null, // the selection args null // the sort order ); return cursorLoader; }
public <D> Loader<D> getLoader(int id) { if (this.mCreatingLoader) { throw new IllegalStateException("Called while creating a loader"); } LoaderInfo loaderInfo = (LoaderInfo) this.mLoaders.get(id); if (loaderInfo == null) { return null; } if (loaderInfo.mPendingLoader != null) { return loaderInfo.mPendingLoader.mLoader; } return loaderInfo.mLoader; }
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { Context context = mContext.get(); if (context == null) { return null; } return AlbumLoader.newInstance(context); }
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { MessageRecord messageRecord = getMessageRecord(this, cursor, getIntent().getStringExtra(TYPE_EXTRA)); if (messageRecord == null) { finish(); } else { new MessageRecipientAsyncTask(this, messageRecord).execute(); } }
/** * {@inheritDoc} */ @Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { changeCursor(data); if(isResumed()) { setListShown(true); }else { setListShownNoAnimation(true); } }
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { if(loader.getId() == LOADER_RESULT) { Utils.logD(LOG_TAG,"onLoadFinished_LOADER_RESULT"); Utils.logD(LOG_TAG,data.toString()); new Thread() { @Override public void run() { bindView(data); } }.start(); } if(loader.getId() == LOADER_QUICK_SEARCH) { Utils.logD(LOG_TAG,"onLoadFinished_LOADER_QUICK_SEARCH"); new Thread() { @Override public void run() { bindViewQuickSearch(data); } }.start(); } }
@Override public Loader<IMPresenter> onCreateLoader(int id, Bundle args) { return new PresenterLoader<>(this, new PresenterFactory<IMPresenter>() { @Override public IMPresenter create() { return new IMPresenter(IMCaseManager.provideIMCase()); } }); }
@Override public Loader<Cursor> onCreateLoader(int i, Bundle bundle) { CursorLoader cursorLoader = new CursorLoader(mContext, MediaStore.Images.Media.EXTERNAL_CONTENT_URI, IMAGE_PROJECTION, IMAGE_PROJECTION[4]+">0 AND "+IMAGE_PROJECTION[3]+"=? OR "+IMAGE_PROJECTION[3]+"=? ", new String[]{"image/jpeg", "image/png"}, IMAGE_PROJECTION[2] + " ASC"); // DESC 降序 return cursorLoader; }
@Override public void onLoadFinished( Loader<List<LocalResourceListItem>> loader, List<LocalResourceListItem> resources) { mAdapter.setResources(resources); if (null != mSavedPathList) { for (String path : mSavedPathList) { mAdapter.setSelection(path, true); } } }
@Override public final Loader<P> onCreateLoader(int i, Bundle bundle) { return new PresenterLoader<P>(this.getContext()) { @Override P create() { return createPresenter(); } }; }
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { return new AsyncTaskLoader<Cursor>(getActivity()) { Cursor mTaskDAta = null; @Override protected void onStartLoading() { if (mTaskDAta != null) { notifyLoaderChangeListener(); } else { forceLoad(); } } private void notifyLoaderChangeListener() { } @Override public Cursor loadInBackground() { try { Uri todayUri = TaskItemsContract.TaskItemsColumns.CONTENT_URI.buildUpon().appendPath(TaskItemsContract.TaskItemsColumns.COLUMN_NAME_IS_TODAY).appendPath("1").build(); return getActivity().getContentResolver().query(todayUri, null, null, null, null); } catch (Exception e) { Log.e(TAG, "Failed to asynchronously load data."); e.printStackTrace(); return null; } } }; }
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { if(id==0) { return new SeasonsLoader(getContext(), mShowId).getV4CursorLoader(true, false); } return super.onCreateLoader(id, args); }
@Override public Loader<List<Song>> onCreateLoader(int id, Bundle args) { if (mPlaylist.getId() == 0) { return null; } PlaylistLoader playlistLoader = new PlaylistLoader(getContext(), mPlaylist.getId()); if (id == trackloader) { return playlistLoader; } return null; }
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args2) { if (getArguments() != null) { String listOfMoviesIds = getArguments().getString(BrowserByVideoSelection.LIST_OF_IDS); if (listOfMoviesIds != null) return new VideosSelectionInPlaylistLoader(getContext(), listOfMoviesIds).getV4CursorLoader(true, mPreferences.getBoolean(VideoPreferencesFragment.KEY_HIDE_WATCHED, false)); } return null; }
@Override public Loader<TicketFeedBackPresenter> onCreateLoader(int id, Bundle args) { return new PresenterLoader<>(this, new PresenterFactory<TicketFeedBackPresenter>() { @Override public TicketFeedBackPresenter create() { return new TicketFeedBackPresenter(TicketUseCaseManager.provideTicketFeedBackCase()); } }); }
/** * Called when a previously created loader has finished its load. * * @param loader The Loader that has finished. * @param data The data generated by the Loader. */ @Override public void onLoadFinished(Loader<String[]> loader, String[] data) { mLoadingIndicator.setVisibility(View.INVISIBLE); mForecastAdapter.setWeatherData(data); if (null == data) { showErrorMessage(); } else { showWeatherDataView(); } }
@Override public void onLoadFinished(Loader<Map<String, Object>> loader, Map<String, Object> data) { binding.setHasData(data != null); if (data != null) { chart.setColumnChartData((ColumnChartData) data.get(ConsumptionPerMonthChartDataLoader.CHART_DATA)); setViewport((Number) data.get(ConsumptionPerMonthChartDataLoader.MIN_CONSUMPTION)); } }
/** * Called by the {@link android.support.v4.app.LoaderManagerImpl} when a new Loader needs to be * created. This Activity only uses one loader, so we don't necessarily NEED to check the * loaderId, but this is certainly best practice. * * @param loaderId The loader ID for which we need to create a loader * @param bundle Any arguments supplied by the caller * @return A new Loader instance that is ready to start loading. */ @Override public Loader<Cursor> onCreateLoader(int loaderId, Bundle bundle) { switch (loaderId) { case ID_FORECAST_LOADER: /* URI for all rows of weather data in our weather table */ Uri forecastQueryUri = WeatherContract.WeatherEntry.CONTENT_URI; /* Sort order: Ascending by date */ String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC"; /* * A SELECTION in SQL declares which rows you'd like to return. In our case, we * want all weather data from today onwards that is stored in our weather table. * We created a handy method to do that in our WeatherEntry class. */ String selection = WeatherContract.WeatherEntry.getSqlSelectForTodayOnwards(); return new CursorLoader(this, forecastQueryUri, MAIN_FORECAST_PROJECTION, selection, null, sortOrder); default: throw new RuntimeException("Loader Not Implemented: " + loaderId); } }
@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. mAdapter.swapCursor(null); }
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { mCartAdapter.swapCursor(data); int mTotalPrice = calculateTotal(data); mTextViewTotalPrice.setText(getString(R.string.shopping_cart_total, mTotalPrice)); boolean emptyCart = data.getCount() == 0; mTextViewEmptyCart.setVisibility(emptyCart ? View.VISIBLE : View.GONE); mButtonCheckout.setEnabled(!emptyCart); }
/** * Called when a previously created loader is being reset, and thus * making its data unavailable. The application should at this point * remove any references it has to the Loader's data. * * @param loader The Loader that is being reset. */ @Override public void onLoaderReset(Loader<String[]> loader) { /* * We aren't using this method in our example application, but we are required to Override * it to implement the LoaderCallbacks<String> interface */ }
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { if (id != LOADER_ID) { return null; } return new CursorLoader( activity, AppProvider.getRecentlyUpdatedUri(), Schema.AppMetadataTable.Cols.ALL, null, null, null ); }
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { if (showProgress) { progress.show(context, R.string.Loading_); } return new ConversationsLoader(context); }
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { return new CursorLoader(this, ContactsContract.CommonDataKinds.Phone.CONTENT_URI,// Content provider null, null, null, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME_PRIMARY + " ASC"); // OrderBy clause }
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { adapter.setApps(cursor); if (adapter.getItemCount() == 0) { appList.setVisibility(View.GONE); emptyState.setVisibility(View.VISIBLE); } else { appList.setVisibility(View.VISIBLE); emptyState.setVisibility(View.GONE); } }
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { return new CursorLoader(getActivity(), SipProfile.ACCOUNT_URI, new String[] { SipProfile.FIELD_ID + " AS " + BaseColumns._ID, SipProfile.FIELD_ID, SipProfile.FIELD_DISPLAY_NAME, SipProfile.FIELD_WIZARD, SipProfile.FIELD_ACTIVE }, null, null, null); }