|
@ -6,6 +6,8 @@ import android.content.pm.PackageInfo;
|
6
|
6
|
import android.content.pm.PackageManager;
|
7
|
7
|
import android.graphics.Color;
|
8
|
8
|
import android.graphics.drawable.BitmapDrawable;
|
|
9
|
import android.os.Handler;
|
|
10
|
import android.os.Message;
|
9
|
11
|
import android.support.constraint.ConstraintLayout;
|
10
|
12
|
import android.support.v7.app.AppCompatActivity;
|
11
|
13
|
import android.os.Bundle;
|
|
@ -15,6 +17,7 @@ import android.view.Gravity;
|
15
|
17
|
import android.view.LayoutInflater;
|
16
|
18
|
import android.view.View;
|
17
|
19
|
import android.view.ViewGroup;
|
|
20
|
import android.widget.AdapterView;
|
18
|
21
|
import android.widget.Button;
|
19
|
22
|
import android.widget.ImageView;
|
20
|
23
|
import android.widget.LinearLayout;
|
|
@ -24,23 +27,37 @@ import android.widget.Toast;
|
24
|
27
|
|
25
|
28
|
import com.amap.api.maps.AMapUtils;
|
26
|
29
|
import com.amap.api.maps.model.LatLng;
|
|
30
|
import com.blankj.utilcode.util.LogUtils;
|
27
|
31
|
import com.electric.chargingpile.R;
|
28
|
32
|
import com.electric.chargingpile.application.MainApplication;
|
29
|
33
|
import com.electric.chargingpile.data.RecommendZhan;
|
|
34
|
import com.electric.chargingpile.data.Zhan;
|
|
35
|
import com.electric.chargingpile.manager.ProfileManager;
|
30
|
36
|
import com.electric.chargingpile.util.BarColorUtil;
|
31
|
37
|
import com.electric.chargingpile.util.JsonUtils;
|
32
|
38
|
import com.electric.chargingpile.util.LoadingDialog;
|
33
|
39
|
import com.electric.chargingpile.util.ToastUtil;
|
34
|
40
|
import com.electric.chargingpile.util.Util;
|
|
41
|
import com.umeng.analytics.MobclickAgent;
|
35
|
42
|
import com.zhy.http.okhttp.OkHttpUtils;
|
36
|
43
|
import com.zhy.http.okhttp.callback.StringCallback;
|
37
|
44
|
|
|
45
|
import java.io.BufferedReader;
|
|
46
|
import java.io.BufferedWriter;
|
|
47
|
import java.io.InputStreamReader;
|
|
48
|
import java.io.OutputStreamWriter;
|
|
49
|
import java.io.PrintWriter;
|
|
50
|
import java.net.Socket;
|
38
|
51
|
import java.net.URISyntaxException;
|
39
|
52
|
import java.util.ArrayList;
|
|
53
|
import java.util.HashMap;
|
40
|
54
|
import java.util.List;
|
|
55
|
import java.util.Map;
|
41
|
56
|
|
42
|
57
|
import okhttp3.Call;
|
43
|
58
|
|
|
59
|
import static com.electric.chargingpile.activity.MainMapActivity.getMD5;
|
|
60
|
|
44
|
61
|
public class RecommendChargingStationActivity extends AppCompatActivity implements View.OnClickListener {
|
45
|
62
|
private static final String TAG = "RecommendChargingStationActivity";
|
46
|
63
|
List<RecommendZhan> recommendZhanList;
|
|
@ -87,6 +104,7 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
87
|
104
|
setContentView(R.layout.activity_recommend_charging_station);
|
88
|
105
|
BarColorUtil.initStatusBarColor(RecommendChargingStationActivity.this);
|
89
|
106
|
initView();
|
|
107
|
MobclickAgent.onEvent(getApplicationContext(), "1136");
|
90
|
108
|
recommendChargingStationFunc();
|
91
|
109
|
}
|
92
|
110
|
|
|
@ -160,24 +178,36 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
160
|
178
|
first_can_charging.setTextColor(firstCanCharging ? Color.parseColor("#2FC45B") : Color.parseColor("#222222"));
|
161
|
179
|
foldSecondCondition();
|
162
|
180
|
filterChargingStation(recommendZhanList);
|
|
181
|
if (firstCanCharging) {
|
|
182
|
MobclickAgent.onEvent(getApplicationContext(), "1141");
|
|
183
|
}
|
163
|
184
|
break;
|
164
|
185
|
case R.id.first_free_parking:
|
165
|
186
|
firstFreeParking = !firstFreeParking;
|
166
|
187
|
first_free_parking.setTextColor(firstFreeParking ? Color.parseColor("#2FC45B") : Color.parseColor("#222222"));
|
167
|
188
|
foldSecondCondition();
|
168
|
189
|
filterChargingStation(recommendZhanList);
|
|
190
|
if (firstFreeParking) {
|
|
191
|
MobclickAgent.onEvent(getApplicationContext(), "1143");
|
|
192
|
}
|
169
|
193
|
break;
|
170
|
194
|
case R.id.first_quick_charging:
|
171
|
195
|
firstQuickCharging = !firstQuickCharging;
|
172
|
196
|
first_quick_charging.setTextColor(firstQuickCharging ? Color.parseColor("#2FC45B") : Color.parseColor("#222222"));
|
173
|
197
|
foldSecondCondition();
|
174
|
198
|
filterChargingStation(recommendZhanList);
|
|
199
|
if (firstQuickCharging) {
|
|
200
|
MobclickAgent.onEvent(getApplicationContext(), "1142");
|
|
201
|
}
|
175
|
202
|
break;
|
176
|
203
|
case R.id.first_slow_charging:
|
177
|
204
|
firstSlowCharging = !firstSlowCharging;
|
178
|
205
|
first_slow_charging.setTextColor(firstSlowCharging ? Color.parseColor("#2FC45B") : Color.parseColor("#222222"));
|
179
|
206
|
foldSecondCondition();
|
180
|
207
|
filterChargingStation(recommendZhanList);
|
|
208
|
if (firstSlowCharging) {
|
|
209
|
MobclickAgent.onEvent(getApplicationContext(), "1144");
|
|
210
|
}
|
181
|
211
|
break;
|
182
|
212
|
case R.id.second_1:
|
183
|
213
|
case R.id.second_2:
|
|
@ -225,30 +255,35 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
225
|
255
|
if (recommendZhanList.size() == 0) {
|
226
|
256
|
recommendChargingStationFunc();
|
227
|
257
|
}
|
|
258
|
MobclickAgent.onEvent(getApplicationContext(), "1136");
|
228
|
259
|
break;
|
229
|
260
|
case R.id.second_2:
|
230
|
261
|
firstCondition = 2;
|
231
|
262
|
second_2.setBackground(getResources().getDrawable(R.drawable.recommend_btn_selected));
|
232
|
263
|
second_2.setTextColor(Color.parseColor("#FFFFFF"));
|
233
|
264
|
first_condition_text.setText("价格最低");
|
|
265
|
MobclickAgent.onEvent(getApplicationContext(), "1138");
|
234
|
266
|
break;
|
235
|
267
|
case R.id.second_3:
|
236
|
268
|
firstCondition = 3;
|
237
|
269
|
second_3.setBackground(getResources().getDrawable(R.drawable.recommend_btn_selected));
|
238
|
270
|
second_3.setTextColor(Color.parseColor("#FFFFFF"));
|
239
|
271
|
first_condition_text.setText("距离最近");
|
|
272
|
MobclickAgent.onEvent(getApplicationContext(), "1139");
|
240
|
273
|
break;
|
241
|
274
|
case R.id.second_4:
|
242
|
275
|
firstCondition = 4;
|
243
|
276
|
second_4.setBackground(getResources().getDrawable(R.drawable.recommend_btn_selected));
|
244
|
277
|
second_4.setTextColor(Color.parseColor("#FFFFFF"));
|
245
|
278
|
first_condition_text.setText("空闲最多");
|
|
279
|
MobclickAgent.onEvent(getApplicationContext(), "1140");
|
246
|
280
|
break;
|
247
|
281
|
case R.id.second_5:
|
248
|
282
|
firstCondition = 5;
|
249
|
283
|
second_5.setBackground(getResources().getDrawable(R.drawable.recommend_btn_selected));
|
250
|
284
|
second_5.setTextColor(Color.parseColor("#FFFFFF"));
|
251
|
285
|
first_condition_text.setText("评分最高");
|
|
286
|
MobclickAgent.onEvent(getApplicationContext(), "1137");
|
252
|
287
|
break;
|
253
|
288
|
}
|
254
|
289
|
foldSecondCondition();
|
|
@ -329,6 +364,7 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
329
|
364
|
}
|
330
|
365
|
}
|
331
|
366
|
}
|
|
367
|
ete("{\"fun\":\"timer\"}");
|
332
|
368
|
}
|
333
|
369
|
});
|
334
|
370
|
}
|
|
@ -811,4 +847,109 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
811
|
847
|
gd_wei = String.valueOf(gg_lat);
|
812
|
848
|
}
|
813
|
849
|
|
|
850
|
private Socket socket;
|
|
851
|
private Handler hand = new Handler() {
|
|
852
|
public void handleMessage(android.os.Message msg) {
|
|
853
|
switch (msg.what) {
|
|
854
|
case 3:
|
|
855
|
try {
|
|
856
|
String rtnCode = JsonUtils.getKeyResult(msg.obj.toString(), "rtnCode");
|
|
857
|
if ("0".equals(rtnCode)) {
|
|
858
|
try{
|
|
859
|
String data = JsonUtils.getKeyResult(msg.obj.toString(), "data");
|
|
860
|
List<RecommendZhan> list = JsonUtils.parseToObjectList(data, RecommendZhan.class);
|
|
861
|
if (list != null && list.size() > 0) {
|
|
862
|
}
|
|
863
|
}catch (Exception e) {
|
|
864
|
e.printStackTrace();
|
|
865
|
}
|
|
866
|
}
|
|
867
|
} catch (Exception e) {
|
|
868
|
e.printStackTrace();
|
|
869
|
}
|
|
870
|
break;
|
|
871
|
default:
|
|
872
|
break;
|
|
873
|
}
|
|
874
|
}
|
|
875
|
};
|
|
876
|
|
|
877
|
//获取站点列表
|
|
878
|
private void ete(final String params) {
|
|
879
|
new Thread(new Runnable() {
|
|
880
|
@Override
|
|
881
|
public void run() {
|
|
882
|
try {
|
|
883
|
// 创建Socket
|
|
884
|
socket = new Socket("cdz.evcharge.cc", 9503); // IP:10.14.114.127,端口54321
|
|
885
|
// 向服务器发送消息
|
|
886
|
PrintWriter out = new PrintWriter(new BufferedWriter(
|
|
887
|
new OutputStreamWriter(socket.getOutputStream())), true);
|
|
888
|
out.println(params);
|
|
889
|
// 接收来自服务器的消息
|
|
890
|
BufferedReader br = new BufferedReader(new InputStreamReader(
|
|
891
|
socket.getInputStream()));
|
|
892
|
String msg = br.readLine();
|
|
893
|
int time = (int) (System.currentTimeMillis() / 1000);
|
|
894
|
int cha = time - Integer.parseInt(msg);
|
|
895
|
String Token = getMD5(String.valueOf((System.currentTimeMillis() / 1000 - cha) / 10) + "qwerty");
|
|
896
|
String llon, llat, rlon, rlat;
|
|
897
|
llon = String.valueOf(Double.parseDouble(center_jing) - 0.047414454728858857);
|
|
898
|
llat = String.valueOf(Double.parseDouble(center_wei) + 0.047414454728858857);
|
|
899
|
rlon = String.valueOf(Double.parseDouble(center_jing) + 0.047414454728858857);
|
|
900
|
rlat = String.valueOf(Double.parseDouble(center_wei) - 0.041842459916509256);
|
|
901
|
HashMap<String, String> map = new HashMap<String, String>();
|
|
902
|
map.put("fun", "zhangetlist");
|
|
903
|
map.put("poi_lux", llon);
|
|
904
|
map.put("poi_luy", llat);
|
|
905
|
map.put("poi_rdx", rlon);
|
|
906
|
map.put("poi_rdy", rlat);
|
|
907
|
map.put("timer", Token);
|
|
908
|
String socket_string = JsonUtils.mapToJson(map);
|
|
909
|
LogUtils.e(socket_string);
|
|
910
|
ete1(socket_string);
|
|
911
|
} catch (Exception e) {
|
|
912
|
}
|
|
913
|
}
|
|
914
|
}).start();
|
|
915
|
|
|
916
|
}
|
|
917
|
|
|
918
|
private void ete1(final String params) {
|
|
919
|
new Thread(new Runnable() {
|
|
920
|
@Override
|
|
921
|
public void run() {
|
|
922
|
try {
|
|
923
|
socket = new Socket("cdz.evcharge.cc", 9503); // IP:10.14.114.127,端口54321
|
|
924
|
socket.setReceiveBufferSize(99999); // 接收缓冲大小
|
|
925
|
socket.setSendBufferSize(99999);
|
|
926
|
// 向服务器发送消息
|
|
927
|
PrintWriter out = new PrintWriter(new BufferedWriter(
|
|
928
|
new OutputStreamWriter(socket.getOutputStream())), true);
|
|
929
|
out.println(params);
|
|
930
|
// 接收来自服务器的消息
|
|
931
|
BufferedReader br = new BufferedReader(new InputStreamReader(
|
|
932
|
socket.getInputStream()));
|
|
933
|
String msg = br.readLine();
|
|
934
|
if (msg != null) {
|
|
935
|
Message mes = new Message();
|
|
936
|
mes.obj = msg;
|
|
937
|
LogUtils.e(msg);
|
|
938
|
mes.what = 3;
|
|
939
|
hand.sendMessage(mes);
|
|
940
|
} else {
|
|
941
|
LogUtils.e("msg=null");
|
|
942
|
}
|
|
943
|
out.close();
|
|
944
|
br.close();
|
|
945
|
// 关闭Socket
|
|
946
|
socket.close();
|
|
947
|
} catch (Exception e) {
|
|
948
|
}
|
|
949
|
}
|
|
950
|
}).start();
|
|
951
|
|
|
952
|
}
|
|
953
|
|
|
954
|
|
814
|
955
|
}
|