This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Windspeed formats --> | |
<!-- Wind in mph [CHAR LIMIT=25] --> | |
<string name="format_wind_mph">Wind: <xliff:g id="speed">%1$1.0f</xliff:g> mph <xliff:g id="direction">%2$s</xliff:g></string> | |
<!-- Wind in kph [CHAR LIMIT=25] --> | |
<string name="format_wind_kmh">Wind: <xliff:g id="speed">%1$1.0f</xliff:g> km/h <xliff:g id="direction">%2$s</xliff:g></string> | |
<!-- Pressure format CHAR LIMIT=25] --> | |
<string name="format_pressure">Pressure: <xliff:g id="pressure">%1.0f</xliff:g> hPa</string> | |
<!-- Humidity format CHAR LIMIT=25]--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int getIconResourceForWeatherCondition(int weatherId) { | |
// Based on weather code data found at: | |
// http://bugs.openweathermap.org/projects/api/wiki/Weather_Condition_Codes | |
if (weatherId >= 200 && weatherId <= 232) { | |
return R.drawable.ic_storm; | |
} else if (weatherId >= 300 && weatherId <= 321) { | |
return R.drawable.ic_light_rain; | |
} else if (weatherId >= 500 && weatherId <= 504) { | |
return R.drawable.ic_rain; | |
} else if (weatherId == 511) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int viewType = getItemViewType(cursor.getPosition()); | |
switch (viewType) { | |
case VIEW_TYPE_TODAY: { | |
// Get weather icon | |
viewHolder.iconView.setImageResource(Utility.getArtResourceForWeatherCondition( | |
cursor.getInt(ForecastFragment.COL_WEATHER_CONDITION_ID))); | |
break; | |
} | |
case VIEW_TYPE_FUTURE_DAY: { | |
// Get weather icon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:baselineAligned="false" | |
android:divider="?android:attr/dividerHorizontal" | |
android:orientation="horizontal" | |
tools:context="com.example.android.sunshine.app.MainActivity"> | |
<!-- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void onLocationChanged( String newLocation ) { | |
// replace the uri, since the location has changed | |
Uri uri = mUri; | |
if (null != uri) { | |
long date = WeatherContract.WeatherEntry.getDateFromUri(uri); | |
Uri updatedUri = WeatherContract.WeatherEntry.buildWeatherLocationWithDate(newLocation, date); | |
mUri = updatedUri; | |
getLoaderManager().restartLoader(DETAIL_LOADER, null, this); | |
} | |
} |
OlderNewer