/* This is ported from FetchWeatherTask --- but now we go straight from the cursor to the string. */ private String convertCursorRowToUXFormat(Cursor cursor) { int idx_max_temp = ForecastFragment.COL_WEATHER_MAX_TEMP; int idx_min_temp = ForecastFragment.COL_WEATHER_MIN_TEMP; int idx_date = ForecastFragment.COL_WEATHER_DATE; int idx_short_desc = ForecastFragment.COL_WEATHER_DESC; String highAndLow = formatHighLows(cursor.getDouble(idx_max_temp), cursor.getDouble(idx_min_temp)); return Utility.formatDate(cursor.getLong(idx_date)) + " - " + cursor.getString(idx_short_desc) + " - " + highAndLow; }
@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()); } }