|
@ -50,6 +50,8 @@ import java.io.PrintWriter;
|
50
|
50
|
import java.net.Socket;
|
51
|
51
|
import java.net.URISyntaxException;
|
52
|
52
|
import java.util.ArrayList;
|
|
53
|
import java.util.Collections;
|
|
54
|
import java.util.Comparator;
|
53
|
55
|
import java.util.HashMap;
|
54
|
56
|
import java.util.List;
|
55
|
57
|
import java.util.Map;
|
|
@ -57,10 +59,12 @@ import java.util.Map;
|
57
|
59
|
import okhttp3.Call;
|
58
|
60
|
|
59
|
61
|
import static com.electric.chargingpile.activity.MainMapActivity.getMD5;
|
|
62
|
import static com.electric.chargingpile.activity.MainMapActivity.list;
|
60
|
63
|
|
61
|
64
|
public class RecommendChargingStationActivity extends AppCompatActivity implements View.OnClickListener {
|
62
|
65
|
private static final String TAG = "RecommendChargingStationActivity";
|
63
|
66
|
List<RecommendZhan> recommendZhanList;
|
|
67
|
List<RecommendZhan> zhanList;
|
64
|
68
|
private LoadingDialog loadingDialog;
|
65
|
69
|
private View popupWindowView;
|
66
|
70
|
private PopupWindow popupWindow;
|
|
@ -109,7 +113,8 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
109
|
113
|
}
|
110
|
114
|
|
111
|
115
|
private void initView() {
|
112
|
|
recommendZhanList = new ArrayList<RecommendZhan>();
|
|
116
|
recommendZhanList = new ArrayList<>();
|
|
117
|
zhanList = new ArrayList<>();
|
113
|
118
|
activity = this;
|
114
|
119
|
loadingDialog = new LoadingDialog(this);
|
115
|
120
|
loadingDialog.setCanceledOnTouchOutside(false);
|
|
@ -177,7 +182,7 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
177
|
182
|
firstCanCharging = !firstCanCharging;
|
178
|
183
|
first_can_charging.setTextColor(firstCanCharging ? Color.parseColor("#2FC45B") : Color.parseColor("#222222"));
|
179
|
184
|
foldSecondCondition();
|
180
|
|
filterChargingStation(recommendZhanList);
|
|
185
|
filterChargingStation();
|
181
|
186
|
if (firstCanCharging) {
|
182
|
187
|
MobclickAgent.onEvent(getApplicationContext(), "1141");
|
183
|
188
|
}
|
|
@ -186,7 +191,7 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
186
|
191
|
firstFreeParking = !firstFreeParking;
|
187
|
192
|
first_free_parking.setTextColor(firstFreeParking ? Color.parseColor("#2FC45B") : Color.parseColor("#222222"));
|
188
|
193
|
foldSecondCondition();
|
189
|
|
filterChargingStation(recommendZhanList);
|
|
194
|
filterChargingStation();
|
190
|
195
|
if (firstFreeParking) {
|
191
|
196
|
MobclickAgent.onEvent(getApplicationContext(), "1143");
|
192
|
197
|
}
|
|
@ -195,7 +200,7 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
195
|
200
|
firstQuickCharging = !firstQuickCharging;
|
196
|
201
|
first_quick_charging.setTextColor(firstQuickCharging ? Color.parseColor("#2FC45B") : Color.parseColor("#222222"));
|
197
|
202
|
foldSecondCondition();
|
198
|
|
filterChargingStation(recommendZhanList);
|
|
203
|
filterChargingStation();
|
199
|
204
|
if (firstQuickCharging) {
|
200
|
205
|
MobclickAgent.onEvent(getApplicationContext(), "1142");
|
201
|
206
|
}
|
|
@ -204,7 +209,7 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
204
|
209
|
firstSlowCharging = !firstSlowCharging;
|
205
|
210
|
first_slow_charging.setTextColor(firstSlowCharging ? Color.parseColor("#2FC45B") : Color.parseColor("#222222"));
|
206
|
211
|
foldSecondCondition();
|
207
|
|
filterChargingStation(recommendZhanList);
|
|
212
|
filterChargingStation();
|
208
|
213
|
if (firstSlowCharging) {
|
209
|
214
|
MobclickAgent.onEvent(getApplicationContext(), "1144");
|
210
|
215
|
}
|
|
@ -254,6 +259,8 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
254
|
259
|
first_condition_text.setText("智能推荐");
|
255
|
260
|
if (recommendZhanList.size() == 0) {
|
256
|
261
|
recommendChargingStationFunc();
|
|
262
|
} else {
|
|
263
|
filterChargingStation();
|
257
|
264
|
}
|
258
|
265
|
MobclickAgent.onEvent(getApplicationContext(), "1136");
|
259
|
266
|
break;
|
|
@ -262,6 +269,12 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
262
|
269
|
second_2.setBackground(getResources().getDrawable(R.drawable.recommend_btn_selected));
|
263
|
270
|
second_2.setTextColor(Color.parseColor("#FFFFFF"));
|
264
|
271
|
first_condition_text.setText("价格最低");
|
|
272
|
if (zhanList.size() == 0) {
|
|
273
|
ete("{\"fun\":\"timer\"}");
|
|
274
|
} else {
|
|
275
|
filterChargingStation();
|
|
276
|
}
|
|
277
|
|
265
|
278
|
MobclickAgent.onEvent(getApplicationContext(), "1138");
|
266
|
279
|
break;
|
267
|
280
|
case R.id.second_3:
|
|
@ -269,6 +282,11 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
269
|
282
|
second_3.setBackground(getResources().getDrawable(R.drawable.recommend_btn_selected));
|
270
|
283
|
second_3.setTextColor(Color.parseColor("#FFFFFF"));
|
271
|
284
|
first_condition_text.setText("距离最近");
|
|
285
|
if (zhanList.size() == 0) {
|
|
286
|
ete("{\"fun\":\"timer\"}");
|
|
287
|
} else {
|
|
288
|
filterChargingStation();
|
|
289
|
}
|
272
|
290
|
MobclickAgent.onEvent(getApplicationContext(), "1139");
|
273
|
291
|
break;
|
274
|
292
|
case R.id.second_4:
|
|
@ -276,6 +294,11 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
276
|
294
|
second_4.setBackground(getResources().getDrawable(R.drawable.recommend_btn_selected));
|
277
|
295
|
second_4.setTextColor(Color.parseColor("#FFFFFF"));
|
278
|
296
|
first_condition_text.setText("空闲最多");
|
|
297
|
if (zhanList.size() == 0) {
|
|
298
|
ete("{\"fun\":\"timer\"}");
|
|
299
|
} else {
|
|
300
|
filterChargingStation();
|
|
301
|
}
|
279
|
302
|
MobclickAgent.onEvent(getApplicationContext(), "1140");
|
280
|
303
|
break;
|
281
|
304
|
case R.id.second_5:
|
|
@ -283,6 +306,11 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
283
|
306
|
second_5.setBackground(getResources().getDrawable(R.drawable.recommend_btn_selected));
|
284
|
307
|
second_5.setTextColor(Color.parseColor("#FFFFFF"));
|
285
|
308
|
first_condition_text.setText("评分最高");
|
|
309
|
if (zhanList.size() == 0) {
|
|
310
|
ete("{\"fun\":\"timer\"}");
|
|
311
|
} else {
|
|
312
|
filterChargingStation();
|
|
313
|
}
|
286
|
314
|
MobclickAgent.onEvent(getApplicationContext(), "1137");
|
287
|
315
|
break;
|
288
|
316
|
}
|
|
@ -353,15 +381,11 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
353
|
381
|
}
|
354
|
382
|
|
355
|
383
|
double d = AMapUtils.calculateLineDistance(center, ll);
|
|
384
|
list.get(i).setDistanceNum(d);
|
356
|
385
|
list.get(i).setDistance(Util.getDistance(d));
|
357
|
386
|
}
|
358
|
387
|
recommendZhanList = list;
|
359
|
|
recommendChargingStationAdapter.setData(list);
|
360
|
|
if (list.size() == 0) {
|
361
|
|
no_result.setVisibility(View.VISIBLE);
|
362
|
|
} else {
|
363
|
|
no_result.setVisibility(View.GONE);
|
364
|
|
}
|
|
388
|
filterChargingStation();
|
365
|
389
|
}
|
366
|
390
|
}
|
367
|
391
|
ete("{\"fun\":\"timer\"}");
|
|
@ -757,18 +781,26 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
757
|
781
|
}
|
758
|
782
|
}
|
759
|
783
|
|
760
|
|
private void filterChargingStation(List<RecommendZhan> zhanList) {
|
|
784
|
private void filterChargingStation() {
|
761
|
785
|
no_result.setVisibility(View.GONE);
|
762
|
786
|
|
|
787
|
List<RecommendZhan> list;
|
|
788
|
if (firstCondition == 1) {
|
|
789
|
list = recommendZhanList;
|
|
790
|
} else {
|
|
791
|
// list = zhanList; // TODO
|
|
792
|
list = recommendZhanList;
|
|
793
|
}
|
|
794
|
|
763
|
795
|
List<RecommendZhan> list1 = new ArrayList<>();
|
764
|
796
|
if (firstCanCharging) {
|
765
|
|
for (RecommendZhan item : zhanList) {
|
|
797
|
for (RecommendZhan item : list) {
|
766
|
798
|
if ("1".equals(item.getOwn_pay())) {
|
767
|
799
|
list1.add(item);
|
768
|
800
|
}
|
769
|
801
|
}
|
770
|
802
|
} else {
|
771
|
|
for (RecommendZhan item : zhanList) {
|
|
803
|
for (RecommendZhan item : list) {
|
772
|
804
|
list1.add(item);
|
773
|
805
|
}
|
774
|
806
|
}
|
|
@ -825,6 +857,116 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
825
|
857
|
}
|
826
|
858
|
}
|
827
|
859
|
|
|
860
|
if (firstCondition == 2) {
|
|
861
|
Collections.sort(list4, new Comparator<RecommendZhan>() {
|
|
862
|
@Override
|
|
863
|
public int compare(RecommendZhan o1, RecommendZhan o2) {
|
|
864
|
double diff = o1.getZongjia() - o2.getZongjia();
|
|
865
|
if (diff > 0) {
|
|
866
|
return 1;
|
|
867
|
} else if (diff < 0) {
|
|
868
|
return -1;
|
|
869
|
}
|
|
870
|
return 0;
|
|
871
|
}
|
|
872
|
});
|
|
873
|
}
|
|
874
|
|
|
875
|
if (firstCondition == 3) {
|
|
876
|
Collections.sort(list4, new Comparator<RecommendZhan>() {
|
|
877
|
@Override
|
|
878
|
public int compare(RecommendZhan o1, RecommendZhan o2) {
|
|
879
|
double diff = o1.getDistanceNum() - o2.getDistanceNum();
|
|
880
|
if (diff > 0) {
|
|
881
|
return 1;
|
|
882
|
} else if (diff < 0) {
|
|
883
|
return -1;
|
|
884
|
}
|
|
885
|
return 0;
|
|
886
|
}
|
|
887
|
});
|
|
888
|
}
|
|
889
|
|
|
890
|
if (firstCondition == 4) {
|
|
891
|
Collections.sort(list4, new Comparator<RecommendZhan>() {
|
|
892
|
@Override
|
|
893
|
public int compare(RecommendZhan o1, RecommendZhan o2) {
|
|
894
|
int fast_able_num1;
|
|
895
|
int fast_able_num2;
|
|
896
|
int slow_able_num1;
|
|
897
|
int slow_able_num2;
|
|
898
|
|
|
899
|
int total_num1;
|
|
900
|
int total_num2;
|
|
901
|
|
|
902
|
if (o1.getFast_able_num() == null || "".equals(o1.getFast_able_num())) {
|
|
903
|
fast_able_num1 = 0;
|
|
904
|
} else {
|
|
905
|
fast_able_num1 = Integer.parseInt(o1.getFast_able_num());
|
|
906
|
}
|
|
907
|
|
|
908
|
if (o1.getSlow_able_num() == null || "".equals(o1.getSlow_able_num())) {
|
|
909
|
slow_able_num1 = 0;
|
|
910
|
} else {
|
|
911
|
slow_able_num1 = Integer.parseInt(o1.getSlow_able_num());
|
|
912
|
}
|
|
913
|
|
|
914
|
|
|
915
|
if (o2.getFast_able_num() == null || "".equals(o2.getFast_able_num())) {
|
|
916
|
fast_able_num2 = 0;
|
|
917
|
} else {
|
|
918
|
fast_able_num2 = Integer.parseInt(o2.getFast_able_num());
|
|
919
|
}
|
|
920
|
|
|
921
|
if (o2.getSlow_able_num() == null || "".equals(o2.getSlow_able_num())) {
|
|
922
|
slow_able_num2 = 0;
|
|
923
|
} else {
|
|
924
|
slow_able_num2 = Integer.parseInt(o2.getSlow_able_num());
|
|
925
|
}
|
|
926
|
|
|
927
|
total_num1 = fast_able_num1 + slow_able_num1;
|
|
928
|
total_num2 = fast_able_num2 + slow_able_num2;
|
|
929
|
|
|
930
|
int diff = total_num1 - total_num2;
|
|
931
|
if (diff > 0) {
|
|
932
|
return -1;
|
|
933
|
} else if (diff < 0) {
|
|
934
|
return 1;
|
|
935
|
}
|
|
936
|
return 0;
|
|
937
|
}
|
|
938
|
});
|
|
939
|
}
|
|
940
|
|
|
941
|
if (firstCondition == 5) {
|
|
942
|
Collections.sort(list4, new Comparator<RecommendZhan>() {
|
|
943
|
@Override
|
|
944
|
public int compare(RecommendZhan o1, RecommendZhan o2) {
|
|
945
|
double star1;
|
|
946
|
double star2;
|
|
947
|
if (o1.getStar() == null || "".equals(o1.getStar())) {
|
|
948
|
star1 = 0;
|
|
949
|
} else {
|
|
950
|
star1 = Double.parseDouble(o1.getStar());
|
|
951
|
}
|
|
952
|
|
|
953
|
if (o2.getStar() == null || "".equals(o2.getStar())) {
|
|
954
|
star2 = 0;
|
|
955
|
} else {
|
|
956
|
star2 = Double.parseDouble(o2.getStar());
|
|
957
|
}
|
|
958
|
|
|
959
|
double diff = star1 - star2;
|
|
960
|
if (diff > 0) {
|
|
961
|
return -1;
|
|
962
|
} else if (diff < 0) {
|
|
963
|
return 1;
|
|
964
|
}
|
|
965
|
return 0;
|
|
966
|
}
|
|
967
|
});
|
|
968
|
}
|
|
969
|
|
828
|
970
|
recommendChargingStationAdapter.setData(list4);
|
829
|
971
|
|
830
|
972
|
if (list4.size() == 0) {
|
|
@ -832,6 +974,8 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
832
|
974
|
} else {
|
833
|
975
|
no_result.setVisibility(View.GONE);
|
834
|
976
|
}
|
|
977
|
|
|
978
|
|
835
|
979
|
}
|
836
|
980
|
|
837
|
981
|
private void getGaode(Double jing, Double wei) {
|
|
@ -855,12 +999,37 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
855
|
999
|
try {
|
856
|
1000
|
String rtnCode = JsonUtils.getKeyResult(msg.obj.toString(), "rtnCode");
|
857
|
1001
|
if ("0".equals(rtnCode)) {
|
858
|
|
try{
|
|
1002
|
try {
|
859
|
1003
|
String data = JsonUtils.getKeyResult(msg.obj.toString(), "data");
|
860
|
1004
|
List<RecommendZhan> list = JsonUtils.parseToObjectList(data, RecommendZhan.class);
|
861
|
|
if (list != null && list.size() > 0) {
|
|
1005
|
if (list != null) {
|
|
1006
|
int count = list.size() > 30 ? 30 : list.size();
|
|
1007
|
for (int i = 0; i < count; i++) {
|
|
1008
|
String wei = list.get(i).getPoi_wei().trim();
|
|
1009
|
String jing = list.get(i).getPoi_jing().trim();
|
|
1010
|
|
|
1011
|
int position_jing = jing.length() - jing.indexOf(".") - 1;
|
|
1012
|
int position_wei = wei.length() - wei.indexOf(".") - 1;
|
|
1013
|
|
|
1014
|
|
|
1015
|
LatLng ll;
|
|
1016
|
if (position_jing > 13 || position_wei > 13) {
|
|
1017
|
ll = new LatLng(Double.parseDouble(wei), Double.parseDouble(jing));
|
|
1018
|
} else {
|
|
1019
|
double dwei = Double.parseDouble(wei);
|
|
1020
|
double djing = Double.parseDouble(jing);
|
|
1021
|
getGaode(djing, dwei);
|
|
1022
|
ll = new LatLng(Double.parseDouble(gd_wei), Double.parseDouble(gd_jing));
|
|
1023
|
}
|
|
1024
|
|
|
1025
|
double d = AMapUtils.calculateLineDistance(center, ll);
|
|
1026
|
list.get(i).setDistanceNum(d);
|
|
1027
|
list.get(i).setDistance(Util.getDistance(d));
|
|
1028
|
}
|
|
1029
|
zhanList = list;
|
|
1030
|
filterChargingStation();
|
862
|
1031
|
}
|
863
|
|
}catch (Exception e) {
|
|
1032
|
} catch (Exception e) {
|
864
|
1033
|
e.printStackTrace();
|
865
|
1034
|
}
|
866
|
1035
|
}
|
|
@ -906,9 +1075,9 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
906
|
1075
|
map.put("poi_rdy", rlat);
|
907
|
1076
|
map.put("timer", Token);
|
908
|
1077
|
String socket_string = JsonUtils.mapToJson(map);
|
909
|
|
LogUtils.e(socket_string);
|
910
|
1078
|
ete1(socket_string);
|
911
|
1079
|
} catch (Exception e) {
|
|
1080
|
e.printStackTrace();
|
912
|
1081
|
}
|
913
|
1082
|
}
|
914
|
1083
|
}).start();
|
|
@ -934,7 +1103,6 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
934
|
1103
|
if (msg != null) {
|
935
|
1104
|
Message mes = new Message();
|
936
|
1105
|
mes.obj = msg;
|
937
|
|
LogUtils.e(msg);
|
938
|
1106
|
mes.what = 3;
|
939
|
1107
|
hand.sendMessage(mes);
|
940
|
1108
|
} else {
|