-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
134 additions
and
17 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package io.github.protino; | ||
|
||
/** | ||
* Created by Gurupad Mamadapur on 27-Feb-17. | ||
*/ | ||
|
||
public class Utility { | ||
|
||
/** | ||
* Helper method to provide the art resource id according to the weather condition id returned | ||
* by the OpenWeatherMap call. | ||
* | ||
* @param weatherId from OpenWeatherMap API response | ||
* @return resource id for the corresponding image. -1 if no relation is found. | ||
*/ | ||
public static int getArtResourceForWeatherCondition(int weatherId) { | ||
// Based on weather code data found at: | ||
// http://bugs.openweathermap.org/projects/api/wiki/Weather_Condition_Codes | ||
if (weatherId >= 200 && weatherId <= 233) { | ||
return R.drawable.art_storm; | ||
} else if (weatherId >= 300 && weatherId <= 321) { | ||
return R.drawable.art_light_rain; | ||
} else if (weatherId >= 500 && weatherId <= 504) { | ||
return R.drawable.art_rain; | ||
} else if (weatherId == 511) { | ||
return R.drawable.art_snow; | ||
} else if (weatherId >= 520 && weatherId <= 531) { | ||
return R.drawable.art_rain; | ||
} else if (weatherId >= 600 && weatherId <= 622) { | ||
return R.drawable.art_snow; | ||
} else if (weatherId >= 701 && weatherId <= 761) { | ||
return R.drawable.art_fog; | ||
} else if (weatherId == 761 || weatherId == 781) { | ||
return R.drawable.art_storm; | ||
} else if (weatherId == 800) { | ||
return R.drawable.art_clear; | ||
} else if (weatherId == 801) { | ||
return R.drawable.art_light_clouds; | ||
} else if (weatherId >= 802 && weatherId <= 804) { | ||
return R.drawable.art_clouds; | ||
} | ||
return R.drawable.ic_cloud_off_white_18dp; | ||
} | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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