-
Notifications
You must be signed in to change notification settings - Fork 123
Expand file tree
/
Copy pathUpdateUI.java
More file actions
56 lines (51 loc) Β· 2.11 KB
/
UpdateUI.java
File metadata and controls
56 lines (51 loc) Β· 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.aniketjain.weatherapp.update;
import android.content.Context;
import com.aniketjain.weatherapp.R;
public class UpdateUI {
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;
}
public static String TranslateDay(String dayToBeTranslated, Context context) {
switch (dayToBeTranslated.trim()) {
case "Monday":
return context.getResources().getString(R.string.monday);
case "Tuesday":
return context.getResources().getString(R.string.tuesday);
case "Wednesday":
return context.getResources().getString(R.string.wednesday);
case "Thursday":
return context.getResources().getString(R.string.thursday);
case "Friday":
return context.getResources().getString(R.string.friday);
case "Saturday":
return context.getResources().getString(R.string.saturday);
case "Sunday":
return context.getResources().getString(R.string.sunday);
}
return dayToBeTranslated;
}
}