public void onLocationChanged(String newLocation) { Uri uri = mUri; if (null != uri) { long date = WeatherContract.WeatherEntry.getDateFromUri(uri); Uri updateUri = WeatherContract.WeatherEntry.buildWeatherLocationWithDate(newLocation, date); mUri = updateUri; getLoaderManager().restartLoader(DETAIL_LOADER, null, this); } }
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { Log.v(LOG_TAG, "In onCreateLoader"); Intent intent = getActivity().getIntent(); if (intent == null || !intent.hasExtra(DATE_KEY)) { return null; } String forecastDate = intent.getStringExtra(DATE_KEY); // Sort order: Ascending, by date. String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATETEXT + " ASC"; mLocation = Utility.getPreferredLocation(getActivity()); Uri weatherForLocationUri = WeatherContract.WeatherEntry.buildWeatherLocationWithDate(mLocation, forecastDate); Log.v(LOG_TAG, weatherForLocationUri.toString()); // Now create and return a CursorLoader that will take care of // creating a Cursor for the data being displayed. return new CursorLoader( getActivity(), weatherForLocationUri, FORECAST_COLUMNS, null, null, sortOrder); }