ete("{\"fun\":\"timer\"}");
406
            }
407
        });
408 178
    }
409 179
410
411 180
    public class RecommendChargingStationAdapter extends RecyclerView.Adapter<RecommendChargingStationAdapter.ViewHolder> {
412 181
        private List<RecommendZhan> mList;
413 182
@ -835,28 +604,21 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
835 604
836 605
    private void filterChargingStation() {
837 606
        no_result.setVisibility(View.GONE);
607
        List<RecommendZhan> list = new ArrayList<RecommendZhan>();
838 608
839
        List<RecommendZhan> list;
840
        if (firstCondition == 1) {
841
            list = recommendZhanList;
842
        } else {
843
            list = zhanList;
844
        }
845
846
        if (firstCondition == 2) { // 价格最低
609
        if (condition == 2) { // 价格最低
847 610
            List<RecommendZhan> priceList1 = new ArrayList<>();
848 611
            List<RecommendZhan> priceList2 = new ArrayList<>();
849 612
850
            for (RecommendZhan zhan : list) {
851
                if (zhan.getZongjia() > 0) {
852
                    priceList1.add(zhan);
613
            for (RecommendZhan point : zhanList) {
614
                if (point.getZongjia() > 0) {
615
                    priceList1.add(point);
853 616
                } else {
854
                    priceList2.add(zhan);
617
                    priceList2.add(point);
855 618
                }
856 619
            }
857 620
858
            list = priceList1;
859
621
            list.addAll(priceList1);
860 622
            Collections.sort(list, new Comparator<RecommendZhan>() {
861 623
                @Override
862 624
                public int compare(RecommendZhan o1, RecommendZhan o2) {
@ -876,7 +638,8 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
876 638
            list.addAll(priceList2);
877 639
        }
878 640
879
        if (firstCondition == 3) { // 距离最近
641
        if (condition == 1) { // 距离最近
642
            list.addAll(zhanList);
880 643
            Collections.sort(list, new Comparator<RecommendZhan>() {
881 644
                @Override
882 645
                public int compare(RecommendZhan o1, RecommendZhan o2) {
@ -891,7 +654,8 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
891 654
            });
892 655
        }
893 656
894
        if (firstCondition == 4) { // 空闲最多
657
        if (condition == 3) { // 空闲最多
658
            list.addAll(zhanList);
895 659
            Collections.sort(list, new Comparator<RecommendZhan>() {
896 660
                @Override
897 661
                public int compare(RecommendZhan o1, RecommendZhan o2) {
@ -942,7 +706,8 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
942 706
            });
943 707
        }
944 708
945
        if (firstCondition == 5) { // 评分最高
709
        if (condition == 4) { // 评分最高
710
            list.addAll(zhanList);
946 711
            Collections.sort(list, new Comparator<RecommendZhan>() {
947 712
                @Override
948 713
                public int compare(RecommendZhan o1, RecommendZhan o2) {
@ -975,75 +740,9 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
975 740
            list = list.subList(0, 30);
976 741
        }
977 742
743
        recommendChargingStationAdapter.setData(list);
978 744
979
        List<RecommendZhan> list1 = new ArrayList<>();
980
        if (firstCanCharging) {
981
            for (RecommendZhan item : list) {
982
                if ("1".equals(item.getOwn_pay())) {
983
                    list1.add(item);
984
                }
985
            }
986
        } else {
987
            for (RecommendZhan item : list) {
988
                list1.add(item);
989
            }
990
        }
991
992
        List<RecommendZhan> list2 = new ArrayList<>();
993
        if (firstFreeParking) {
994
            for (RecommendZhan item : list1) {
995
                if (item.getStop_cost().contains("免费")) {
996
                    list2.add(item);
997
                }
998
            }
999
        } else {
1000
            for (RecommendZhan item : list1) {
1001
                list2.add(item);
1002
            }
1003
        }
1004
1005
        List<RecommendZhan> list3 = new ArrayList<>();
1006
        if (firstQuickCharging) {
1007
            for (RecommendZhan item : list2) {
1008
                int fastNum;
1009
                if ("".equals(item.getFast_num())) {
1010
                    fastNum = 0;
1011
                } else {
1012
                    fastNum = Integer.parseInt(item.getFast_num());
1013
                }
1014
1015
                if (fastNum > 0) {
1016
                    list3.add(item);
1017
                }
1018
            }
1019
        } else {
1020
            for (RecommendZhan item : list2) {
1021
                list3.add(item);
1022
            }
1023
        }
1024
1025
        List<RecommendZhan> list4 = new ArrayList<>();
1026
        if (firstSlowCharging) {
1027
            for (RecommendZhan item : list3) {
1028
                int slowNum;
1029
                if ("".equals(item.getSlow_num())) {
1030
                    slowNum = 0;
1031
                } else {
1032
                    slowNum = Integer.parseInt(item.getSlow_num());
1033
                }
1034
                if (slowNum > 0) {
1035
                    list4.add(item);
1036
                }
1037
            }
1038
        } else {
1039
            for (RecommendZhan item : list3) {
1040
                list4.add(item);
1041
            }
1042
        }
1043
1044
        recommendChargingStationAdapter.setData(list4);
1045
1046
        if (list4.size() == 0) {
745
        if (list.size() == 0) {
1047 746
            if (socket != null && !socket.isClosed()) {
1048 747
                no_result.setText("数据加载中,请稍后...");
1049 748
            } else {
@ -1137,8 +836,7 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
1137 836
                            new OutputStreamWriter(socket.getOutputStream())), true);
1138 837
                    out.println(params);
1139 838
                    // 接收来自服务器的消息
1140
                    BufferedReader br = new BufferedReader(new InputStreamReader(
1141
                            socket.getInputStream()));
839
                    BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
1142 840
                    String msg = br.readLine();
1143 841
                    int time = (int) (System.currentTimeMillis() / 1000);
1144 842
                    int cha = time - Integer.parseInt(msg);
@ -1181,8 +879,7 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
1181 879
                    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())), true);
1182 880
                    out.println(params);
1183 881
                    // 接收来自服务器的消息
1184
                    BufferedReader br = new BufferedReader(new InputStreamReader(
1185
                            socket.getInputStream()));
882
                    BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
1186 883
                    String msg = br.readLine();
1187 884
                    if (msg != null) {
1188 885
                        Message mes = new Message();
@ -1205,8 +902,6 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
1205 902
                }
1206 903
            }
1207 904
        }).start();
1208
1209 905
    }
1210 906
1211
1212 907
}

+ 71 - 232
app/src/main/res/layout/activity_recommend_charging_station.xml

@ -44,265 +44,104 @@
44 44
            app:layout_constraintRight_toRightOf="parent" />
45 45
    </androidx.constraintlayout.widget.ConstraintLayout>
46 46
47
    <androidx.constraintlayout.widget.ConstraintLayout
48
        android:id="@+id/condition_first_bar"
47
    <LinearLayout
48
        android:id="@+id/condition_bar"
49 49
        android:layout_width="match_parent"
50 50
        android:layout_height="40dp"
51
        android:gravity="center_vertical"
52
        android:orientation="horizontal"
51 53
        app:layout_constraintLeft_toLeftOf="parent"
52 54
        app:layout_constraintRight_toRightOf="parent"
53 55
        app:layout_constraintTop_toBottomOf="@+id/nav_bar">
54 56
55
        <LinearLayout
56
            android:layout_width="match_parent"
57
        <TextView
58
            android:id="@+id/first_condition"
59
            android:layout_width="0dp"
57 60
            android:layout_height="match_parent"
61
            android:layout_weight="1"
58 62
            android:gravity="center"
59
            android:orientation="horizontal">
60
61
            <LinearLayout
62
                android:id="@+id/first_condition"
63
                android:layout_width="0dp"
64
                android:layout_height="match_parent"
65
                android:layout_weight="0.224"
66
                android:gravity="center"
67
                android:orientation="horizontal">
68
69
                <TextView
70
                    android:id="@+id/first_condition_text"
71
                    android:layout_width="wrap_content"
72
                    android:layout_height="wrap_content"
73
                    android:gravity="center"
74
                    android:text="距离最近"
75
                    android:textColor="#2fc45b"
76
                    android:textSize="12sp" />
63
            android:text="距离最近"
64
            android:textColor="#1BB637"
65
            android:textSize="12sp"
66
            android:textStyle="bold" />
77 67
78
                <ImageView
79
                    android:id="@+id/first_condition_image"
80
                    android:layout_width="wrap_content"
81
                    android:layout_height="wrap_content"
82
                    android:layout_marginLeft="5dp"
83
                    android:src="@drawable/recommend_fold" />
84
            </LinearLayout>
85
86
            <View
87
                android:layout_width="1dp"
88
                android:layout_height="10dp"
89
                android:background="#d8d8d8" />
90
91
            <TextView
92
                android:id="@+id/first_can_charging"
93
                android:layout_width="0dp"
94
                android:layout_height="match_parent"
95
                android:layout_weight="0.272"
96
                android:gravity="center"
97
                android:text="本APP可充电"
98
                android:textColor="#222222"
99
                android:textSize="12sp" />
100
101
            <View
102
                android:layout_width="1dp"
103
                android:layout_height="10dp"
104
                android:background="#d8d8d8" />
68
        <View
69
            android:layout_width="1dp"
70
            android:layout_height="10dp"
71
            android:background="#d8d8d8" />
105 72
106
            <TextView
107
                android:id="@+id/first_free_parking"
108
                android:layout_width="0dp"
109
                android:layout_height="match_parent"
110
                android:layout_weight="0.211"
111
                android:gravity="center"
112
                android:text="免费停车"
113
                android:textColor="#222222"
114
                android:textSize="12sp" />
73
        <TextView
74
            android:id="@+id/second_condition"
75
            android:layout_width="0dp"
76
            android:layout_height="match_parent"
77
            android:layout_weight="1"
78
            android:gravity="center"
79
            android:text="价格最低"
80
            android:textColor="#222222"
81
            android:textSize="12sp"
82
            android:textStyle="bold" />
115 83
116
            <View
117
                android:layout_width="1dp"
118
                android:layout_height="10dp"
119
                android:background="#d8d8d8" />
84
        <View
85
            android:layout_width="1dp"
86
            android:layout_height="10dp"
87
            android:background="#d8d8d8" />
120 88
121
            <TextView
122
                android:id="@+id/first_quick_charging"
123
                android:layout_width="0dp"
124
                android:layout_height="match_parent"
125
                android:layout_weight="0.147"
126
                android:gravity="center"
127
                android:text="快充"
128
                android:textColor="#222222"
129
                android:textSize="12sp" />
89
        <TextView
90
            android:id="@+id/third_condition"
91
            android:layout_width="0dp"
92
            android:layout_height="match_parent"
93
            android:layout_weight="1"
94
            android:gravity="center"
95
            android:text="空闲最多"
96
            android:textColor="#222222"
97
            android:textSize="12sp"
98
            android:textStyle="bold" />
130 99
131
            <View
132
                android:layout_width="1dp"
133
                android:layout_height="10dp"
134
                android:background="#d8d8d8" />
100
        <View
101
            android:layout_width="1dp"
102
            android:layout_height="10dp"
103
            android:background="#d8d8d8" />
135 104
136
            <TextView
137
                android:id="@+id/first_slow_charging"
138
                android:layout_width="0dp"
139
                android:layout_height="match_parent"
140
                android:layout_weight="0.147"
141
                android:gravity="center"
142
                android:text="慢充"
143
                android:textColor="#222222"
144
                android:textSize="12sp" />
145
        </LinearLayout>
105
        <TextView
106
            android:id="@+id/forth_condition"
107
            android:layout_width="0dp"
108
            android:layout_height="match_parent"
109
            android:layout_weight="1"
110
            android:gravity="center"
111
            android:text="评分最高"
112
            android:textColor="#222222"
113
            android:textSize="12sp"
114
            android:textStyle="bold" />
146 115
147
        <View
148
            android:layout_width="match_parent"
149
            android:layout_height="0.5dp"
150
            android:background="#dddddd"
151
            app:layout_constraintBottom_toBottomOf="parent"
152
            app:layout_constraintLeft_toLeftOf="parent"
153
            app:layout_constraintRight_toRightOf="parent" />
116
    </LinearLayout>
154 117
155
    </androidx.constraintlayout.widget.ConstraintLayout>
118
    <View
119
        android:id="@+id/condition_line"
120
        app:layout_constraintLeft_toLeftOf="parent"
121
        app:layout_constraintRight_toRightOf="parent"
122
        app:layout_constraintTop_toBottomOf="@+id/condition_bar"
123
        android:layout_width="match_parent"
124
        android:layout_height="0.5dp"
125
        android:background="#dddddd" />
156 126
157 127
    <androidx.recyclerview.widget.RecyclerView
158 128
        android:id="@+id/recyclerView"
159 129
        android:layout_width="match_parent"
160 130
        android:layout_height="0dp"
161 131
        app:layout_constraintBottom_toBottomOf="parent"
162
        app:layout_constraintTop_toBottomOf="@+id/condition_first_bar" />
163
    <androidx.constraintlayout.widget.ConstraintLayout
164
        android:id="@+id/condition_second_bar"
165
        android:layout_width="match_parent"
166
        android:layout_height="0dp"
167
        android:visibility="gone"
168
        app:layout_constraintBottom_toBottomOf="parent"
169
        app:layout_constraintTop_toBottomOf="@+id/condition_first_bar"
170
        tools:visibility="visible">
171
172
        <View
173
            android:layout_width="match_parent"
174
            android:layout_height="match_parent"
175
            android:alpha="0.29"
176
            android:background="#000000" />
177
178
        <LinearLayout
179
            android:layout_width="match_parent"
180
            android:layout_height="120dp"
181
            android:background="#ffffff"
182
            android:orientation="vertical"
183
            android:paddingLeft="22dp"
184
            android:paddingTop="21dp"
185
            android:paddingRight="23dp"
186
            app:layout_constraintTop_toTopOf="parent">
187
188
            <LinearLayout
189
                android:layout_width="match_parent"
190
                android:layout_height="30dp"
191
                android:orientation="horizontal">
192
193
                <Button
194
                    android:id="@+id/second_3"
195
                    android:layout_width="0dp"
196
                    android:layout_height="match_parent"
197
                    android:layout_weight="1"
198
                    android:background="@drawable/recommend_btn_selected"
199
                    android:text="距离最近"
200
                    android:textColor="#ffffff"
201
                    android:textSize="12sp" />
202
203
                <View
204
                    android:layout_width="10dp"
205
                    android:layout_height="match_parent" />
206
207
                <Button
208
                    android:id="@+id/second_2"
209
                    android:layout_width="0dp"
210
                    android:layout_height="match_parent"
211
                    android:layout_weight="1"
212
                    android:background="@drawable/recommend_btn_normal"
213
                    android:text="价格最低"
214
                    android:textColor="#2FC45B"
215
                    android:textSize="12sp" />
216
217
                <View
218
                    android:layout_width="10dp"
219
                    android:layout_height="match_parent" />
220
221
                <Button
222
                    android:id="@+id/second_1"
223
                    android:layout_width="0dp"
224
                    android:layout_height="match_parent"
225
                    android:layout_weight="1"
226
                    android:background="@drawable/recommend_btn_normal"
227
                    android:text="智能推荐"
228
                    android:textColor="#2FC45B"
229
                    android:textSize="12sp" />
230
231
                <View
232
                    android:layout_width="10dp"
233
                    android:layout_height="match_parent" />
234
235
                <Button
236
                    android:id="@+id/second_4"
237
                    android:layout_width="0dp"
238
                    android:layout_height="match_parent"
239
                    android:layout_weight="1"
240
                    android:background="@drawable/recommend_btn_normal"
241
                    android:text="空闲最多"
242
                    android:textColor="#2FC45B"
243
                    android:textSize="12sp" />
244
            </LinearLayout>
245
246
            <LinearLayout
247
                android:layout_width="match_parent"
248
                android:layout_height="30dp"
249
                android:layout_marginTop="15dp">
250
251
                <Button
252
                    android:id="@+id/second_5"
253
                    android:layout_width="0dp"
254
                    android:layout_height="match_parent"
255
                    android:layout_weight="1"
256
                    android:background="@drawable/recommend_btn_normal"
257
                    android:text="评分最高"
258
                    android:textColor="#2FC45B"
259
                    android:textSize="12sp" />
260
261
                <View
262
                    android:layout_width="10dp"
263
                    android:layout_height="match_parent" />
264
265
                <View
266
                    android:layout_width="0dp"
267
                    android:layout_height="match_parent"
268
                    android:layout_weight="1" />
269
270
                <View
271
                    android:layout_width="10dp"
272
                    android:layout_height="match_parent" />
273
274
                <View
275
                    android:layout_width="0dp"
276
                    android:layout_height="match_parent"
277
                    android:layout_weight="1" />
278
279
                <View
280
                    android:layout_width="10dp"
281
                    android:layout_height="match_parent" />
282
283
                <View
284
                    android:layout_width="0dp"
285
                    android:layout_height="match_parent"
286
                    android:layout_weight="1" />
287
            </LinearLayout>
288
289
290
        </LinearLayout>
291
292
293
    </androidx.constraintlayout.widget.ConstraintLayout>
132
        app:layout_constraintTop_toBottomOf="@+id/condition_line" />
294 133
295 134
    <TextView
296 135
        android:id="@+id/no_result"
297
        android:visibility="gone"
298
        tools:visibility="visible"
299
        android:gravity="center"
300
        android:textSize="14sp"
301
        android:textColor="#666666"
302
        android:text="周边没有符合筛选条件的站点,请检查您的筛选项"
303 136
        android:layout_width="match_parent"
304 137
        android:layout_height="0dp"
138
        android:gravity="center"
139
        android:text="周边没有符合筛选条件的站点,请检查您的筛选项"
140
        android:textColor="#666666"
141
        android:textSize="14sp"
142
        android:visibility="gone"
305 143
        app:layout_constraintBottom_toBottomOf="parent"
306
        app:layout_constraintTop_toBottomOf="@+id/condition_first_bar"/>
144
        app:layout_constraintTop_toBottomOf="@+id/condition_line"
145
        tools:visibility="visible" />
307 146
308 147
</androidx.constraintlayout.widget.ConstraintLayout>

cdzApp - Gogs: Go Git Service

充电桩app代码

dxh 06bd894653 init 6 years ago
..
KeyMacCDZ.jks 06bd894653 init 6 years ago