Browse Source

推荐列表开发

huyuguo 5 years ago
parent
commit
2007eca462

+ 73 - 3
app/src/main/java/com/electric/chargingpile/activity/RecommendChargingStationActivity.java

@ -104,6 +104,8 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
104 104
        first_slow_charging.setOnClickListener(this);
105 105
106 106
        condition_second_bar = findViewById(R.id.condition_second_bar);
107
        condition_second_bar.setOnClickListener(this);
108
107 109
        second_1 = findViewById(R.id.second_1);
108 110
        second_2 = findViewById(R.id.second_2);
109 111
        second_3 = findViewById(R.id.second_3);
@ -163,6 +165,9 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
163 165
            case R.id.second_5:
164 166
                chooseSecondCondition(v.getId());
165 167
                break;
168
            case R.id.condition_second_bar:
169
                foldSecondCondition();
170
                break;
166 171
        }
167 172
    }
168 173
@ -290,7 +295,20 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
290 295
            final TextView score_text;
291 296
            final TextView charge_record_cnt;
292 297
            final TextView comment_cnt;
293
             final View times_line;
298
            final View times_line;
299
            final LinearLayout zongjia_container;
300
            final TextView zongjia;
301
            final TextView iv_label_public;
302
            final TextView iv_label_ground;
303
            final TextView iv_label_free_park;
304
            final TextView payment_method;
305
            final TextView fast_num;
306
            final TextView fast_free;
307
            final TextView fast_free_num;
308
            final TextView slow_num;
309
            final TextView slow_free;
310
            final TextView slow_free_num;
311
294 312
295 313
            public ViewHolder(View itemView) {
296 314
                super(itemView);
@ -302,6 +320,21 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
302 320
                charge_record_cnt = itemView.findViewById(R.id.charge_record_cnt);
303 321
                comment_cnt = itemView.findViewById(R.id.comment_cnt);
304 322
                times_line = itemView.findViewById(R.id.times_line);
323
                zongjia_container = itemView.findViewById(R.id.zongjia_container);
324
                zongjia = itemView.findViewById(R.id.zongjia);
325
                iv_label_public = itemView.findViewById(R.id.iv_label_public);
326
                iv_label_ground = itemView.findViewById(R.id.iv_label_ground);
327
                iv_label_free_park = itemView.findViewById(R.id.iv_label_free_park);
328
                payment_method = itemView.findViewById(R.id.payment_method);
329
330
                fast_num = itemView.findViewById(R.id.fast_num);
331
                fast_free = itemView.findViewById(R.id.fast_free);
332
                fast_free_num = itemView.findViewById(R.id.fast_free_num);
333
334
                slow_num = itemView.findViewById(R.id.slow_num);
335
                slow_free = itemView.findViewById(R.id.slow_free);
336
                slow_free_num = itemView.findViewById(R.id.slow_free_num);
337
305 338
            }
306 339
        }
307 340
@ -346,7 +379,7 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
346 379
                holder.charge_record_cnt.setVisibility(View.GONE);
347 380
            } else {
348 381
                holder.charge_record_cnt.setVisibility(View.VISIBLE);
349
                holder.charge_record_cnt.setText(recommendZhan.getCharge_record_cnt() + "次公共充电");
382
                holder.charge_record_cnt.setText(recommendZhan.getCharge_record_cnt() + "次充电成功");
350 383
            }
351 384
352 385
            if (recommendZhan.getComment_cnt() == 0) {
@ -356,12 +389,49 @@ public class RecommendChargingStationActivity extends AppCompatActivity implemen
356 389
                holder.comment_cnt.setText(recommendZhan.getComment_cnt() + "次评论");
357 390
            }
358 391
359
            if (recommendZhan.getCharge_record_cnt() == 0 && recommendZhan.getComment_cnt() == 0) {
392
            if (recommendZhan.getComment_cnt() == 0 || recommendZhan.getCharge_record_cnt() == 0 && recommendZhan.getComment_cnt() == 0) {
360 393
                holder.times_line.setVisibility(View.GONE);
361 394
            } else {
362 395
                holder.times_line.setVisibility(View.VISIBLE);
363 396
            }
364 397
398
            if (recommendZhan.getZongjia() == 0) {
399
                holder.zongjia_container.setVisibility(View.GONE);
400
            } else {
401
                holder.zongjia_container.setVisibility(View.VISIBLE);
402
                holder.zongjia.setText(String.format("%.2f", recommendZhan.getZongjia()));
403
            }
404
405
            holder.iv_label_public.setText(recommendZhan.getBelong_attribute());
406
            holder.iv_label_ground.setText("0".equals(recommendZhan.getPark_location()) ? "地下" : "地上");
407
            holder.iv_label_free_park.setVisibility(recommendZhan.getStop_cost().contains("免费") ? View.VISIBLE : View.GONE);
408
409
            if ("1".equals(recommendZhan.getOwn_pay())) {
410
                holder.payment_method.setText("可使用本APP扫码支付");
411
            } else {
412
                if ("".equals(recommendZhan.getCharge_cost_way2())) {
413
                    holder.payment_method.setText("暂无");
414
                } else {
415
                    holder.payment_method.setText(recommendZhan.getCharge_cost_way2());
416
                }
417
            }
418
419
            if (recommendZhan.getFast_able_num() == null && recommendZhan.getSlow_able_num() == null) {
420
                holder.fast_free.setVisibility(View.GONE);
421
                holder.fast_free_num.setVisibility(View.GONE);
422
                holder.slow_free.setVisibility(View.GONE);
423
                holder.slow_free_num.setVisibility(View.GONE);
424
            } else {
425
                holder.fast_free.setVisibility(View.VISIBLE);
426
                holder.fast_free_num.setVisibility(View.VISIBLE);
427
                holder.slow_free.setVisibility(View.VISIBLE);
428
                holder.slow_free_num.setVisibility(View.VISIBLE);
429
                holder.fast_free_num.setText(recommendZhan.getFast_able_num());
430
                holder.slow_free_num.setText(recommendZhan.getSlow_able_num());
431
            }
432
433
            holder.fast_num.setText("".equals(recommendZhan.getFast_num()) ? "" : recommendZhan.getFast_num());
434
            holder.slow_num.setText("".equals(recommendZhan.getSlow_num()) ? "0" : recommendZhan.getSlow_num());
365 435
        }
