ClothesRecommend.java
4.26 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package com.example.test;
import android.os.StrictMode;
import java.util.ArrayList;
public class ClothesRecommend extends Thread {
ClothesActivity cContext;
WeatherActivity wContext;
WeatherForCast mWeather;
public ClothesRecommend(ClothesActivity mContext) {
this.cContext = cContext;
}
public int Cal_Perceived(String Temper, String Velo) {
int perceived;
double temper = Double.parseDouble(Temper);
double velo = Double.parseDouble(Velo);
perceived = (int) (13.12 + 0.6215 * temper - 11.37 * Math.pow(velo, 0.16) + 0.3965 * Math.pow(velo, 0.16) * temper);
return perceived;
}
// 체감온도에 따른 옷추천 (Recommend는 [체감온도, 성별]으로 이루어진 배열)
public ArrayList<ArrayList<String>> Recommend(ArrayList<Integer> Recommend){
int perceived = Recommend.get(0);
int gender = Recommend.get(1);
ArrayList<String> code = new ArrayList<String>();
ArrayList<String> top = new ArrayList<String>();
ArrayList<String> bottom = new ArrayList<String>();
ArrayList<ArrayList<String>> clothes = new ArrayList<ArrayList<String>>();
if (perceived >= 28){
top.add("민소매");
top.add("반팔");
bottom.add("반바지");
if (gender == 1){
bottom.add("치마");
top.add("원피스");
code.add("11");
} else { code.add("10"); }
} else if (perceived >= 23) {
top.add("반팔");
top.add("얇은 셔츠");
top.add("긴팔");
bottom.add("반바지");
bottom.add("면바지");
if (gender == 1){
bottom.add("치마");
code.add("21");
} else { code.add("20"); }
} else if (perceived >= 20) {
top.add("긴팔");
top.add("가디건");
bottom.add("면바지");
bottom.add("슬랙스");
bottom.add("스키니");
code.add("30");
} else if (perceived >= 17) {
top.add("가디건");
top.add("후드티");
top.add("맨투맨");
bottom.add("청바지");
bottom.add("면바지");
code.add("40");
} else if (perceived >= 12) {
top.add("후드티");
top.add("셔츠");
top.add("가디건");
bottom.add("긴바지");
bottom.add("청바지");
if (gender == 1){
bottom.add("살색스타킹");
code.add("51");
} else { code.add("50"); }
} else if (perceived >= 10) {
top.add("자켓");
top.add("니트");
top.add("트렌치코트");
bottom.add("긴바지");
if (gender == 1){
bottom.add("검정스타킹");
code.add("61");
} else { code.add("60"); }
} else if (perceived >= 4) {
top.add("코트");
top.add("자켓");
top.add("히트텍");
bottom.add("긴바지");
if (gender == 1){
bottom.add("레깅스");
code.add("71");
} else { code.add("70"); }
} else {
top.add("패딩");
top.add("두꺼운 코트");
bottom.add("긴바지");
if (gender == 1) {
bottom.add("레깅스");
code.add("81");
} else { code.add("80"); }
}
clothes.add(code);
clothes.add(top);
clothes.add(bottom);
// Return [[이미지 코드], [상의], [하의]]
return clothes;
}
public ArrayList<ArrayList<String>> AccessWeather(String code){
ArrayList<ArrayList<String>> gData = new ArrayList<ArrayList<String>>();
mWeather = new WeatherForCast(code, (WeatherActivity) wContext);
gData = mWeather.GetOpenWeather(code);
return gData;
}
@Override
public void run() {
super.run();
if (android.os.Build.VERSION.SDK_INT > 9) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
}
}
}