+ 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
+ );
+ }
+
+ @Override
+ public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
+ Log.v(LOG_TAG, "In onLoadFinished");
+ if (!data.moveToFirst()) { return; }
+
+ String dateString = Utility.formatDate(
+ data.getString(data.getColumnIndex(WeatherEntry.COLUMN_DATETEXT)));
+ ((TextView) getView().findViewById(R.id.detail_date_textview))
+ .setText(dateString);
+
+ String weatherDescription =
+ data.getString(data.getColumnIndex(WeatherEntry.COLUMN_SHORT_DESC));
+ ((TextView) getView().findViewById(R.id.detail_forecast_textview))
+ .setText(weatherDescription);
+
+ boolean isMetric = Utility.isMetric(getActivity());
+
+ String high = Utility.formatTemperature(
+ data.getDouble(data.getColumnIndex(WeatherEntry.COLUMN_MAX_TEMP)), isMetric);
+ ((TextView) getView().findViewById(R.id.detail_high_textview)).setText(high);
+
+ String low = Utility.formatTemperature(
+ data.getDouble(data.getColumnIndex(WeatherEntry.COLUMN_MIN_TEMP)), isMetric);
+ ((TextView) getView().findViewById(R.id.detail_low_textview)).setText(low);
+
+ // We still need this for the share intent
+ mForecast = String.format("%s - %s - %s/%s", dateString, weatherDescription, high, low);
+
+ Log.v(LOG_TAG, "Forecast String: " + mForecast);
+
+ // If onCreateOptionsMenu has already happened, we need to update the share intent now.
+ if (mShareActionProvider != null) {
+ mShareActionProvider.setShareIntent(createShareForecastIntent());