|
@@ -22,6 +22,7 @@ |
|
|
import android.view.LayoutInflater; |
|
|
import android.view.View; |
|
|
import android.view.ViewGroup; |
|
|
import android.widget.ImageView; |
|
|
import android.widget.TextView; |
|
|
|
|
|
import com.example.android.sunshine.utilities.SunshineDateUtils; |
|
@@ -116,20 +117,35 @@ public void onBindViewHolder(ForecastAdapterViewHolder forecastAdapterViewHolder |
|
|
long dateInMillis = mCursor.getLong(MainActivity.INDEX_WEATHER_DATE); |
|
|
/* Get human readable string using our utility method */ |
|
|
String dateString = SunshineDateUtils.getFriendlyDateString(mContext, dateInMillis, false); |
|
|
/* Use the weatherId to obtain the proper description */ |
|
|
|
|
|
/* Use the weatherId to obtain the proper description */ |
|
|
int weatherId = mCursor.getInt(MainActivity.INDEX_WEATHER_CONDITION_ID); |
|
|
String description = SunshineWeatherUtils.getStringForWeatherCondition(mContext, weatherId); |
|
|
/* Read high temperature from the cursor (in degrees celsius) */ |
|
|
String descriptionA11y = mContext.getString(R.string.a11y_forecast, description); |
|
|
|
|
|
/* Read high temperature from the cursor (in degrees celsius) */ |
|
|
double highInCelsius = mCursor.getDouble(MainActivity.INDEX_WEATHER_MAX_TEMP); |
|
|
/* Read low temperature from the cursor (in degrees celsius) */ |
|
|
String highTemp = SunshineWeatherUtils.formatTemperature(mContext,highInCelsius); |
|
|
String highA11 = mContext.getString(R.string.a11y_high_temp, highTemp); |
|
|
|
|
|
/* Read low temperature from the cursor (in degrees celsius) */ |
|
|
double lowInCelsius = mCursor.getDouble(MainActivity.INDEX_WEATHER_MIN_TEMP); |
|
|
String lowTemp = SunshineWeatherUtils.formatTemperature(mContext,lowInCelsius); |
|
|
String lowA11y = mContext.getString(R.string.a11y_low_temp, lowTemp); |
|
|
|
|
|
String highAndLowTemperature = |
|
|
SunshineWeatherUtils.formatHighLows(mContext, highInCelsius, lowInCelsius); |
|
|
forecastAdapterViewHolder.dateView.setText(dateString); |
|
|
forecastAdapterViewHolder.dateView.setContentDescription("Hello"+dateString); |
|
|
|
|
|
String weatherSummary = dateString + " - " + description + " - " + highAndLowTemperature; |
|
|
forecastAdapterViewHolder.descriptionView.setText(description); |
|
|
forecastAdapterViewHolder.descriptionView.setContentDescription(descriptionA11y); |
|
|
|
|
|
forecastAdapterViewHolder.weatherSummary.setText(weatherSummary); |
|
|
forecastAdapterViewHolder.highTempView.setText(highTemp); |
|
|
forecastAdapterViewHolder.highTempView.setContentDescription(highA11); |
|
|
|
|
|
forecastAdapterViewHolder.lowTempView.setText(lowTemp); |
|
|
forecastAdapterViewHolder.lowTempView.setContentDescription(lowA11y); |
|
|
|
|
|
forecastAdapterViewHolder.iconView.setImageResource(SunshineWeatherUtils.getSmallArtResourceIdForWeatherCondition(weatherId)); |
|
|
} |
|
|
|
|
|
/** |
|
@@ -164,15 +180,26 @@ void swapCursor(Cursor newCursor) { |
|
|
*/ |
|
|
class ForecastAdapterViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { |
|
|
// TODO (4) Replace the weatherSummary TextView with individual weather detail TextViews |
|
|
final TextView weatherSummary; |
|
|
//final TextView weatherSummary; |
|
|
final TextView dateView; |
|
|
final TextView descriptionView; |
|
|
final TextView highTempView; |
|
|
final TextView lowTempView; |
|
|
|
|
|
// TODO (5) Add an ImageView for the weather icon |
|
|
final ImageView iconView; |
|
|
|
|
|
ForecastAdapterViewHolder(View view) { |
|
|
super(view); |
|
|
|
|
|
// TODO (6) Get references to all new views and delete this line |
|
|
weatherSummary = (TextView) view.findViewById(R.id.tv_weather_data); |
|
|
//weatherSummary = (TextView) view.findViewById(R.id.tv_weather_data); |
|
|
|
|
|
iconView = (ImageView) view.findViewById(R.id.weather_icon); |
|
|
descriptionView = (TextView)view.findViewById(R.id.weather_description); |
|
|
dateView = (TextView)view.findViewById(R.id.date); |
|
|
highTempView = (TextView)view.findViewById(R.id.high_temperature); |
|
|
lowTempView = (TextView) view.findViewById(R.id.low_temperature); |
|
|
|
|
|
view.setOnClickListener(this); |
|
|
} |
|
|