Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ private void updateUI() {
binding.layout.updatedAtTv.setText(updated_at);
binding.layout.conditionIv.setImageResource(
getResources().getIdentifier(
UpdateUI.getIconID(condition, update_time, sunrise, sunset),
UpdateUI.getWeatherIconDrawableName(condition, update_time, sunrise, sunset),
"drawable",
getPackageName()
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private void updateUI(DayViewHolder holder) {
holder.humidity.setText(humidity + "%");
holder.icon.setImageResource(
context.getResources().getIdentifier(
UpdateUI.getIconID(condition, update_time, sunrise, sunset),
UpdateUI.getWeatherIconDrawableName(condition, update_time, sunrise, sunset),
"drawable",
context.getPackageName()
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,34 @@

public class UpdateUI {

public static String getIconID(int condition, long update_time, long sunrise, long sunset) {
public static String getWeatherIconDrawableName(int condition, long update_time, long sunrise, long sunset) {
if (condition >= 200 && condition <= 232)
return "thunderstorm";
else if (condition >= 300 && condition <= 321)
return "drizzle";
else if (condition >= 500 && condition <= 531)
return "rain";
else if (condition >= 600 && condition <= 622)
return "snow";
else if (condition >= 701 && condition <= 781)
return "wind";
else if (condition == 800) {
if (update_time >= sunrise && update_time <= sunset)
return "clear_day";
else
return "clear_night";
} else if (condition == 801) {
if (update_time >= sunrise && update_time <= sunset)
return "few_clouds_day";
else
return "few_clouds_night";
} else if (condition == 802)
return "scattered_clouds";
else if (condition == 803 || condition == 804)
return "broken_clouds";
return null;
}

Check notice on line 36 in app/src/main/java/com/aniketjain/weatherapp/update/UpdateUI.java

View check run for this annotation

codefactor.io / CodeFactor

app/src/main/java/com/aniketjain/weatherapp/update/UpdateUI.java#L9-L36

Complex Method
public static String TranslateDay(String dayToBeTranslated, Context context) {
switch (dayToBeTranslated.trim()) {
case "Monday":
Expand Down