366 436
367 437
        @Override

+ 42 - 0
app/src/main/java/com/electric/chargingpile/data/RecommendZhan.java

@ -26,6 +26,9 @@ public class RecommendZhan {
26 26
     * zongjia: 0.65 价格最低排序
27 27
     * charge_record_cnt: 1 充电成功次数
28 28
     * comment_cnt: 1 评论次数
29
     * belong_attribute: 公共 个人
30
     * park_location: 地上 地下
31
     * stop_cost: 免费 收费
29 32
     */
30 33
31 34
    private String id;
@ -47,6 +50,45 @@ public class RecommendZhan {
47 50
    private double zongjia;
48 51
    private int charge_record_cnt;
49 52
    private int comment_cnt;
53
    private String belong_attribute;
54
    private String park_location;
55
    private String stop_cost;
56
57
    public void setZongjia(double zongjia) {
58
        this.zongjia = zongjia;
59
    }
60
61
    public void setCharge_record_cnt(int charge_record_cnt) {
62
        this.charge_record_cnt = charge_record_cnt;
63
    }
64
65
    public void setComment_cnt(int comment_cnt) {
66
        this.comment_cnt = comment_cnt;
67
    }
68
69
    public void setBelong_attribute(String belong_attribute) {
70
        this.belong_attribute = belong_attribute;
71
    }
72
73
    public void setPark_location(String park_location) {
74
        this.park_location = park_location;
75
    }
76
77
    public void setStop_cost(String stop_cost) {
78
        this.stop_cost = stop_cost;
79
    }
80
81
    public String getBelong_attribute() {
82
        return belong_attribute;
83
    }
84
85
    public String getPark_location() {
86
        return park_location;
87
    }
88
89
    public String getStop_cost() {
90
        return stop_cost;
91
    }
50 92
51 93
    public double getZongjia() {
52 94
        return zongjia;

+ 187 - 5
app/src/main/res/layout/recommend_charging_station_item.xml

@ -103,8 +103,8 @@
103 103
    <LinearLayout
104 104
        android:layout_width="match_parent"
105 105
        android:layout_height="wrap_content"
106
        android:gravity="center_vertical"
107 106
        android:layout_marginTop="10dp"
107
        android:gravity="center_vertical"
108 108
        android:paddingLeft="15sp">
109 109
110 110
        <TextView
@ -135,11 +135,193 @@
135 135
    <!-- 公共、地下、免费停车属性  价格 -->
136 136
    <LinearLayout
137 137
        android:layout_width="match_parent"
138
        android:layout_gravity="center_vertical"
139
        android:layout_height="wrap_content">
138
        android:layout_height="wrap_content"
139
        android:layout_marginTop="6dp"
140
        android:gravity="bottom"
141
        android:paddingLeft="15dp">
142
140 143
        <LinearLayout
141
            android:layout_width="wrap_content"
142
            android:layout_height="wrap_content">
144
            android:layout_width="0dp"
145
            android:layout_height="wrap_content"
146
            android:layout_weight="2"
147
            tools:background="#ff0000">
148
149
            <TextView
150
                android:id="@+id/iv_label_public"
151
                android:layout_width="36dp"
152
                android:layout_height="18dp"
153
                android:background="@drawable/label_round_border"
154
                android:gravity="center"
155
                android:text="公共"
156
                android:textColor="#828282"
157
                android:textSize="11dp" />
158
159
            <TextView
160
                android:id="@+id/iv_label_ground"
161
                android:layout_width="36dp"
162
                android:layout_height="18dp"
163
                android:layout_marginLeft="5dp"
164
                android:background="@drawable/label_round_border"
165
                android:gravity="center"
166
                android:text="地下"
167
                android:textColor="#828282"
168
                android:textSize="11dp" />
169
170
            <TextView
171
                android:id="@+id/iv_label_free_park"
172
                android:layout_width="65dp"
173
                android:layout_height="18dp"
174
                android:layout_marginLeft="5dp"
175
                android:background="@drawable/label_round_border"
176
                android:gravity="center"
177
                android:text="免费停车"
178
                android:textColor="#828282"
179
                android:textSize="11dp" />
180
        </LinearLayout>
181
182
        <LinearLayout
183
            android:id="@+id/zongjia_container"
184
            android:layout_width="0dp"
185
            android:layout_height="wrap_content"
186
            android:layout_weight="1"
187
            android:gravity="right|bottom"
188
            android:paddingRight="15dp"
189
            tools:background="#00ff00">
190
191
            <TextView
192
                android:layout_width="wrap_content"
193
                android:layout_height="wrap_content"
194
                android:text="¥"
195
                android:textColor="#555557"
196
                android:textSize="12dp" />
197
198
            <TextView
199
                android:id="@+id/zongjia"
200
                android:layout_width="wrap_content"
201
                android:layout_height="wrap_content"
202
                android:textColor="#555557"
203
                android:textSize="20dp"
204
                tools:text="1.69" />
205
206
            <TextView
207
                android:layout_width="wrap_content"
208
                android:layout_height="wrap_content"
209
                android:text="元/度"
210
                android:textColor="#555557"
211
                android:textSize="12sp" />
212
213
        </LinearLayout>
214
    </LinearLayout>
215
216
    <!-- 支付方式 -->
217
    <TextView
218
        android:id="@+id/payment_method"
219
        android:layout_width="match_parent"
220
        android:layout_height="wrap_content"
221
        android:layout_marginLeft="15dp"
222
        android:layout_marginTop="20dp"
223
        android:layout_marginRight="15dp"
224
        android:textColor="#222222"
225
        android:textSize="14sp"
226
        tools:text="可使用本APP扫码支付" />
227
228
    <View
229
        android:layout_width="match_parent"
230
        android:layout_height="0.5dp"
231
        android:layout_marginTop="20dp"
232
        android:background="#d8d8d8" />
233
234
    <!-- 充电桩桩数 -->
235
    <LinearLayout
236
        android:gravity="center_vertical"
237
        android:layout_width="match_parent"
238
        android:layout_height="48dp">
239
240
        <LinearLayout
241
            android:layout_width="0dp"
242
            android:layout_height="match_parent"
243
            android:layout_weight="1"
244
            android:gravity="center">
245
246
            <TextView
247
                android:layout_width="wrap_content"
248
                android:layout_height="wrap_content"
249
                android:text="快充"
250
                android:textColor="#b2b2b2"
251
                android:textSize="12sp" />
252
253
            <TextView
254
                android:id="@+id/fast_num"
255
                android:layout_width="wrap_content"
256
                android:layout_height="wrap_content"
257
                android:layout_marginLeft="10dp"
258
                android:textColor="#555556"
259
                android:textSize="20sp"
260
                tools:text="5" />
261
            <TextView
262
                android:id="@+id/fast_free"
263
                android:layout_marginLeft="34dp"
264
                android:layout_width="wrap_content"
265
                android:layout_height="wrap_content"
266
                android:text="空闲"
267
                android:textColor="#b2b2b2"
268
                android:textSize="12sp" />
269
270
            <TextView
271
                android:id="@+id/fast_free_num"
272
                android:layout_width="wrap_content"
273
                android:layout_height="wrap_content"
274
                android:layout_marginLeft="10dp"
275
                android:textColor="#555556"
276
                android:textSize="20sp"
277
                tools:text="5" />
278
279
280
        </LinearLayout>
281
        <View
282
            android:background="#d8d8d8"
283
            android:layout_width="1dp"
284
            android:layout_height="14dp"/>
285
286
        <LinearLayout
287
            android:layout_width="0dp"
288
            android:layout_height="match_parent"
289
            android:layout_weight="1"
290
            android:gravity="center">
291
292
            <TextView
293
                android:layout_width="wrap_content"
294
                android:layout_height="wrap_content"
295
                android:text="慢充"
296
                android:textColor="#b2b2b2"
297
                android:textSize="12sp" />
298
299
            <TextView
300
                android:id="@+id/slow_num"
301
                android:layout_width="wrap_content"
302
                android:layout_height="wrap_content"
303
                android:layout_marginLeft="10dp"
304
                android:textColor="#555556"
305
                android:textSize="20sp"
306
                tools:text="5" />
307
308
            <TextView
309
                android:id="@+id/slow_free"
310
                android:layout_width="wrap_content"
311
                android:layout_height="wrap_content"
312
                android:layout_marginLeft="34dp"
313
                android:text="空闲"
314
                android:textColor="#b2b2b2"
315
                android:textSize="12sp" />
316
317
            <TextView
318
                android:id="@+id/slow_free_num"
319
                android:layout_width="wrap_content"
320
                android:layout_height="wrap_content"
321
                android:layout_marginLeft="10dp"
322
                android:textColor="#555556"
323
                android:textSize="20sp"
324
                tools:text="5" />
143 325
        </LinearLayout>
144 326
    </LinearLayout>
145 327