|
@ -55,6 +55,8 @@ import java.util.Comparator;
|
55
|
55
|
import java.util.HashMap;
|
56
|
56
|
import java.util.List;
|
57
|
57
|
import java.util.Map;
|
|
58
|
import java.util.function.Predicate;
|
|
59
|
import java.util.stream.Collectors;
|
58
|
60
|
|
59
|
61
|
import okhttp3.Call;
|
60
|
62
|
|
|
@ -269,7 +271,8 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
269
|
271
|
second_2.setBackground(getResources().getDrawable(R.drawable.recommend_btn_selected));
|
270
|
272
|
second_2.setTextColor(Color.parseColor("#FFFFFF"));
|
271
|
273
|
first_condition_text.setText("价格最低");
|
272
|
|
if (zhanList.size() == 0) {
|
|
274
|
if (zhanList.size() == 0 && socket != null && socket.isClosed()) {
|
|
275
|
loadingDialog.show();
|
273
|
276
|
ete("{\"fun\":\"timer\"}");
|
274
|
277
|
} else {
|
275
|
278
|
filterChargingStation();
|
|
@ -282,7 +285,8 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
282
|
285
|
second_3.setBackground(getResources().getDrawable(R.drawable.recommend_btn_selected));
|
283
|
286
|
second_3.setTextColor(Color.parseColor("#FFFFFF"));
|
284
|
287
|
first_condition_text.setText("距离最近");
|
285
|
|
if (zhanList.size() == 0) {
|
|
288
|
if (zhanList.size() == 0 && socket != null && socket.isClosed()) {
|
|
289
|
loadingDialog.show();
|
286
|
290
|
ete("{\"fun\":\"timer\"}");
|
287
|
291
|
} else {
|
288
|
292
|
filterChargingStation();
|
|
@ -294,7 +298,8 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
294
|
298
|
second_4.setBackground(getResources().getDrawable(R.drawable.recommend_btn_selected));
|
295
|
299
|
second_4.setTextColor(Color.parseColor("#FFFFFF"));
|
296
|
300
|
first_condition_text.setText("空闲最多");
|
297
|
|
if (zhanList.size() == 0) {
|
|
301
|
if (zhanList.size() == 0 && socket != null && socket.isClosed()) {
|
|
302
|
loadingDialog.show();
|
298
|
303
|
ete("{\"fun\":\"timer\"}");
|
299
|
304
|
} else {
|
300
|
305
|
filterChargingStation();
|
|
@ -306,7 +311,8 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
306
|
311
|
second_5.setBackground(getResources().getDrawable(R.drawable.recommend_btn_selected));
|
307
|
312
|
second_5.setTextColor(Color.parseColor("#FFFFFF"));
|
308
|
313
|
first_condition_text.setText("评分最高");
|
309
|
|
if (zhanList.size() == 0) {
|
|
314
|
if (zhanList.size() == 0 && socket != null && socket.isClosed()) {
|
|
315
|
loadingDialog.show();
|
310
|
316
|
ete("{\"fun\":\"timer\"}");
|
311
|
317
|
} else {
|
312
|
318
|
filterChargingStation();
|
|
@ -586,7 +592,11 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
586
|
592
|
|
587
|
593
|
@Override
|
588
|
594
|
public int getItemCount() {
|
589
|
|
return mList.size();
|
|
595
|
if (mList.size() > 30) {
|
|
596
|
return 30;
|
|
597
|
} else {
|
|
598
|
return mList.size();
|
|
599
|
}
|
590
|
600
|
}
|
591
|
601
|
|
592
|
602
|
private void showStarInfoView(ViewHolder holder, RecommendZhan recommendZhan) {
|
|
@ -788,8 +798,7 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
788
|
798
|
if (firstCondition == 1) {
|
789
|
799
|
list = recommendZhanList;
|
790
|
800
|
} else {
|
791
|
|
|
792
|
|
list = recommendZhanList;
|
|
801
|
list = zhanList;
|
793
|
802
|
}
|
794
|
803
|
|
795
|
804
|
List<RecommendZhan> list1 = new ArrayList<>();
|
|
@ -857,22 +866,40 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
857
|
866
|
}
|
858
|
867
|
}
|
859
|
868
|
|
860
|
|
if (firstCondition == 2) {
|
|
869
|
if (firstCondition == 2) {
|
|
870
|
List<RecommendZhan> priceList1 = new ArrayList<>();
|
|
871
|
List<RecommendZhan> priceList2 = new ArrayList<>();
|
|
872
|
|
|
873
|
for (RecommendZhan zhan : list4) {
|
|
874
|
if (zhan.getZongjia() > 0) {
|
|
875
|
priceList1.add(zhan);
|
|
876
|
} else {
|
|
877
|
priceList2.add(zhan);
|
|
878
|
}
|
|
879
|
}
|
|
880
|
|
|
881
|
list4 = priceList1;
|
|
882
|
|
861
|
883
|
Collections.sort(list4, new Comparator<RecommendZhan>() {
|
862
|
884
|
@Override
|
863
|
885
|
public int compare(RecommendZhan o1, RecommendZhan o2) {
|
864
|
886
|
double diff = o1.getZongjia() - o2.getZongjia();
|
|
887
|
if (o1.getZongjia() == 0) {
|
|
888
|
diff = -1;
|
|
889
|
}
|
865
|
890
|
if (diff > 0) {
|
866
|
891
|
return 1;
|
867
|
892
|
} else if (diff < 0) {
|
868
|
|
return -1;
|
|
893
|
return -1;
|
869
|
894
|
}
|
870
|
895
|
return 0;
|
871
|
896
|
}
|
872
|
897
|
});
|
|
898
|
|
|
899
|
list4.addAll(priceList2);
|
873
|
900
|
}
|
874
|
901
|
|
875
|
|
if (firstCondition == 3) {
|
|
902
|
if (firstCondition == 3) {
|
876
|
903
|
Collections.sort(list4, new Comparator<RecommendZhan>() {
|
877
|
904
|
@Override
|
878
|
905
|
public int compare(RecommendZhan o1, RecommendZhan o2) {
|
|
@ -880,14 +907,14 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
880
|
907
|
if (diff > 0) {
|
881
|
908
|
return 1;
|
882
|
909
|
} else if (diff < 0) {
|
883
|
|
return -1;
|
|
910
|
return -1;
|
884
|
911
|
}
|
885
|
912
|
return 0;
|
886
|
913
|
}
|
887
|
914
|
});
|
888
|
915
|
}
|
889
|
916
|
|
890
|
|
if (firstCondition == 4) {
|
|
917
|
if (firstCondition == 4) {
|
891
|
918
|
Collections.sort(list4, new Comparator<RecommendZhan>() {
|
892
|
919
|
@Override
|
893
|
920
|
public int compare(RecommendZhan o1, RecommendZhan o2) {
|
|
@ -931,14 +958,14 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
931
|
958
|
if (diff > 0) {
|
932
|
959
|
return -1;
|
933
|
960
|
} else if (diff < 0) {
|
934
|
|
return 1;
|
|
961
|
return 1;
|
935
|
962
|
}
|
936
|
963
|
return 0;
|
937
|
964
|
}
|
938
|
965
|
});
|
939
|
966
|
}
|
940
|
967
|
|
941
|
|
if (firstCondition == 5) {
|
|
968
|
if (firstCondition == 5) {
|
942
|
969
|
Collections.sort(list4, new Comparator<RecommendZhan>() {
|
943
|
970
|
@Override
|
944
|
971
|
public int compare(RecommendZhan o1, RecommendZhan o2) {
|
|
@ -960,7 +987,7 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
960
|
987
|
if (diff > 0) {
|
961
|
988
|
return -1;
|
962
|
989
|
} else if (diff < 0) {
|
963
|
|
return 1;
|
|
990
|
return 1;
|
964
|
991
|
}
|
965
|
992
|
return 0;
|
966
|
993
|
}
|
|
@ -970,12 +997,15 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
970
|
997
|
recommendChargingStationAdapter.setData(list4);
|
971
|
998
|
|
972
|
999
|
if (list4.size() == 0) {
|
|
1000
|
if (socket != null && !socket.isClosed()) {
|
|
1001
|
no_result.setText("数据加载中,请稍后...");
|
|
1002
|
} else {
|
|
1003
|
no_result.setText("周边没有符合筛选条件的站点,请检查您的筛选项");
|
|
1004
|
}
|
973
|
1005
|
no_result.setVisibility(View.VISIBLE);
|
974
|
1006
|
} else {
|
975
|
1007
|
no_result.setVisibility(View.GONE);
|
976
|
1008
|
}
|
977
|
|
|
978
|
|
|
979
|
1009
|
}
|
980
|
1010
|
|
981
|
1011
|
private void getGaode(Double jing, Double wei) {
|
|
@ -994,6 +1024,10 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
994
|
1024
|
private Socket socket;
|
995
|
1025
|
private Handler hand = new Handler() {
|
996
|
1026
|
public void handleMessage(android.os.Message msg) {
|
|
1027
|
if (activity != null && !activity.isFinishing()) {
|
|
1028
|
loadingDialog.dismiss();
|
|
1029
|
}
|
|
1030
|
|
997
|
1031
|
switch (msg.what) {
|
998
|
1032
|
case 3:
|
999
|
1033
|
try {
|
|
@ -1003,7 +1037,7 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
1003
|
1037
|
String data = JsonUtils.getKeyResult(msg.obj.toString(), "data");
|
1004
|
1038
|
List<RecommendZhan> list = JsonUtils.parseToObjectList(data, RecommendZhan.class);
|
1005
|
1039
|
if (list != null) {
|
1006
|
|
int count = list.size() > 30 ? 30 : list.size();
|
|
1040
|
int count = list.size();
|
1007
|
1041
|
for (int i = 0; i < count; i++) {
|
1008
|
1042
|
String wei = list.get(i).getPoi_wei().trim();
|
1009
|
1043
|
String jing = list.get(i).getPoi_jing().trim();
|
|
@ -1050,7 +1084,7 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
1050
|
1084
|
public void run() {
|
1051
|
1085
|
try {
|
1052
|
1086
|
|
1053
|
|
socket = new Socket("cdz.evcharge.cc", 9503);
|
|
1087
|
socket = new Socket("59.110.68.162", 9503);
|
1054
|
1088
|
|
1055
|
1089
|
PrintWriter out = new PrintWriter(new BufferedWriter(
|
1056
|
1090
|
new OutputStreamWriter(socket.getOutputStream())), true);
|
|
@ -1078,6 +1112,10 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
1078
|
1112
|
ete1(socket_string);
|
1079
|
1113
|
} catch (Exception e) {
|
1080
|
1114
|
e.printStackTrace();
|
|
1115
|
Message mes = new Message();
|
|
1116
|
mes.obj = "error";
|
|
1117
|
mes.what = 100;
|
|
1118
|
hand.sendMessage(mes);
|
1081
|
1119
|
}
|
1082
|
1120
|
}
|
1083
|
1121
|
}).start();
|
|
@ -1089,7 +1127,7 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
1089
|
1127
|
@Override
|
1090
|
1128
|
public void run() {
|
1091
|
1129
|
try {
|
1092
|
|
socket = new Socket("cdz.evcharge.cc", 9503);
|
|
1130
|
socket = new Socket("59.110.68.162", 9503);
|
1093
|
1131
|
socket.setReceiveBufferSize(99999);
|
1094
|
1132
|
socket.setSendBufferSize(99999);
|
1095
|
1133
|
|
|
@ -1113,6 +1151,11 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
|
1113
|
1151
|
|
1114
|
1152
|
socket.close();
|
1115
|
1153
|
} catch (Exception e) {
|
|
1154
|
e.printStackTrace();
|
|
1155
|
Message mes = new Message();
|
|
1156
|
mes.obj = "error";
|
|
1157
|
mes.what = 100;
|
|
1158
|
hand.sendMessage(mes);
|
1116
|
1159
|
}
|
1117
|
1160
|
}
|
1118
|
1161
|
}).start();
|