80
            return true;
81
        }
82
        return false;
83
    }
84
85
    private void handleLayoutIfStaggeredGridLayout(RecyclerView.ViewHolder holder, int position) {
86
        if (isEmptyPosition(position) || judgeType(position) == TYPE_HEADER || judgeType(position) == TYPE_FOOTER) {
87
            StaggeredGridLayoutManager.LayoutParams p = (StaggeredGridLayoutManager.LayoutParams)
88
                    holder.itemView.getLayoutParams();
89
            p.setFullSpan(true);
90
        }
91
    }
92
93
    @Override
94
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
95
        if (viewType == TYPE_EMPTY){
96
            return new BaseViewHolder(getEmptyView(parent));
97
        } else {
98
            if (mUseBinding) {
99
                ViewDataBinding binding = DataBindingUtil.inflate(LayoutInflater.from(mContext),
100
                        getLayoutId(mTempPosition, viewType), parent, false);
101
                return new BaseViewHolder(binding.getRoot());
102
            } else {
103
                View view = LayoutInflater.from(mContext).inflate(
104
                        getLayoutId(mTempPosition, viewType), parent, false);
105
                return new BaseViewHolder(view);
106
            }
107
        }
108
    }
109
110
    @Override
111
    public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
112
        int type = judgeType(position);
113
        final int groupPosition = getGroupPositionForPosition(position);
114
        if (type == TYPE_HEADER) {
115
            if (mOnHeaderClickListener != null) {
116
                holder.itemView.setOnClickListener(new View.OnClickListener() {
117
                    @Override
118
                    public void onClick(View v) {
119
                        if (mOnHeaderClickListener != null) {
120
                            ViewParent parent = holder.itemView.getParent();
121
                            int gPosition = parent instanceof FrameLayout ? groupPosition : getGroupPositionForPosition(holder.getLayoutPosition());
122
                            if (gPosition >= 0 && gPosition < mStructures.size()) {
123
                                mOnHeaderClickListener.onHeaderClick(GroupedRecyclerViewAdapter.this,
124
                                        (BaseViewHolder) holder, gPosition);
125
                            }
126
                        }
127
                    }
128
                });
129
            }
130
            onBindHeaderViewHolder((BaseViewHolder) holder, groupPosition);
131
        } else if (type == TYPE_FOOTER) {
132
            if (mOnFooterClickListener != null) {
133
                holder.itemView.setOnClickListener(new View.OnClickListener() {
134
                    @Override
135
                    public void onClick(View v) {
136
                        if (mOnFooterClickListener != null) {
137
                            int gPosition = getGroupPositionForPosition(holder.getLayoutPosition());
138
                            if (gPosition >= 0 && gPosition < mStructures.size()) {
139
                                mOnFooterClickListener.onFooterClick(GroupedRecyclerViewAdapter.this,
140
                                        (BaseViewHolder) holder, gPosition);
141
                            }
142
                        }
143
                    }
144
                });
145
            }
146
            onBindFooterViewHolder((BaseViewHolder) holder, groupPosition);
147
        } else if (type == TYPE_CHILD) {
148
            int childPosition = getChildPositionForPosition(groupPosition, position);
149
            if (mOnChildClickListener != null) {
150
                holder.itemView.setOnClickListener(new View.OnClickListener() {
151
                    @Override
152
                    public void onClick(View v) {
153
                        if (mOnChildClickListener != null) {
154
                            int gPosition = getGroupPositionForPosition(holder.getLayoutPosition());
155
                            int cPosition = getChildPositionForPosition(gPosition, holder.getLayoutPosition());
156
                            if (gPosition >= 0 && gPosition < mStructures.size() && cPosition >= 0
157
                                    && cPosition < mStructures.get(gPosition).getChildrenCount()) {
158
                                mOnChildClickListener.onChildClick(GroupedRecyclerViewAdapter.this,
159
                                        (BaseViewHolder) holder, gPosition, cPosition);
160
                            }
161
                        }
162
                    }
163
                });
164
            }
165
            onBindChildViewHolder((BaseViewHolder) holder, groupPosition, childPosition);
166
        }
167
    }
168
169
    @Override
170
    public int getItemCount() {
171
        if (isDataChanged) {
172
            structureChanged();
173
        }
174
175
        int count = count();
176
        if (count > 0) {
177
            return count;
178
        } else if (showEmptyView) {
179
            // 显示空布局
180
            return 1;
181
        } else {
182
            return 0;
183
        }
184
    }
185
186
    public boolean isEmptyPosition(int position) {
187
        return position == 0 && showEmptyView && count() == 0;
188
    }
189
190
    @Override
191
    public int getItemViewType(int position) {
192
        if (isEmptyPosition(position)) {
193
            // 空布局
194
            return TYPE_EMPTY;
195
        }
196
        mTempPosition = position;
197
        int groupPosition = getGroupPositionForPosition(position);
198
        int type = judgeType(position);
199
        if (type == TYPE_HEADER) {
200
            return getHeaderViewType(groupPosition);
201
        } else if (type == TYPE_FOOTER) {
202
            return getFooterViewType(groupPosition);
203
        } else if (type == TYPE_CHILD) {
204
            int childPosition = getChildPositionForPosition(groupPosition, position);
205
            return getChildViewType(groupPosition, childPosition);
206
        }
207
        return super.getItemViewType(position);
208
    }
209
210
    public int getHeaderViewType(int groupPosition) {
211
        return TYPE_HEADER;
212
    }
213
214
    public int getFooterViewType(int groupPosition) {
215
        return TYPE_FOOTER;
216
    }
217
218
    public int getChildViewType(int groupPosition, int childPosition) {
219
        return TYPE_CHILD;
220
    }
221
222
    private int getLayoutId(int position, int viewType) {
223
        int type = judgeType(position);
224
        if (type == TYPE_HEADER) {
225
            return getHeaderLayout(viewType);
226
        } else if (type == TYPE_FOOTER) {
227
            return getFooterLayout(viewType);
228
        } else if (type == TYPE_CHILD) {
229
            return getChildLayout(viewType);
230
        }
231
        return 0;
232
    }
233
234
    private int count() {
235
        return countGroupRangeItem(0, mStructures.size());
236
    }
237
238
    /**
239
     * 判断item的type 头部 尾部 和 子项
240
     *
241
     * @param position
242
     * @return
243
     */
244
    public int judgeType(int position) {
245
        int itemCount = 0;
246
        int groupCount = mStructures.size();
247
248
        for (int i = 0; i < groupCount; i++) {
249
            GroupStructure structure = mStructures.get(i);
250
            if (structure.hasHeader()) {
251
                itemCount += 1;
252
                if (position < itemCount) {
253
                    return TYPE_HEADER;
254
                }
255
            }
256
257
            itemCount += structure.getChildrenCount();
258
            if (position < itemCount) {
259
                return TYPE_CHILD;
260
            }
261
262
            if (structure.hasFooter()) {
263
                itemCount += 1;
264
                if (position < itemCount) {
265
                    return TYPE_FOOTER;
266
                }
267
            }
268
        }
269
270
        return TYPE_EMPTY;
271
    }
272
273
    /**
274
     * 重置组结构列表
275
     */
276
    private void structureChanged() {
277
        mStructures.clear();
278
        int groupCount = getGroupCount();
279
        for (int i = 0; i < groupCount; i++) {
280
            mStructures.add(new GroupStructure(hasHeader(i), hasFooter(i), getChildrenCount(i)));
281
        }
282
        isDataChanged = false;
283
    }
284
285
    /**
286
     * 根据下标计算position所在的组(groupPosition)
287
     *
288
     * @param position 下标
289
     * @return 组下标 groupPosition
290
     */
291
    public int getGroupPositionForPosition(int position) {
292
        int count = 0;
293
        int groupCount = mStructures.size();
294
        for (int i = 0; i < groupCount; i++) {
295
            count += countGroupItem(i);
296
            if (position < count) {
297
                return i;
298
            }
299
        }
300
        return -1;
301
    }
302
303
    /**
304
     * 根据下标计算position在组中位置(childPosition)
305
     *
306
     * @param groupPosition 所在的组
307
     * @param position      下标
308
     * @return 子项下标 childPosition
309
     */
310
    public int getChildPositionForPosition(int groupPosition, int position) {
311
        if (groupPosition >= 0 && groupPosition < mStructures.size()) {
312
            int itemCount = countGroupRangeItem(0, groupPosition + 1);
313
            GroupStructure structure = mStructures.get(groupPosition);
314
            int p = structure.getChildrenCount() - (itemCount - position)
315
                    + (structure.hasFooter() ? 1 : 0);
316
            if (p >= 0) {
317
                return p;
318
            }
319
        }
320
        return -1;
321
    }
322
323
    /**
324
     * 获取一个组的开始下标,这个下标可能是组头,可能是子项(如果没有组头)或者组尾(如果这个组只有组尾)
325
     *
326
     * @param groupPosition 组下标
327
     * @return
328
     */
329
    public int getPositionForGroup(int groupPosition) {
330
        if (groupPosition >= 0 && groupPosition < mStructures.size()) {
331
            return countGroupRangeItem(0, groupPosition);
332
        } else {
333
            return -1;
334
        }
335
336
    }
337
338
    /**
339
     * 获取一个组的组头下标 如果该组没有组头 返回-1
340
     *
341
     * @param groupPosition 组下标
342
     * @return 下标
343
     */
344
    public int getPositionForGroupHeader(int groupPosition) {
345
        if (groupPosition >= 0 && groupPosition < mStructures.size()) {
346
            GroupStructure structure = mStructures.get(groupPosition);
347
            if (!structure.hasHeader()) {
348
                return -1;
349
            }
350
            return countGroupRangeItem(0, groupPosition);
351
        }
352
        return -1;
353
    }
354
355
    /**
356
     * 获取一个组的组尾下标 如果该组没有组尾 返回-1
357
     *
358
     * @param groupPosition 组下标
359
     * @return 下标
360
     */
361
    public int getPositionForGroupFooter(int groupPosition) {
362
        if (groupPosition >= 0 && groupPosition < mStructures.size()) {
363
            GroupStructure structure = mStructures.get(groupPosition);
364
            if (!structure.hasFooter()) {
365
                return -1;
366
            }
367
            return countGroupRangeItem(0, groupPosition + 1) - 1;
368
        }
369
        return -1;
370
    }
371
372
    /**
373
     * 获取一个组指定的子项下标 如果没有 返回-1
374
     *
375
     * @param groupPosition 组下标
376
     * @param childPosition 子项的组内下标
377
     * @return 下标
378
     */
379
    public int getPositionForChild(int groupPosition, int childPosition) {
380
        if (groupPosition >= 0 && groupPosition < mStructures.size()) {
381
            GroupStructure structure = mStructures.get(groupPosition);
382
            if (structure.getChildrenCount() > childPosition) {
383
                int itemCount = countGroupRangeItem(0, groupPosition);
384
                return itemCount + childPosition + (structure.hasHeader() ? 1 : 0);
385
            }
386
        }
387
        return -1;
388
    }
389
390
    /**
391
     * 计算一个组里有多少个Item(头加尾加子项)
392
     *
393
     * @param groupPosition
394
     * @return
395
     */
396
    public int countGroupItem(int groupPosition) {
397
        int itemCount = 0;
398
        if (groupPosition >= 0 && groupPosition < mStructures.size()) {
399
            GroupStructure structure = mStructures.get(groupPosition);
400
            if (structure.hasHeader()) {
401
                itemCount += 1;
402
            }
403
            itemCount += structure.getChildrenCount();
404
            if (structure.hasFooter()) {
405
                itemCount += 1;
406
            }
407
        }
408
        return itemCount;
409
    }
410
411
    /**
412
     * 计算多个组的项的总和
413
     *
414
     * @return
415
     */
416
    public int countGroupRangeItem(int start, int count) {
417
        int itemCount = 0;
418
        int size = mStructures.size();
419
        for (int i = start; i < size && i < start + count; i++) {
420
            itemCount += countGroupItem(i);
421
        }
422
        return itemCount;
423
    }
424
425
    /**
426
     * 设置空布局显示。默认不显示
427
     * @param isShow
428
     */
429
    public void showEmptyView(boolean isShow){
430
        if (isShow != showEmptyView){
431
            showEmptyView = isShow;
432
            notifyDataChanged();
433
        }
434
    }
435
436
    public boolean isShowEmptyView(){
437
        return showEmptyView;
438
    }
439
440
    //****** 刷新操作 *****//
441
442
    /**
443
     * Use {@link #notifyDataChanged()} instead.
444
     */
445
    @Deprecated
446
    public void changeDataSet() {
447
        notifyDataChanged();
448
    }
449
450
    /**
451
     * 通知数据列表刷新
452
     */
453
    public void notifyDataChanged() {
454
        isDataChanged = true;
455
        notifyDataSetChanged();
456
    }
457
458
    /**
459
     * Use {@link #notifyGroupChanged(int)} instead.
460
     *
461
     * @param groupPosition
462
     */
463
    @Deprecated
464
    public void changeGroup(int groupPosition) {
465
        notifyGroupChanged(groupPosition);
466
    }
467
468
    /**
469
     * 通知一组数据刷新,包括组头,组尾和子项
470
     *
471
     * @param groupPosition
472
     */
473
    public void notifyGroupChanged(int groupPosition) {
474
        int index = getPositionForGroup(groupPosition);
475
        int itemCount = countGroupItem(groupPosition);
476
        if (index >= 0 && itemCount > 0) {
477
            notifyItemRangeChanged(index, itemCount);
478
        }
479
    }
480
481
    /**
482
     * Use {@link #notifyGroupRangeChanged(int, int)} instead.
483
     *
484
     * @param groupPosition
485
     * @param count
486
     */
487
    @Deprecated
488
    public void changeRangeGroup(int groupPosition, int count) {
489
        notifyGroupRangeChanged(groupPosition, count);
490
    }
491
492
    /**
493
     * 通知多组数据刷新,包括组头,组尾和子项
494
     *
495
     * @param groupPosition
496
     */
497
    public void notifyGroupRangeChanged(int groupPosition, int count) {
498
        int index = getPositionForGroup(groupPosition);
499
        int itemCount = 0;
500
        if (groupPosition + count <= mStructures.size()) {
501
            itemCount = countGroupRangeItem(groupPosition, groupPosition + count);
502
        } else {
503
            itemCount = countGroupRangeItem(groupPosition, mStructures.size());
504
        }
505
        if (index >= 0 && itemCount > 0) {
506
            notifyItemRangeChanged(index, itemCount);
507
        }
508
    }
509
510
    /**
511
     * Use {@link #notifyHeaderChanged(int)} instead.
512
     *
513
     * @param groupPosition
514
     */
515
    @Deprecated
516
    public void changeHeader(int groupPosition) {
517
        notifyHeaderChanged(groupPosition);
518
    }
519
520
    /**
521
     * 通知组头刷新
522
     *
523
     * @param groupPosition
524
     */
525
    public void notifyHeaderChanged(int groupPosition) {
526
        int index = getPositionForGroupHeader(groupPosition);
527
        if (index >= 0) {
528
            notifyItemChanged(index);
529
        }
530
    }
531
532
    /**
533
     * Use {@link #notifyFooterChanged(int)} instead.
534
     *
535
     * @param groupPosition
536
     */
537
    @Deprecated
538
    public void changeFooter(int groupPosition) {
539
        notifyFooterChanged(groupPosition);
540
    }
541
542
    /**
543
     * 通知组尾刷新
544
     *
545
     * @param groupPosition
546
     */
547
    public void notifyFooterChanged(int groupPosition) {
548
        int index = getPositionForGroupFooter(groupPosition);
549
        if (index >= 0) {
550
            notifyItemChanged(index);
551
        }
552
    }
553
554
    /**
555
     * Use {@link #notifyChildChanged(int, int)} instead.
556
     *
557
     * @param groupPosition
558
     * @param childPosition
559
     */
560
    @Deprecated
561
    public void changeChild(int groupPosition, int childPosition) {
562
        notifyChildChanged(groupPosition, childPosition);
563
    }
564
565
    /**
566
     * 通知一组里的某个子项刷新
567
     *
568
     * @param groupPosition
569
     * @param childPosition
570
     */
571
    public void notifyChildChanged(int groupPosition, int childPosition) {
572
        int index = getPositionForChild(groupPosition, childPosition);
573
        if (index >= 0) {
574
            notifyItemChanged(index);
575
        }
576
    }
577
578
    /**
579
     * Use {@link #notifyChildRangeChanged(int, int, int)} instead.
580
     *
581
     * @param groupPosition
582
     * @param childPosition
583
     * @param count
584
     */
585
    @Deprecated
586
    public void changeRangeChild(int groupPosition, int childPosition, int count) {
587
        notifyChildRangeChanged(groupPosition, childPosition, count);
588
    }
589
590
    /**
591
     * 通知一组里的多个子项刷新
592
     *
593
     * @param groupPosition
594
     * @param childPosition
595
     * @param count
596
     */
597
    public void notifyChildRangeChanged(int groupPosition, int childPosition, int count) {
598
        if (groupPosition < mStructures.size()) {
599
            int index = getPositionForChild(groupPosition, childPosition);
600
            if (index >= 0) {
601
                GroupStructure structure = mStructures.get(groupPosition);
602
                if (structure.getChildrenCount() >= childPosition + count) {
603
                    notifyItemRangeChanged(index, count);
604
                } else {
605
                    notifyItemRangeChanged(index, structure.getChildrenCount() - childPosition);
606
                }
607
            }
608
        }
609
    }
610
611
    /**
612
     * Use {@link #notifyChildrenChanged(int)} instead.
613
     *
614
     * @param groupPosition
615
     */
616
    @Deprecated
617
    public void changeChildren(int groupPosition) {
618
        notifyChildrenChanged(groupPosition);
619
    }
620
621
    /**
622
     * 通知一组里的所有子项刷新
623
     *
624
     * @param groupPosition
625
     */
626
    public void notifyChildrenChanged(int groupPosition) {
627
        if (groupPosition >= 0 && groupPosition < mStructures.size()) {
628
            int index = getPositionForChild(groupPosition, 0);
629
            if (index >= 0) {
630
                GroupStructure structure = mStructures.get(groupPosition);
631
                notifyItemRangeChanged(index, structure.getChildrenCount());
632
            }
633
        }
634
    }
635
636
    //****** 删除操作 *****//
637
638
    /**
639
     * Use {@link #notifyDataRemoved()} instead.
640
     */
641
    @Deprecated
642
    public void removeAll() {
643
        notifyDataRemoved();
644
    }
645
646
    /**
647
     * 通知所有数据删除
648
     */
649
    public void notifyDataRemoved() {
650
        int count = countGroupRangeItem(0, mStructures.size());
651
        mStructures.clear();
652
        notifyItemRangeRemoved(0, count);
653
    }
654
655
    /**
656
     * Use {@link #notifyGroupRemoved(int)} instead.
657
     */
658
    @Deprecated
659
    public void removeGroup(int groupPosition) {
660
        notifyGroupRemoved(groupPosition);
661
    }
662
663
    /**
664
     * 通知一组数据删除,包括组头,组尾和子项
665
     *
666
     * @param groupPosition
667
     */
668
    public void notifyGroupRemoved(int groupPosition) {
669
        int index = getPositionForGroup(groupPosition);
670
        int itemCount = countGroupItem(groupPosition);
671
        if (index >= 0 && itemCount > 0) {
672
            mStructures.remove(groupPosition);
673
            notifyItemRangeRemoved(index, itemCount);
674
        }
675
    }
676
677
    /**
678
     * Use {@link #notifyGroupRangeRemoved(int, int)} instead.
679
     */
680
    @Deprecated
681
    public void removeRangeGroup(int groupPosition, int count) {
682
        notifyGroupRangeRemoved(groupPosition, count);
683
    }
684
685
    /**
686
     * 通知多组数据删除,包括组头,组尾和子项
687
     *
688
     * @param groupPosition
689
     */
690
    public void notifyGroupRangeRemoved(int groupPosition, int count) {
691
        int index = getPositionForGroup(groupPosition);
692
        int itemCount = 0;
693
        if (groupPosition + count <= mStructures.size()) {
694
            itemCount = countGroupRangeItem(groupPosition, groupPosition + count);
695
        } else {
696
            itemCount = countGroupRangeItem(groupPosition, mStructures.size());
697
        }
698
        if (index >= 0 && itemCount > 0) {
699
            mStructures.remove(groupPosition);
700
            notifyItemRangeRemoved(index, itemCount);
701
        }
702
    }
703
704
    /**
705
     * Use {@link #notifyHeaderRemoved(int)} instead.
706
     */
707
    @Deprecated
708
    public void removeHeader(int groupPosition) {
709
        notifyHeaderRemoved(groupPosition);
710
    }
711
712
    /**
713
     * 通知组头删除
714
     *
715
     * @param groupPosition
716
     */
717
    public void notifyHeaderRemoved(int groupPosition) {
718
        int index = getPositionForGroupHeader(groupPosition);
719
        if (index >= 0) {
720
            GroupStructure structure = mStructures.get(groupPosition);
721
            structure.setHasHeader(false);
722
            notifyItemRemoved(index);
723
        }
724
    }
725
726
    /**
727
     * Use {@link #notifyFooterRemoved(int)} instead.
728
     *
729
     * @param groupPosition
730
     */
731
    @Deprecated
732
    public void removeFooter(int groupPosition) {
733
        notifyFooterRemoved(groupPosition);
734
    }
735
736
    /**
737
     * 通知组尾删除
738
     *
739
     * @param groupPosition
740
     */
741
    public void notifyFooterRemoved(int groupPosition) {
742
        int index = getPositionForGroupFooter(groupPosition);
743
        if (index >= 0) {
744
            GroupStructure structure = mStructures.get(groupPosition);
745
            structure.setHasFooter(false);
746
            notifyItemRemoved(index);
747
        }
748
    }
749
750
    /**
751
     * Use {@link #notifyChildRemoved(int, int)} instead.
752
     *
753
     * @param groupPosition
754
     * @param childPosition
755
     */
756
    @Deprecated
757
    public void removeChild(int groupPosition, int childPosition) {
758
        notifyChildRemoved(groupPosition, childPosition);
759
    }
760
761
    /**
762
     * 通知一组里的某个子项删除
763
     *
764
     * @param groupPosition
765
     * @param childPosition
766
     */
767
    public void notifyChildRemoved(int groupPosition, int childPosition) {
768
        int index = getPositionForChild(groupPosition, childPosition);
769
        if (index >= 0) {
770
            GroupStructure structure = mStructures.get(groupPosition);
771
            structure.setChildrenCount(structure.getChildrenCount() - 1);
772
            notifyItemRemoved(index);
773
        }
774
    }
775
776
    /**
777
     * Use {@link #notifyChildRangeRemoved(int, int, int)} instead.
778
     *
779
     * @param groupPosition
780
     * @param childPosition
781
     * @param count
782
     */
783
    @Deprecated
784
    public void removeRangeChild(int groupPosition, int childPosition, int count) {
785
        notifyChildRangeRemoved(groupPosition, childPosition, count);
786
    }
787
788
    /**
789
     * 通知一组里的多个子项删除
790
     *
791
     * @param groupPosition
792
     * @param childPosition
793
     * @param count
794
     */
795
    public void notifyChildRangeRemoved(int groupPosition, int childPosition, int count) {
796
        if (groupPosition < mStructures.size()) {
797
            int index = getPositionForChild(groupPosition, childPosition);
798
            if (index >= 0) {
799
                GroupStructure structure = mStructures.get(groupPosition);
800
                int childCount = structure.getChildrenCount();
801
                int removeCount = count;
802
                if (childCount < childPosition + count) {
803
                    removeCount = childCount - childPosition;
804
                }
805
                structure.setChildrenCount(childCount - removeCount);
806
                notifyItemRangeRemoved(index, removeCount);
807
            }
808
        }
809
    }
810
811
    /**
812
     * Use {@link #notifyChildrenRemoved(int)} instead.
813
     *
814
     * @param groupPosition
815
     */
816
    @Deprecated
817
    public void removeChildren(int groupPosition) {
818
        notifyChildrenRemoved(groupPosition);
819
    }
820
821
    /**
822
     * 通知一组里的所有子项删除
823
     *
824
     * @param groupPosition
825
     */
826
    public void notifyChildrenRemoved(int groupPosition) {
827
        if (groupPosition < mStructures.size()) {
828
            int index = getPositionForChild(groupPosition, 0);
829
            if (index >= 0) {
830
                GroupStructure structure = mStructures.get(groupPosition);
831
                int itemCount = structure.getChildrenCount();
832
                structure.setChildrenCount(0);
833
                notifyItemRangeRemoved(index, itemCount);
834
            }
835
        }
836
    }
837
838
    //****** 插入操作 *****//
839
840
    /**
841
     * Use {@link #notifyGroupInserted(int)} instead.
842
     *
843
     * @param groupPosition
844
     */
845
    @Deprecated
846
    public void insertGroup(int groupPosition) {
847
        notifyGroupInserted(groupPosition);
848
    }
849
850
    /**
851
     * 通知一组数据插入
852
     *
853
     * @param groupPosition
854
     */
855
    public void notifyGroupInserted(int groupPosition) {
856
        GroupStructure structure = new GroupStructure(hasHeader(groupPosition),
857
                hasFooter(groupPosition), getChildrenCount(groupPosition));
858
        if (groupPosition < mStructures.size()) {
859
            mStructures.add(groupPosition, structure);
860
        } else {
861
            mStructures.add(structure);
862
            groupPosition = mStructures.size() - 1;
863
        }
864
865
        int index = countGroupRangeItem(0, groupPosition);
866
        int itemCount = countGroupItem(groupPosition);
867
        if (itemCount > 0) {
868
            notifyItemRangeInserted(index, itemCount);
869
        }
870
    }
871
872
    /**
873
     * Use {@link #notifyGroupRangeInserted(int, int)} instead.
874
     *
875
     * @param groupPosition
876
     * @param count
877
     */
878
    @Deprecated
879
    public void insertRangeGroup(int groupPosition, int count) {
880
        notifyGroupRangeInserted(groupPosition, count);
881
    }
882
883
    /**
884
     * 通知多组数据插入
885
     *
886
     * @param groupPosition
887
     * @param count
888
     */
889
    public void notifyGroupRangeInserted(int groupPosition, int count) {
890
        ArrayList<GroupStructure> list = new ArrayList<>();
891
        for (int i = 0; i < count; i++) {
892
            GroupStructure structure = new GroupStructure(hasHeader(i),
893
                    hasFooter(i), getChildrenCount(i));
894
            list.add(structure);
895
        }
896
897
        if (groupPosition < mStructures.size()) {
898
            mStructures.addAll(groupPosition, list);
899
        } else {
900
            mStructures.addAll(list);
901
            groupPosition = mStructures.size() - list.size();
902
        }
903
904
        int index = countGroupRangeItem(0, groupPosition);
905
        int itemCount = countGroupRangeItem(groupPosition, count);
906
        if (itemCount > 0) {
907
            notifyItemRangeInserted(index, itemCount);
908
        }
909
    }
910
911
    /**
912
     * Use {@link #notifyHeaderInserted(int)} instead.
913
     *
914
     * @param groupPosition
915
     */
916
    @Deprecated
917
    public void insertHeader(int groupPosition) {
918
        notifyHeaderInserted(groupPosition);
919
    }
920
921
    /**
922
     * 通知组头插入
923
     *
924
     * @param groupPosition
925
     */
926
    public void notifyHeaderInserted(int groupPosition) {
927
        if (groupPosition < mStructures.size() && 0 > getPositionForGroupHeader(groupPosition)) {
928
            GroupStructure structure = mStructures.get(groupPosition);
929
            structure.setHasHeader(true);
930
            int index = countGroupRangeItem(0, groupPosition);
931
            notifyItemInserted(index);
932
        }
933
    }
934
935
    /**
936
     * Use {@link #notifyFooterInserted(int)} instead.
937
     *
938
     * @param groupPosition
939
     */
940
    @Deprecated
941
    public void insertFooter(int groupPosition) {
942
        notifyFooterInserted(groupPosition);
943
    }
944
945
    /**
946
     * 通知组尾插入
947
     *
948
     * @param groupPosition
949
     */
950
    public void notifyFooterInserted(int groupPosition) {
951
        if (groupPosition < mStructures.size() && 0 > getPositionForGroupFooter(groupPosition)) {
952
            GroupStructure structure = mStructures.get(groupPosition);
953
            structure.setHasFooter(true);
954
            int index = countGroupRangeItem(0, groupPosition + 1);
955
            notifyItemInserted(index);
956
        }
957
    }
958
959
    /**
960
     * Use {@link #notifyChildInserted(int, int)} instead.
961
     *
962
     * @param groupPosition
963
     * @param childPosition
964
     */
965
    @Deprecated
966
    public void insertChild(int groupPosition, int childPosition) {
967
        notifyChildInserted(groupPosition, childPosition);
968
    }
969
970
    /**
971
     * 通知一个子项到组里插入
972
     *
973
     * @param groupPosition
974
     * @param childPosition
975
     */
976
    public void notifyChildInserted(int groupPosition, int childPosition) {
977
        if (groupPosition < mStructures.size()) {
978
            GroupStructure structure = mStructures.get(groupPosition);
979
            int index = getPositionForChild(groupPosition, childPosition);
980
            if (index < 0) {
981
                index = countGroupRangeItem(0, groupPosition);
982
                index += structure.hasHeader() ? 1 : 0;
983
                index += structure.getChildrenCount();
984
            }
985
            structure.setChildrenCount(structure.getChildrenCount() + 1);
986
            notifyItemInserted(index);
987
        }
988
    }
989
990
    /**
991
     * Use {@link #notifyChildRangeInserted(int, int, int)} instead.
992
     *
993
     * @param groupPosition
994
     * @param childPosition
995
     * @param count
996
     */
997
    @Deprecated
998
    public void insertRangeChild(int groupPosition, int childPosition, int count) {
999
        notifyChildRangeInserted(groupPosition, childPosition, count);
1000
    }
1001
1002
    /**
1003
     * 通知一组里的多个子项插入
1004
     *
1005
     * @param groupPosition
1006
     * @param childPosition
1007
     * @param count
1008
     */
1009
    public void notifyChildRangeInserted(int groupPosition, int childPosition, int count) {
1010
        if (groupPosition < mStructures.size()) {
1011
            int index = countGroupRangeItem(0, groupPosition);
1012
            GroupStructure structure = mStructures.get(groupPosition);
1013
            if (structure.hasHeader()) {
1014
                index++;
1015
            }
1016
            if (childPosition < structure.getChildrenCount()) {
1017
                index += childPosition;
1018
            } else {
1019
                index += structure.getChildrenCount();
1020
            }
1021
            if (count > 0) {
1022
                structure.setChildrenCount(structure.getChildrenCount() + count);
1023
                notifyItemRangeInserted(index, count);
1024
            }
1025
        }
1026
    }
1027
1028
    /**
1029
     * Use {@link #notifyChildrenInserted(int)} instead.
1030
     *
1031
     * @param groupPosition
1032
     */
1033
    @Deprecated
1034
    public void insertChildren(int groupPosition) {
1035
        notifyChildrenInserted(groupPosition);
1036
    }
1037
1038
    /**
1039
     * 通知一组里的所有子项插入
1040
     *
1041
     * @param groupPosition
1042
     */
1043
    public void notifyChildrenInserted(int groupPosition) {
1044
        if (groupPosition < mStructures.size()) {
1045
            int index = countGroupRangeItem(0, groupPosition);
1046
            GroupStructure structure = mStructures.get(groupPosition);
1047
            if (structure.hasHeader()) {
1048
                index++;
1049
            }
1050
            int itemCount = getChildrenCount(groupPosition);
1051
            if (itemCount > 0) {
1052
                structure.setChildrenCount(itemCount);
1053
                notifyItemRangeInserted(index, itemCount);
1054
            }
1055
        }
1056
    }
1057
1058
    //****** 设置点击事件 *****//
1059
1060
    /**
1061
     * 设置组头点击事件
1062
     *
1063
     * @param listener
1064
     */
1065
    public void setOnHeaderClickListener(OnHeaderClickListener listener) {
1066
        mOnHeaderClickListener = listener;
1067
    }
1068
1069
    /**
1070
     * 设置组尾点击事件
1071
     *
1072
     * @param listener
1073
     */
1074
    public void setOnFooterClickListener(OnFooterClickListener listener) {
1075
        mOnFooterClickListener = listener;
1076
    }
1077
1078
    /**
1079
     * 设置子项点击事件
1080
     *
1081
     * @param listener
1082
     */
1083
    public void setOnChildClickListener(OnChildClickListener listener) {
1084
        mOnChildClickListener = listener;
1085
    }
1086
1087
    public abstract int getGroupCount();
1088
1089
    public abstract int getChildrenCount(int groupPosition);
1090
1091
    public abstract boolean hasHeader(int groupPosition);
1092
1093
    public abstract boolean hasFooter(int groupPosition);
1094
1095
    public abstract int getHeaderLayout(int viewType);
1096
1097
    public abstract int getFooterLayout(int viewType);
1098
1099
    public abstract int getChildLayout(int viewType);
1100
1101
    public abstract void onBindHeaderViewHolder(BaseViewHolder holder, int groupPosition);
1102
1103
    public abstract void onBindFooterViewHolder(BaseViewHolder holder, int groupPosition);
1104
1105
    public abstract void onBindChildViewHolder(BaseViewHolder holder,
1106
                                               int groupPosition, int childPosition);
1107
1108
    /**
1109
     * 获取空布局
1110
     * @param parent
1111
     * @return
1112
     */
1113
    public View getEmptyView(ViewGroup parent){
1114
        View view = LayoutInflater.from(mContext).inflate(R.layout.group_adapter_default_empty_view, parent, false);
1115
        return view;
1116
    }
1117
1118
    class GroupDataObserver extends RecyclerView.AdapterDataObserver {
1119
1120
        @Override
1121
        public void onChanged() {
1122
            isDataChanged = true;
1123
        }
1124
1125
        public void onItemRangeChanged(int positionStart, int itemCount) {
1126
            isDataChanged = true;
1127
        }
1128
1129
        public void onItemRangeChanged(int positionStart, int itemCount, Object payload) {
1130
            onItemRangeChanged(positionStart, itemCount);
1131
        }
1132
1133
        public void onItemRangeInserted(int positionStart, int itemCount) {
1134
            isDataChanged = true;
1135
        }
1136
1137
        public void onItemRangeRemoved(int positionStart, int itemCount) {
1138
            isDataChanged = true;
1139
        }
1140
    }
1141
1142
    public interface OnHeaderClickListener {
1143
        void onHeaderClick(GroupedRecyclerViewAdapter adapter, BaseViewHolder holder, int groupPosition);
1144
    }
1145
1146
    public interface OnFooterClickListener {
1147
        void onFooterClick(GroupedRecyclerViewAdapter adapter, BaseViewHolder holder, int groupPosition);
1148
    }
1149
1150
    public interface OnChildClickListener {
1151
        void onChildClick(GroupedRecyclerViewAdapter adapter, BaseViewHolder holder,
1152
                          int groupPosition, int childPosition);
1153
    }
1154
}

+ 126 - 0
app/src/main/java/com/donkingliang/groupedadapter/holder/BaseViewHolder.java

@ -0,0 +1,126 @@
1
package com.donkingliang.groupedadapter.holder;
2
3
import android.graphics.Bitmap;
4
import android.graphics.drawable.Drawable;
5
import android.util.SparseArray;
6
import android.view.View;
7
import android.widget.ImageView;
8
import android.widget.TextView;
9
10
import androidx.databinding.DataBindingUtil;
11
import androidx.databinding.ViewDataBinding;
12
import androidx.recyclerview.widget.RecyclerView;
13
14
/**
15
 * 通用的RecyclerView.ViewHolder。提供了根据viewId获取View的方法。
16
 * 提供了对View、TextView、ImageView的常用设置方法。
17
 */
18
public class BaseViewHolder extends RecyclerView.ViewHolder {
19
20
    private SparseArray<View> mViews;
21
22
    public BaseViewHolder(View itemView) {
23
        super(itemView);
24
        mViews = new SparseArray<>();
25
    }
26
27
    /**
28
     * 获取item对应的ViewDataBinding对象
29
     *
30
     * @param <T>
31
     * @return
32
     */
33
    public <T extends ViewDataBinding> T getBinding() {
34
        return DataBindingUtil.getBinding(this.itemView);
35
    }
36
37
    /**
38
     * 根据View Id 获取对应的View
39
     *
40
     * @param viewId
41
     * @param <T>
42
     * @return
43
     */
44
    public <T extends View> T get(int viewId) {
45
        View view = mViews.get(viewId);
46
        if (view == null) {
47
            view = this.itemView.findViewById(viewId);
48
            mViews.put(viewId, view);
49
        }
50
        return (T) view;
51
    }
52
53
    //******** 提供对View、TextView、ImageView的常用设置方法 ******//
54
55
    public BaseViewHolder setText(int viewId, String text) {
56
        TextView tv = get(viewId);
57
        tv.setText(text);
58
        return this;
59
    }
60
61
    public BaseViewHolder setText(int viewId, int textRes) {
62
        TextView tv = get(viewId);
63
        tv.setText(textRes);
64
        return this;
65
    }
66
67
    public BaseViewHolder setTextColor(int viewId, int textColor) {
68
        TextView view = get(viewId);
69
        view.setTextColor(textColor);
70
        return this;
71
    }
72
73
    public BaseViewHolder setTextSize(int viewId, int size) {
74
        TextView view = get(viewId);
75
        view.setTextSize(size);
76
        return this;
77
    }
78
79
    public BaseViewHolder setImageResource(int viewId, int resId) {
80
        ImageView view = get(viewId);
81
        view.setImageResource(resId);
82
        return this;
83
    }
84
85
    public BaseViewHolder setImageBitmap(int viewId, Bitmap bitmap) {
86
        ImageView view = get(viewId);
87
        view.setImageBitmap(bitmap);
88
        return this;
89
    }
90
91
92
    public BaseViewHolder setImageDrawable(int viewId, Drawable drawable) {
93
        ImageView view = get(viewId);
94
        view.setImageDrawable(drawable);
95
        return this;
96
    }
97
98
99
    public BaseViewHolder setBackgroundColor(int viewId, int color) {
100
        View view = get(viewId);
101
        view.setBackgroundColor(color);
102
        return this;
103
    }
104
105
    public BaseViewHolder setBackgroundRes(int viewId, int backgroundRes) {
106
        View view = get(viewId);
107
        view.setBackgroundResource(backgroundRes);
108
        return this;
109
    }
110
111
    public BaseViewHolder setVisible(int viewId, boolean visible) {
112
        View view = get(viewId);
113
        view.setVisibility(visible ? View.VISIBLE : View.GONE);
114
        return this;
115
    }
116
117
    public BaseViewHolder setVisible(int viewId, int visible) {
118
        View view = get(viewId);
119
        view.setVisibility(visible);
120
        return this;
121
    }
122
123
    public ImageView getImageView(int viewId) {
124
        return get(viewId);
125
    }
126
}

+ 77 - 0
app/src/main/java/com/donkingliang/groupedadapter/layoutmanger/GroupedGridLayoutManager.java

@ -0,0 +1,77 @@
1
package com.donkingliang.groupedadapter.layoutmanger;
2
3
import android.content.Context;
4
import android.util.AttributeSet;
5
6
import com.donkingliang.groupedadapter.adapter.GroupedRecyclerViewAdapter;
7
8
import androidx.recyclerview.widget.GridLayoutManager;
9
10
11
/**
12
 * 为分组列表提供的GridLayoutManager。
13
 * 因为分组列表如果要使用GridLayoutManager实现网格布局。要保证组的头部和尾部是要单独占用一行的。
14
 * 否则组的头、尾可能会跟子项混着一起,造成布局混乱。
15
 */
16
public class GroupedGridLayoutManager extends GridLayoutManager {
17
18
    private GroupedRecyclerViewAdapter mAdapter;
19
20
    public GroupedGridLayoutManager(Context context, int spanCount,
21
                                    GroupedRecyclerViewAdapter adapter) {
22
        super(context, spanCount);
23
        mAdapter = adapter;
24
        setSpanSizeLookup();
25
    }
26
27
    public GroupedGridLayoutManager(Context context, int spanCount, int orientation,
28
                                    boolean reverseLayout, GroupedRecyclerViewAdapter adapter) {
29
        super(context, spanCount, orientation, reverseLayout);
30
        this.mAdapter = adapter;
31
        setSpanSizeLookup();
32
    }
33
34
    public GroupedGridLayoutManager(Context context, AttributeSet attrs, int defStyleAttr,
35
                                    int defStyleRes, GroupedRecyclerViewAdapter adapter) {
36
        super(context, attrs, defStyleAttr, defStyleRes);
37
        this.mAdapter = adapter;
38
        setSpanSizeLookup();
39
    }
40
41
    private void setSpanSizeLookup() {
42
        super.setSpanSizeLookup(new SpanSizeLookup() {
43
            @Override
44
            public int getSpanSize(int position) {
45
                int count = getSpanCount();
46
                if (mAdapter != null) {
47
                    int type = mAdapter.judgeType(position);
48
                    //只对子项做Grid效果
49
                    if (type == GroupedRecyclerViewAdapter.TYPE_CHILD) {
50
                        int groupPosition = mAdapter.getGroupPositionForPosition(position);
51
                        int childPosition =
52
                                mAdapter.getChildPositionForPosition(groupPosition, position);
53
                        return getChildSpanSize(groupPosition, childPosition);
54
                    }
55
                }
56
57
                return count;
58
            }
59
        });
60
    }
61
62
    /**
63
     * 提供这个方法可以使外部改变子项的SpanSize。
64
     * 这个方法的作用跟{@link SpanSizeLookup#getSpanSize(int)}一样。
65
     * @param groupPosition
66
     * @param childPosition
67
     * @return
68
     */
69
    public int getChildSpanSize(int groupPosition, int childPosition) {
70
        return 1;
71
    }
72
73
    @Override
74
    public void setSpanSizeLookup(SpanSizeLookup spanSizeLookup) {
75
76
    }
77
}

+ 43 - 0
app/src/main/java/com/donkingliang/groupedadapter/structure/GroupStructure.java

@ -0,0 +1,43 @@
1
package com.donkingliang.groupedadapter.structure;
2
3
/**
4
 * 这个类是用来记录分组列表中组的结构的。
5
 * 通过GroupStructure记录每个组是否有头部,是否有尾部和子项的数量。从而能方便的计算
6
 * 列表的长度和每个组的组头、组尾和子项在列表中的位置。
7
 */
8
public class GroupStructure {
9
10
    private boolean hasHeader;
11
    private boolean hasFooter;
12
    private int childrenCount;
13
14
    public GroupStructure(boolean hasHeader, boolean hasFooter, int childrenCount) {
15
        this.hasHeader = hasHeader;
16
        this.hasFooter = hasFooter;
17
        this.childrenCount = childrenCount;
18
    }
19
20
    public boolean hasHeader() {
21
        return hasHeader;
22
    }
23
24
    public void setHasHeader(boolean hasHeader) {
25
        this.hasHeader = hasHeader;
26
    }
27
28
    public boolean hasFooter() {
29
        return hasFooter;
30
    }
31
32
    public void setHasFooter(boolean hasFooter) {
33
        this.hasFooter = hasFooter;
34
    }
35
36
    public int getChildrenCount() {
37
        return childrenCount;
38
    }
39
40
    public void setChildrenCount(int childrenCount) {
41
        this.childrenCount = childrenCount;
42
    }
43
}

+ 439 - 0
app/src/main/java/com/donkingliang/groupedadapter/widget/StickyHeaderLayout.java

@ -0,0 +1,439 @@
1
package com.donkingliang.groupedadapter.widget;
2
3
import android.content.Context;
4
import android.util.AttributeSet;
5
import android.util.SparseArray;
6
import android.view.View;
7
import android.view.ViewGroup;
8
import android.widget.FrameLayout;
9
10
import com.donkingliang.groupedadapter.adapter.GroupedRecyclerViewAdapter;
11
import com.donkingliang.groupedadapter.holder.BaseViewHolder;
12
13
import java.lang.reflect.Method;
14
15
import androidx.annotation.AttrRes;
16
import androidx.annotation.NonNull;
17
import androidx.annotation.Nullable;
18
import androidx.recyclerview.widget.GridLayoutManager;
19
import androidx.recyclerview.widget.LinearLayoutManager;
20
import androidx.recyclerview.widget.RecyclerView;
21
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
22
23
/**
24
 * Depiction:头部吸顶布局。只要用StickyHeaderLayout包裹{@link RecyclerView},
25
 * 并且使用{@link GroupedRecyclerViewAdapter},就可以实现列表头部吸顶功能。
26
 * StickyHeaderLayout只能包裹RecyclerView,而且只能包裹一个RecyclerView。
27
 * <p>
28
 * Author:donkingliang  QQ:1043214265
29
 * Dat:2017/11/14
30
 */
31
public class StickyHeaderLayout extends FrameLayout {
32
33
    private Context mContext;
34
    private RecyclerView mRecyclerView;
35
36
    //吸顶容器,用于承载吸顶布局。
37
    private FrameLayout mStickyLayout;
38
39
    //保存吸顶布局的缓存池。它以列表组头的viewType为key,ViewHolder为value对吸顶布局进行保存和回收复用。
40
    private final SparseArray<BaseViewHolder> mStickyViews = new SparseArray<>();
41
42
    //用于在吸顶布局中保存viewType的key。
43
    private final int VIEW_TAG_TYPE = -101;
44
45
    //用于在吸顶布局中保存ViewHolder的key。
46
    private final int VIEW_TAG_HOLDER = -102;
47
48
    //记录当前吸顶的组。
49
    private int mCurrentStickyGroup = -1;
50
51
    //是否吸顶。
52
    private boolean isSticky = true;
53
54
    //是否已经注册了adapter刷新监听
55
    private boolean isRegisterDataObserver = false;
56
57
    public StickyHeaderLayout(@NonNull Context context) {
58
        super(context);
59
        mContext = context;
60
    }
61
62
    public StickyHeaderLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
63
        super(context, attrs);
64
        mContext = context;
65
    }
66
67
    public StickyHeaderLayout(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
68
        super(context, attrs, defStyleAttr);
69
        mContext = context;
70
    }
71
72
    @Override
73
    public void addView(View child, int index, ViewGroup.LayoutParams params) {
74
        if (getChildCount() > 0 || !(child instanceof RecyclerView)) {
75
            //外界只能向StickyHeaderLayout添加一个RecyclerView,而且只能添加RecyclerView。
76
            throw new IllegalArgumentException("StickyHeaderLayout can host only one direct child --> RecyclerView");
77
        }
78
        super.addView(child, index, params);
79
        mRecyclerView = (RecyclerView) child;
80
        addOnScrollListener();
81
        addStickyLayout();
82
    }
83
84
    /**
85
     * 添加滚动监听
86
     */
87
    private void addOnScrollListener() {
88
        mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
89
            @Override
90
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
91
                // 在滚动的时候,需要不断的更新吸顶布局。
92
                if (isSticky) {
93
                    updateStickyView(false);
94
                }
95
            }
96
        });
97
    }
98
99
    /**
100
     * 添加吸顶容器
101
     */
102
    private void addStickyLayout() {
103
        mStickyLayout = new FrameLayout(mContext);
104
        LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT,
105
                LayoutParams.WRAP_CONTENT);
106
        mStickyLayout.setLayoutParams(lp);
107
        super.addView(mStickyLayout, 1, lp);
108
    }
109
110
    /**
111
     * 强制更新吸顶布局。
112
     */
113
    public void updateStickyView() {
114
        updateStickyView(true);
115
    }
116
117
    /**
118
     * 更新吸顶布局。
119
     *
120
     * @param imperative 是否强制更新。
121
     */
122
    private void updateStickyView(boolean imperative) {
123
        RecyclerView.Adapter adapter = mRecyclerView.getAdapter();
124
        //只有RecyclerView的adapter是GroupedRecyclerViewAdapter的时候,才会添加吸顶布局。
125
        if (adapter instanceof GroupedRecyclerViewAdapter) {
126
            GroupedRecyclerViewAdapter gAdapter = (GroupedRecyclerViewAdapter) adapter;
127
            registerAdapterDataObserver(gAdapter);
128
            //获取列表显示的第一个项。
129
            int firstVisibleItem = getFirstVisibleItem();
130
            //通过显示的第一个项的position获取它所在的组。
131
            int groupPosition = gAdapter.getGroupPositionForPosition(firstVisibleItem);
132
133
            //如果当前吸顶的组头不是我们要吸顶的组头,就更新吸顶布局。这样做可以避免频繁的更新吸顶布局。
134
            if (imperative || mCurrentStickyGroup != groupPosition) {
135
                mCurrentStickyGroup = groupPosition;
136
                if (stickyHeaderPositionListener != null) {
137
                    stickyHeaderPositionListener.onHeaderPositionChange(mCurrentStickyGroup);
138
                }
139
                //通过groupPosition获取当前组的组头position。这个组头就是我们需要吸顶的布局。
140
                int groupHeaderPosition = gAdapter.getPositionForGroupHeader(groupPosition);
141
                if (groupHeaderPosition != -1) {
142
                    //获取吸顶布局的viewType。
143
                    int viewType = gAdapter.getItemViewType(groupHeaderPosition);
144
145
                    //如果当前的吸顶布局的类型和我们需要的一样,就直接获取它的ViewHolder,否则就回收。
146
                    BaseViewHolder holder = recycleStickyView(viewType);
147
148
                    //标志holder是否是从当前吸顶布局取出来的。
149
                    boolean flag = holder != null;
150
151
                    if (holder == null) {
152
                        //从缓存池中获取吸顶布局。
153
                        holder = getStickyViewByType(viewType);
154
                    }
155
156
                    if (holder == null) {
157
                        //如果没有从缓存池中获取到吸顶布局,则通过GroupedRecyclerViewAdapter创建。
158
                        holder = (BaseViewHolder) gAdapter.onCreateViewHolder(mStickyLayout, viewType);
159
                        holder.itemView.setTag(VIEW_TAG_TYPE, viewType);
160
                        holder.itemView.setTag(VIEW_TAG_HOLDER, holder);
161
                    }
162
163
                    //通过GroupedRecyclerViewAdapter更新吸顶布局的数据。
164
                    //这样可以保证吸顶布局的显示效果跟列表中的组头保持一致。
165
                    gAdapter.onBindViewHolder(holder, groupHeaderPosition);
166
167
                    //如果holder不是从当前吸顶布局取出来的,就需要把吸顶布局添加到容器里。
168
                    if (!flag) {
169
                        mStickyLayout.addView(holder.itemView);
170
                    }
171
                } else {
172
                    //如果当前组没有组头,则不显示吸顶布局。
173
                    //回收旧的吸顶布局。
174
                    recycle();
175
                }
176
            }
177
178
            //这是是处理第一次打开时,吸顶布局已经添加到StickyLayout,但StickyLayout的高依然为0的情况。
179
            if (mStickyLayout.getChildCount() > 0 && mStickyLayout.getHeight() == 0) {
180
                mStickyLayout.requestLayout();
181
            }
182
183
            //设置mStickyLayout的Y偏移量。
184
            mStickyLayout.setTranslationY(calculateOffset(gAdapter, firstVisibleItem, groupPosition + 1));
185
        }
186
    }
187
188
    /**
189
     * 注册adapter刷新监听
190
     */
191
    private void registerAdapterDataObserver(GroupedRecyclerViewAdapter adapter) {
192
        if (!isRegisterDataObserver) {
193
            isRegisterDataObserver = true;
194
            adapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
195
                @Override
196
                public void onChanged() {
197
                    updateStickyViewDelayed();
198
                }
199
200
                @Override
201
                public void onItemRangeChanged(int positionStart, int itemCount) {
202
                    updateStickyViewDelayed();
203
                }
204
205
                @Override
206
                public void onItemRangeInserted(int positionStart, int itemCount) {
207
                    updateStickyViewDelayed();
208
                }
209
210
                @Override
211
                public void onItemRangeRemoved(int positionStart, int itemCount) {
212
                    updateStickyViewDelayed();
213
                }
214
215
            });
216
        }
217
    }
218
219
    private void updateStickyViewDelayed() {
220
        postDelayed(new Runnable() {
221
            @Override
222
            public void run() {
223
                updateStickyView(true);
224
            }
225
        }, 64);
226
    }
227
228
    /**
229
     * 判断是否需要先回收吸顶布局,如果要回收,则回收吸顶布局并返回null。
230
     * 如果不回收,则返回吸顶布局的ViewHolder。
231
     * 这样做可以避免频繁的添加和移除吸顶布局。
232
     *
233
     * @param viewType
234
     * @return
235
     */
236
    private BaseViewHolder recycleStickyView(int viewType) {
237
        if (mStickyLayout.getChildCount() > 0) {
238
            View view = mStickyLayout.getChildAt(0);
239
            int type = (int) view.getTag(VIEW_TAG_TYPE);
240
            if (type == viewType) {
241
                return (BaseViewHolder) view.getTag(VIEW_TAG_HOLDER);
242
            } else {
243
                recycle();
244
            }
245
        }
246
        return null;
247
    }
248
249
    /**
250
     * 回收并移除吸顶布局
251
     */
252
    private void recycle() {
253
        if (mStickyLayout.getChildCount() > 0) {
254
            View view = mStickyLayout.getChildAt(0);
255
            mStickyViews.put((int) (view.getTag(VIEW_TAG_TYPE)),
256
                    (BaseViewHolder) (view.getTag(VIEW_TAG_HOLDER)));
257
            mStickyLayout.removeAllViews();
258
        }
259
    }
260
261
    /**
262
     * 从缓存池中获取吸顶布局
263
     *
264
     * @param viewType 吸顶布局的viewType
265
     * @return
266
     */
267
    private BaseViewHolder getStickyViewByType(int viewType) {
268
        return mStickyViews.get(viewType);
269
    }
270
271
    /**
272
     * 计算StickyLayout的偏移量。因为如果下一个组的组头顶到了StickyLayout,
273
     * 就要把StickyLayout顶上去,直到下一个组的组头变成吸顶布局。否则会发生两个组头重叠的情况。
274
     *
275
     * @param gAdapter
276
     * @param firstVisibleItem 当前列表显示的第一个项。
277
     * @param groupPosition    下一个组的组下标。
278
     * @return 返回偏移量。
279
     */
280
    private float calculateOffset(GroupedRecyclerViewAdapter gAdapter, int firstVisibleItem, int groupPosition) {
281
        int groupHeaderPosition = gAdapter.getPositionForGroupHeader(groupPosition);
282
        if (groupHeaderPosition != -1) {
283
            int index = groupHeaderPosition - firstVisibleItem;
284
            if (mRecyclerView.getChildCount() > index) {
285
                //获取下一个组的组头的itemView。
286
                View view = mRecyclerView.getChildAt(index);
287
                float off = view.getY() - mStickyLayout.getHeight();
288
                if (off < 0) {
289
                    return off;
290
                }
291
            }
292
        }
293
        return 0;
294
    }
295
296
    /**
297
     * 获取当前第一个显示的item .
298
     */
299
    private int getFirstVisibleItem() {
300
        int firstVisibleItem = -1;
301
        RecyclerView.LayoutManager layout = mRecyclerView.getLayoutManager();
302
        if (layout != null) {
303
            if (layout instanceof GridLayoutManager) {
304
                firstVisibleItem = ((GridLayoutManager) layout).findFirstVisibleItemPosition();
305
            } else if (layout instanceof LinearLayoutManager) {
306
                firstVisibleItem = ((LinearLayoutManager) layout).findFirstVisibleItemPosition();
307
            } else if (layout instanceof StaggeredGridLayoutManager) {
308
                int[] firstPositions = new int[((StaggeredGridLayoutManager) layout).getSpanCount()];
309
                ((StaggeredGridLayoutManager) layout).findFirstVisibleItemPositions(firstPositions);
310
                firstVisibleItem = getMin(firstPositions);
311
            }
312
        }
313
        return firstVisibleItem;
314
    }
315
316
    private int getMin(int[] arr) {
317
        int min = arr[0];
318
        for (int x = 1; x < arr.length; x++) {
319
            if (arr[x] < min)
320
                min = arr[x];
321
        }
322
        return min;
323
    }
324
325
    /**
326
     * 是否吸顶
327
     *
328
     * @return
329
     */
330
    public boolean isSticky() {
331
        return isSticky;
332
    }
333
334
    /**
335
     * 设置是否吸顶。
336
     *
337
     * @param sticky
338
     */
339
    public void setSticky(boolean sticky) {
340
        if (isSticky != sticky) {
341
            isSticky = sticky;
342
            if (mStickyLayout != null) {
343
                if (isSticky) {
344
                    mStickyLayout.setVisibility(VISIBLE);
345
                    updateStickyView(false);
346
                } else {
347
                    recycle();
348
                    mStickyLayout.setVisibility(GONE);
349
                }
350
            }
351
        }
352
    }
353
354
    @Override
355
    protected int computeVerticalScrollOffset() {
356
        if (mRecyclerView != null) {
357
            try {
358
                Method method = View.class.getDeclaredMethod("computeVerticalScrollOffset");
359
                method.setAccessible(true);
360
                return (int) method.invoke(mRecyclerView);
361
            } catch (Exception e) {
362
                e.printStackTrace();
363
            }
364
        }
365
        return super.computeVerticalScrollOffset();
366
    }
367
368
369
    @Override
370
    protected int computeVerticalScrollRange() {
371
        if (mRecyclerView != null) {
372
            try {
373
                Method method = View.class.getDeclaredMethod("computeVerticalScrollRange");
374
                method.setAccessible(true);
375
                return (int) method.invoke(mRecyclerView);
376
            } catch (Exception e) {
377
                e.printStackTrace();
378
            }
379
        }
380
        return super.computeVerticalScrollRange();
381
    }
382
383
    @Override
384
    protected int computeVerticalScrollExtent() {
385
        if (mRecyclerView != null) {
386
            try {
387
                Method method = View.class.getDeclaredMethod("computeVerticalScrollExtent");
388
                method.setAccessible(true);
389
                return (int) method.invoke(mRecyclerView);
390
            } catch (Exception e) {
391
                e.printStackTrace();
392
            }
393
        }
394
        return super.computeVerticalScrollExtent();
395
    }
396
397
    @Override
398
    public void scrollBy(int x, int y) {
399
        if (mRecyclerView != null) {
400
            mRecyclerView.scrollBy(x, y);
401
        } else {
402
            super.scrollBy(x, y);
403
        }
404
    }
405
406
    @Override
407
    public void scrollTo(int x, int y) {
408
        if (mRecyclerView != null) {
409
            mRecyclerView.scrollTo(x, y);
410
        } else {
411
            super.scrollTo(x, y);
412
        }
413
    }
414
415
    private StickyHeaderPositionListener stickyHeaderPositionListener;
416
417
    /**
418
     * 添加监听,监控头部视图滑动到顶部对应的头部视图的position
419
     * add by huyuguo
420
     */
421
    public void setStickyHeaderPositionListener(StickyHeaderPositionListener listener) {
422
        stickyHeaderPositionListener = listener;
423
    }
424
425
    /**
426
     * 滑动到指定位置
427
     * https://blog.csdn.net/shanshan_1117/article/details/78780137
428
     * @param position
429
     */
430
    public void scrollToPosition(int position) {
431
        if (mRecyclerView != null) {
432
            mRecyclerView.scrollToPosition(position);
433
            LinearLayoutManager linearLayoutManager = (LinearLayoutManager) mRecyclerView.getLayoutManager();
434
            linearLayoutManager.scrollToPositionWithOffset(position, 0);
435
            updateStickyView();
436
        }
437
    }
438
439
}

+ 5 - 0
app/src/main/java/com/donkingliang/groupedadapter/widget/StickyHeaderPositionListener.java

@ -0,0 +1,5 @@
1
package com.donkingliang.groupedadapter.widget;
2
3
public interface StickyHeaderPositionListener {
4
    public void onHeaderPositionChange(int groupPosition);
5
}

+ 120 - 0
app/src/main/java/com/electric/chargingpile/activity/CarBrandActivity.java

@ -0,0 +1,120 @@
1
package com.electric.chargingpile.activity;
2
3
import androidx.appcompat.app.AppCompatActivity;
4
import androidx.recyclerview.widget.LinearLayoutManager;
5
import androidx.recyclerview.widget.RecyclerView;
6
7
import android.content.Intent;
8
import android.os.Bundle;
9
import android.view.View;
10
import android.widget.TextView;
11
12
import com.donkingliang.groupedadapter.adapter.GroupedRecyclerViewAdapter;
13
import com.donkingliang.groupedadapter.holder.BaseViewHolder;
14
import com.donkingliang.groupedadapter.widget.StickyHeaderLayout;
15
import com.donkingliang.groupedadapter.widget.StickyHeaderPositionListener;
16
import com.electric.chargingpile.R;
17
import com.electric.chargingpile.adapter.CarBrandGroupedListAdapter;
18
import com.electric.chargingpile.entity.CarBrandGroupEntity;
19
import com.electric.chargingpile.entity.CarCompanyEntity;
20
import com.electric.chargingpile.event.CarBrandEvent;
21
import com.electric.chargingpile.event.CarCompanyEvent;
22
import com.electric.chargingpile.util.BarColorUtil;
23
import com.electric.chargingpile.view.LetterSideView;
24
25
import org.greenrobot.eventbus.EventBus;
26
27
import java.util.ArrayList;
28
29
public class CarBrandActivity extends AppCompatActivity implements View.OnClickListener {
30
31
    private LetterSideView letter_side_view;
32
    private TextView text_view_dialog;
33
    private StickyHeaderLayout sticky_header_layout;
34
    private RecyclerView recycler_view;
35
    private CarBrandGroupedListAdapter adapter;
36
    private ArrayList<CarBrandGroupEntity> groups;
37
38
    @Override
39
    protected void onCreate(Bundle savedInstanceState) {
40
        super.onCreate(savedInstanceState);
41
        setContentView(R.layout.activity_car_brand);
42
        BarColorUtil.initStatusBarColor(CarBrandActivity.this);
43
        initViews();
44
    }
45
46
    private void initViews() {
47
48
        CarBrandEvent event = EventBus.getDefault().removeStickyEvent(CarBrandEvent.class);
49
        if (event != null) {
50
            groups = event.getGroups();
51
        }
52
53
        findViewById(R.id.iv_back).setOnClickListener(this::onClick);
54
        letter_side_view = findViewById(R.id.letter_side_view);
55
        text_view_dialog = findViewById(R.id.text_view_dialog);
56
        letter_side_view.setTextView(text_view_dialog);
57
        letter_side_view.setOnTouchLetterChangedListener(new LetterSideView.OnTouchLetterChangedListener() {
58
            @Override
59
            public void onTouchLetterChanged(String s) {
60
61
            }
62
63
            @Override
64
            public void onTouchLetterPosition(int position) {
65
                int count = 0;
66
                for (int i = 0; i < groups.size(); i++) {
67
                    if (i < position) {
68
                        count += groups.get(i).getBrandList().size();
69
                    } else {
70
                        break;
71
                    }
72
                }
73
                count += position;
74
                sticky_header_layout.scrollToPosition(count);
75
            }
76
        });
77
78
        String[] letters = new String[groups.size()];
79
        for (int i = 0; i < groups.size(); i++) {
80
            letters[i] = groups.get(i).getInitial();
81
        }
82
        LetterSideView.letters = letters;
83
        letter_side_view.setVisibility(View.VISIBLE);
84
85
        recycler_view = (RecyclerView) findViewById(R.id.recycler_view);
86
        sticky_header_layout = (StickyHeaderLayout) findViewById(R.id.sticky_header_layout);
87
88
        recycler_view.setLayoutManager(new LinearLayoutManager(this));
89
        adapter = new CarBrandGroupedListAdapter(this, groups);
90
        adapter.setOnChildClickListener(new GroupedRecyclerViewAdapter.OnChildClickListener() {
91
            @Override
92
            public void onChildClick(GroupedRecyclerViewAdapter adapter, BaseViewHolder holder, int groupPosition, int childPosition) {
93
                ArrayList<CarCompanyEntity> companyList = groups.get(groupPosition).getBrandList().get(childPosition).getCompanyList();
94
                EventBus.getDefault().postSticky(new CarCompanyEvent(companyList));
95
                startActivity(new Intent(CarBrandActivity.this, CarModelActivity.class));
96
            }
97
        });
98
99
        recycler_view.setAdapter(adapter);
100
        // 设置是否吸顶。
101
        sticky_header_layout.setSticky(true);
102
        // 头部滑动到视图顶部时,监听头部对应的groupPosition
103
        sticky_header_layout.setStickyHeaderPositionListener(new StickyHeaderPositionListener() {
104
            @Override
105
            public void onHeaderPositionChange(int groupPosition) {
106
                letter_side_view.setPosition(groupPosition);
107
            }
108
        });
109
110
    }
111
112
    @Override
113
    public void onClick(View v) {
114
        switch (v.getId()) {
115
            case R.id.iv_back:
116
                finish();
117
                break;
118
        }
119
    }
120
}

+ 75 - 0
app/src/main/java/com/electric/chargingpile/activity/CarModelActivity.java

@ -0,0 +1,75 @@
1
package com.electric.chargingpile.activity;
2
3
import androidx.appcompat.app.AppCompatActivity;
4
import androidx.recyclerview.widget.LinearLayoutManager;
5
import androidx.recyclerview.widget.RecyclerView;
6
7
import android.content.Intent;
8
import android.os.Bundle;
9
import android.view.View;
10
11
import com.donkingliang.groupedadapter.adapter.GroupedRecyclerViewAdapter;
12
import com.donkingliang.groupedadapter.holder.BaseViewHolder;
13
import com.donkingliang.groupedadapter.widget.StickyHeaderLayout;
14
import com.electric.chargingpile.R;
15
import com.electric.chargingpile.adapter.CarModelGroupedListAdapter;
16
import com.electric.chargingpile.entity.CarCompanyEntity;
17
import com.electric.chargingpile.entity.CarSeriesEntity;
18
import com.electric.chargingpile.event.CarCompanyEvent;
19
import com.electric.chargingpile.event.CarSerieEvent;
20
import com.electric.chargingpile.util.BarColorUtil;
21
22
import org.greenrobot.eventbus.EventBus;
23
24
import java.util.ArrayList;
25
26
public class CarModelActivity extends AppCompatActivity implements View.OnClickListener {
27
28
    private RecyclerView recycler_view;
29
    private StickyHeaderLayout sticky_header_layout;
30
    private CarModelGroupedListAdapter adapter;
31
    private ArrayList<CarCompanyEntity> companyList;
32
33
    @Override
34
    protected void onCreate(Bundle savedInstanceState) {
35
        super.onCreate(savedInstanceState);
36
        setContentView(R.layout.activity_car_model);
37
        BarColorUtil.initStatusBarColor(CarModelActivity.this);
38
        initViews();
39
    }
40
41
    private void initViews() {
42
        findViewById(R.id.nav_bar).setOnClickListener(this::onClick);
43
        CarCompanyEvent event = EventBus.getDefault().removeStickyEvent(CarCompanyEvent.class);
44
        if (event != null) {
45
            companyList = event.getCompanyList();
46
        }
47
48
        recycler_view = (RecyclerView) findViewById(R.id.recycler_view);
49
        sticky_header_layout = (StickyHeaderLayout) findViewById(R.id.sticky_header_layout);
50
51
        recycler_view.setLayoutManager(new LinearLayoutManager(this));
52
        adapter = new CarModelGroupedListAdapter(this, companyList);
53
        adapter.setOnChildClickListener(new GroupedRecyclerViewAdapter.OnChildClickListener() {
54
            @Override
55
            public void onChildClick(GroupedRecyclerViewAdapter adapter, BaseViewHolder holder, int groupPosition, int childPosition) {
56
                CarSeriesEntity carSeriesEntity = companyList.get(groupPosition).getSerieslist().get(childPosition);
57
                EventBus.getDefault().post(new CarSerieEvent(carSeriesEntity));
58
                startActivity(new Intent(CarModelActivity.this, CarOwnerCertificateActivity.class));
59
            }
60
        });
61
62
        recycler_view.setAdapter(adapter);
63
        // 设置是否吸顶。
64
        sticky_header_layout.setSticky(true);
65
    }
66
67
    @Override
68
    public void onClick(View v) {
69
        switch (v.getId()) {
70
            case R.id.nav_bar:
71
                finish();
72
                break;
73
        }
74
    }
75
}

+ 385 - 0
app/src/main/java/com/electric/chargingpile/activity/CarOwnerCertificateActivity.java

@ -0,0 +1,385 @@
1
package com.electric.chargingpile.activity;
2
3
import androidx.appcompat.app.AppCompatActivity;
4
import androidx.constraintlayout.widget.ConstraintLayout;
5
6
import android.app.ProgressDialog;
7
import android.content.Intent;
8
import android.graphics.Bitmap;
9
import android.graphics.BitmapFactory;
10
import android.graphics.Matrix;
11
import android.graphics.drawable.Drawable;
12
import android.net.Uri;
13
import android.os.Bundle;
14
import android.view.View;
15
import android.view.WindowManager;
16
import android.widget.Button;
17
import android.widget.ImageView;
18
import android.widget.TextView;
19
import android.widget.Toast;
20
21
import com.bumptech.glide.Glide;
22
import com.electric.chargingpile.R;
23
import com.electric.chargingpile.entity.CarBrandGroupEntity;
24
import com.electric.chargingpile.entity.CarSeriesEntity;
25
import com.electric.chargingpile.event.CarBrandEvent;
26
import com.electric.chargingpile.event.CarSerieEvent;
27
import com.electric.chargingpile.util.BarColorUtil;
28
import com.electric.chargingpile.util.FileUtils;
29
import com.electric.chargingpile.util.JsonUtils;
30
import com.electric.chargingpile.util.LoadingDialog;
31
import com.electric.chargingpile.util.ToastUtil;
32
import com.electric.chargingpile.view.TextImageView;
33
import com.electric.chargingpile.view.xrichtext.SDCardUtil;
34
import com.google.gson.Gson;
35
import com.google.gson.reflect.TypeToken;
36
import com.zhihu.matisse.Matisse;
37
import com.zhihu.matisse.MimeType;
38
import com.zhihu.matisse.engine.impl.GlideEngine;
39
import com.zhihu.matisse.internal.entity.CaptureStrategy;
40
import com.zhy.http.okhttp.OkHttpUtils;
41
import com.zhy.http.okhttp.callback.StringCallback;
42
43
import org.greenrobot.eventbus.EventBus;
44
import org.greenrobot.eventbus.Subscribe;
45
import org.greenrobot.eventbus.ThreadMode;
46
47
import java.io.ByteArrayOutputStream;
48
import java.io.File;
49
import java.util.ArrayList;
50
import java.util.List;
51
52
import io.reactivex.Observable;
53
import io.reactivex.ObservableEmitter;
54
import io.reactivex.ObservableOnSubscribe;
55
import io.reactivex.Observer;
56
import io.reactivex.android.schedulers.AndroidSchedulers;
57
import io.reactivex.disposables.Disposable;
58
import io.reactivex.schedulers.Schedulers;
59
import okhttp3.Call;
60
61
/**
62
 * 车主认证
63
 */
64
65
public class CarOwnerCertificateActivity extends AppCompatActivity implements View.OnClickListener {
66
67
    private static final int RC_ALBUM_PERM = 123;
68
    private static final int REQUEST_CODE_CHOOSE = 342;
69
    private Bitmap insertBitmap;
70
    private String u_path = "";
71
    private int drivingLicenseType = 1;
72
    private ProgressDialog insertDialog;
73
74
    private TextView nav_title;
75
    private Button submit_btn;
76
    private TextImageView driving_license_type_first;
77
    private TextImageView driving_license_type_second;
78
    private TextImageView driving_license_type_third;
79
    private TextView add_car_model_btn;
80
    private LoadingDialog loadDialog;
81
    private ArrayList<CarBrandGroupEntity> groups;
82
    private CarSeriesEntity carSeriesEntity;
83
    private ConstraintLayout car_model_constraint_layout;
84
    private ConstraintLayout car_model_selected_constraint_layout;
85
    private ImageView car_icon;
86
    private TextView car_name;
87
    private TextView car_series;
88
    private ConstraintLayout driving_license;
89
    private ImageView driving_license_icon;
90
    private ImageView driving_license_upload_icon;
91
    private TextView driving_license_text_view;
92
    private Drawable selected;
93
    private Drawable normal;
94
95
    @Override
96
    protected void onCreate(Bundle savedInstanceState) {
97
        super.onCreate(savedInstanceState);
98
        // 禁止顶部固定部分滑动
99
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
100
        setContentView(R.layout.activity_car_owner_certificate);
101
        BarColorUtil.initStatusBarColor(CarOwnerCertificateActivity.this);
102
        initViews();
103
        brandListRequest(false);
104
        add_car_model_btn.setVisibility(View.GONE);
105
        EventBus.getDefault().register(this);
106
    }
107
108
    private void initViews() {
109
        loadDialog = new LoadingDialog(this);
110
        loadDialog.setCanceledOnTouchOutside(false);
111
112
        insertDialog = new ProgressDialog(this);
113
        insertDialog.setMessage("正在插入图片...");
114
        insertDialog.setCanceledOnTouchOutside(false);
115
116
        nav_title = findViewById(R.id.nav_title);
117
        findViewById(R.id.iv_back).setOnClickListener(new View.OnClickListener() {
118
            @Override
119
            public void onClick(View v) {
120
                finish();
121
            }
122
        });
123
124
        add_car_model_btn = findViewById(R.id.add_car_model_btn);
125
        car_model_constraint_layout = findViewById(R.id.car_model_constraint_layout);
126
        car_model_selected_constraint_layout = findViewById(R.id.car_model_selected_constraint_layout);
127
        add_car_model_btn.setOnClickListener(this);
128
        car_model_selected_constraint_layout.setOnClickListener(this);
129
130
        car_icon = findViewById(R.id.car_icon);
131
        car_name = findViewById(R.id.car_name);
132
        car_series = findViewById(R.id.car_series);
133
134
        driving_license = findViewById(R.id.driving_license);
135
        driving_license.setOnClickListener(this);
136
        driving_license_icon = findViewById(R.id.driving_license_icon);
137
        driving_license_upload_icon = findViewById(R.id.driving_license_upload_icon);
138
        driving_license_text_view = findViewById(R.id.driving_license_text_view);
139
140
141
        driving_license_type_first = findViewById(R.id.driving_license_type_first);
142
        driving_license_type_second = findViewById(R.id.driving_license_type_second);
143
        driving_license_type_third = findViewById(R.id.driving_license_type_third);
144
        driving_license_type_first.setOnClickListener(this);
145
        driving_license_type_second.setOnClickListener(this);
146
        driving_license_type_third.setOnClickListener(this);
147
148
        selected = getResources().getDrawable(R.drawable.icon_radio_selected, null);
149
        selected.setBounds(0, 0, selected.getMinimumWidth(), selected.getMinimumHeight());
150
        normal = getResources().getDrawable(R.drawable.icon_radio_normal, null);
151
        normal.setBounds(0, 0, normal.getMinimumWidth(), normal.getMinimumHeight());
152
153
        submit_btn = findViewById(R.id.submit_btn);
154
        submit_btn.setOnClickListener(this);
155
    }
156
157
    private void brandListRequest(Boolean showLoading) {
158
        if (showLoading)
159
            loadDialog.show();
160
        // https://www.jianshu.com/p/10382cc71127
161
//        String url = "https://api.touchev.com:83/car/api/v1000/brand/list.do";
162
        String url = "http://car.d1ev.com/car/api/v1000/brand/list.do";
163
//        String url = MainApplication.url + "/zhannew/basic/web/index.php/member/get-score?id=" + MainApplication.userId +
164
//                "&phone=" + MainApplication.userPhone + "&password=" + MainApplication.userPassword + "&token=" + "xxxxxx";
165
        OkHttpUtils.get().url(url).build().connTimeOut(5000).readTimeOut(5000).execute(new StringCallback() {
166
            @Override
167
            public void onError(Call call, Exception e) {
168
                Toast.makeText(getApplicationContext(), "网络不给力,请检查网络状态", Toast.LENGTH_SHORT).show();
169
                loadDialog.dismiss();
170
                add_car_model_btn.setVisibility(View.VISIBLE);
171
            }
172
173
            @Override
174
            public void onResponse(String response) {
175
                loadDialog.dismiss();
176
                add_car_model_btn.setVisibility(View.VISIBLE);
177
                String code = JsonUtils.getKeyResult(response, "code");
178
                String desc = JsonUtils.getKeyResult(response, "desc");
179
                if ("1000".equals(code)) {
180
                    String data = JsonUtils.getKeyResult(response, "data");
181
                    Gson gson = new Gson();
182
                    groups = gson.fromJson(data, new TypeToken<ArrayList<CarBrandGroupEntity>>() {
183
                    }.getType());
184
                    if (groups == null || groups.size() == 0) {
185
                        if (showLoading)
186
                            ToastUtil.showToast(getApplicationContext(), desc, Toast.LENGTH_SHORT);
187
                    } else {
188
                        if (showLoading) {
189
                            EventBus.getDefault().postSticky(new CarBrandEvent(groups));
190
                            startActivity(new Intent(CarOwnerCertificateActivity.this, CarBrandActivity.class));
191
                        }
192
                    }
193
                } else {
194
                    if (showLoading)
195
                        ToastUtil.showToast(getApplicationContext(), desc, Toast.LENGTH_SHORT);
196
                }
197
            }
198
        });
199
    }
200
201
    @Override
202
    public void onClick(View v) {
203
        switch (v.getId()) {
204
            case R.id.add_car_model_btn:
205
            case R.id.car_model_selected_constraint_layout:
206
                if (groups == null || groups.size() == 0) {
207
                    brandListRequest(true);
208
                } else {
209
                    EventBus.getDefault().postSticky(new CarBrandEvent(groups));
210
                    startActivity(new Intent(CarOwnerCertificateActivity.this, CarBrandActivity.class));
211
                }
212
                break;
213
            case R.id.driving_license:
214
                Matisse.from(CarOwnerCertificateActivity.this)
215
                        .choose(MimeType.of(MimeType.JPEG, MimeType.PNG))
216
                        .showSingleMediaType(true)
217
                        .countable(true)
218
                        .maxSelectable(1)
219
                        .capture(true)
220
                        .captureStrategy(new CaptureStrategy(true, "com.electric.chargingpile.provider"))
221
                        .imageEngine(new GlideEngine())
222
                        .forResult(REQUEST_CODE_CHOOSE);
223
                break;
224
            case R.id.driving_license_type_first:
225
                drivingLicenseType = 1;
226
                driving_license_type_first.setCompoundDrawables(selected, null, null, null);
227
                driving_license_type_second.setCompoundDrawables(normal, null, null, null);
228
                driving_license_type_third.setCompoundDrawables(normal, null, null, null);
229
                break;
230
            case R.id.driving_license_type_second:
231
                drivingLicenseType = 2;
232
                driving_license_type_first.setCompoundDrawables(normal, null, null, null);
233
                driving_license_type_second.setCompoundDrawables(selected, null, null, null);
234
                driving_license_type_third.setCompoundDrawables(normal, null, null, null);
235
                break;
236
            case R.id.driving_license_type_third:
237
                drivingLicenseType = 3;
238
                driving_license_type_first.setCompoundDrawables(normal, null, null, null);
239
                driving_license_type_second.setCompoundDrawables(normal, null, null, null);
240
                driving_license_type_third.setCompoundDrawables(selected, null, null, null);
241
                break;
242
            case R.id.submit_btn:
243
                if (carSeriesEntity == null) {
244
                    ToastUtil.showToast(this, "请添加车型" + drivingLicenseType, Toast.LENGTH_SHORT);
245
                    return;
246
                }
247
                break;
248
        }
249
    }
250
251
    @Override
252
    protected void onDestroy() {
253
        super.onDestroy();
254
        EventBus.getDefault().unregister(this);
255
    }
256
257
    @Subscribe(threadMode = ThreadMode.MAIN)
258
    public void onCarSeriesMessage(CarSerieEvent event) {
259
        if (event != null && event.getCarSeriesEntity() != null) {
260
            carSeriesEntity = event.getCarSeriesEntity();
261
            car_model_constraint_layout.setVisibility(View.GONE);
262
            car_model_selected_constraint_layout.setVisibility(View.VISIBLE);
263
            car_name.setText(carSeriesEntity.getBrandName());
264
            car_series.setText(carSeriesEntity.getSeriesName());
265
            Glide.with(CarOwnerCertificateActivity.this).load(carSeriesEntity.getIcon()).placeholder(android.R.color.white).fitCenter().into(car_icon);
266
        } else {
267
            carSeriesEntity = null;
268
            car_model_constraint_layout.setVisibility(View.VISIBLE);
269
            car_model_selected_constraint_layout.setVisibility(View.GONE);
270
        }
271
    }
272
273
    @Override
274
    protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
275
        super.onActivityResult(requestCode, resultCode, data);
276
        if (resultCode == RESULT_OK) {
277
            if (data != null) {
278
                if (requestCode == REQUEST_CODE_CHOOSE) {
279
                    insertImagesSync(data);
280
                }
281
            }
282
        }
283
    }
284
285
    private Bitmap imageZoom(Bitmap bm) {
286
        // 图片允许最大空间 单位:KB
287
        double maxSize = 200.00;
288
        // 将bitmap放至数组中,意在bitmap的大小(与实际读取的原文件要大)
289
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
290
        bm.compress(Bitmap.CompressFormat.JPEG, 100, baos);
291
        byte[] b = baos.toByteArray();
292
        // 将字节换成KB
293
        double mid = b.length / 1024;
294
        // 判断bitmap占用空间是否大于允许最大空间 如果大于则压缩 小于则不压缩
295
        if (mid > maxSize) {
296
            // 获取bitmap大小 是允许最大大小的多少倍
297
            double i = mid / maxSize;
298
            // 开始压缩 此处用到平方根 将宽带和高度压缩掉对应的平方根倍
299
            // (1.保持刻度和高度和原bitmap比率一致,压缩后也达到了最大大小占用空间的大小)
300
            bm = zoomImage(bm, bm.getWidth() / Math.sqrt(i), bm.getHeight()
301
                    / Math.sqrt(i));
302
        }
303
304
305
        return bm;
306
    }
307
308
    public Bitmap zoomImage(Bitmap bgimage, double newWidth, double newHeight) {
309
        // 获取这个图片的宽和高
310
        float width = bgimage.getWidth();
311
        float height = bgimage.getHeight();
312
        // 创建操作图片用的matrix对象
313
        Matrix matrix = new Matrix();
314
        // 计算宽高缩放率
315
        float scaleWidth = ((float) newWidth) / width;
316
        float scaleHeight = ((float) newHeight) / height;
317
        // 缩放图片动作
318
        matrix.postScale(scaleWidth, scaleHeight);
319
        Bitmap bitmap = Bitmap.createBitmap(bgimage, 0, 0, (int) width,
320
                (int) height, matrix, true);
321
        return bitmap;
322
    }
323
324
    /**
325
     * 异步方式插入图片
326
     *
327
     * @param data
328
     */
329
    private void insertImagesSync(final Intent data) {
330
        insertDialog.show();
331
332
        Observable.create(new ObservableOnSubscribe<String>() {
333
            @Override
334
            public void subscribe(ObservableEmitter<String> subscriber) throws Exception {
335
336
                try {
337
                    List<Uri> uriList = Matisse.obtainResult(data);
338
                    Uri uri = uriList.get(0);
339
                    Bitmap bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(uri));
340
                    File file = FileUtils.from(CarOwnerCertificateActivity.this, uri);
341
342
                    bitmap = FileUtils.rotateIfRequired(file, bitmap);
343
                    bitmap = imageZoom(bitmap);
344
                    insertBitmap = bitmap;
345
346
                    u_path = SDCardUtil.saveToSdCard(bitmap);
347
348
                    subscriber.onNext(u_path);
349
                    subscriber.onComplete();
350
                } catch (Exception e) {
351
                    e.printStackTrace();
352
                    subscriber.onError(e);
353
                }
354
            }
355
        })
356
                .subscribeOn(Schedulers.io())//生产事件在io
357
                .observeOn(AndroidSchedulers.mainThread())//消费事件在UI线程
358
                .subscribe(new Observer<String>() {
359
                    @Override
360
                    public void onComplete() {
361
                        insertDialog.dismiss();
362
                        driving_license_icon.setImageBitmap(insertBitmap);
363
                        driving_license_upload_icon.setVisibility(View.GONE);
364
                        driving_license_text_view.setVisibility(View.GONE);
365
//                        uploadPic(insertBitmap, u_path); // TODO EditAnswerActivity
366
                    }
367
368
                    @Override
369
                    public void onError(Throwable e) {
370
                        insertDialog.dismiss();
371
                        ToastUtil.showToast(getApplicationContext(), "图片插入失败", Toast.LENGTH_SHORT);
372
                    }
373
374
                    @Override
375
                    public void onSubscribe(Disposable d) {
376
377
                    }
378
379
                    @Override
380
                    public void onNext(String imagePath) {
381
382
                    }
383
                });
384
    }
385
}

+ 29 - 133
app/src/main/java/com/electric/chargingpile/activity/UserCenterActivity.java

@ -21,7 +21,9 @@ import android.os.Environment;
21 21
import android.os.Handler;
22 22
import android.os.Message;
23 23
import android.os.Process;
24
24 25
import androidx.annotation.NonNull;
26
25 27
import android.util.Log;
26 28
import android.view.KeyEvent;
27 29
import android.view.View;
@ -98,7 +100,7 @@ public class UserCenterActivity extends Activity implements View.OnClickListener
98 100
    private NetworkChangeReceiver networkChangeReceiver;
99 101
    private ImageView iv_back, iv_message, iv_qiandao, iv_share_prompt, iv_find, iv_main, iv_screening, iv_point;
100 102
    private RelativeLayout rl_addZhan, rl_collection, rl_more,
101
            rl_offline, rl_shop, rl_message, rl_feedback, rl_shareNo, rl_offline_upload, rl_chongzhi, rl_myaccount, rl_yue, rl_chongdianbi, rl_hongbao;
103
            rl_offline, rl_shop, rl_message, rl_feedback, rl_shareNo, rl_offline_upload, rl_chongzhi, rl_myaccount, rl_yue, rl_chongdianbi, rl_hongbao, rl_car_owner_certificate, rl_publish_price;
102 104
    private ToggleButton mTogBtn;
103 105
    private TextView tv_exit, userLogin, userRegister, chongdianbi, yue, hongbao, tv_our;
104 106
    private LinearLayout ll_userLogin;
@ -148,73 +150,11 @@ public class UserCenterActivity extends Activity implements View.OnClickListener
148 150
149 151
                        Log.d("pingLunNum+++", pingLunNum);
150 152
                        MainMapActivity.have_pinglun = Integer.parseInt(pingLunNum);
151
152 153
                        Log.d("pinglun===yonghu", MainMapActivity.have_message + "");
153
//                        if (MainMapActivity.have_message == 0 && MainMapActivity.have_pinglun == 0) {
154
////            ivRight.setImageResource(R.drawable.icon_user2_0);
155
////                        iv_havemessage.setVisibility(View.GONE);
156
//                            iv_message.setVisibility(View.INVISIBLE);
157
//                            if (MainApplication.festival_time.equals("1")){
158
//                                iv_our.setImageResource(R.drawable.icon_cj4);
159
//                            }else if (MainApplication.festival_time.equals("2")){
160
//                                iv_our.setImageResource(R.drawable.icon_yx4);
161
//                            }else {
162
//                                iv_our.setImageResource(R.drawable.tab_our_selected);
163
//                            }
164
////                            iv_our.setImageResource(R.drawable.tab_our_selected);
165
//                        } else if (MainMapActivity.have_message == 1) {
166
//                            if (MainApplication.festival_time.equals("1")){
167
//                                iv_our.setImageResource(R.drawable.icon_cjh4);
168
//                            }else if (MainApplication.festival_time.equals("2")){
169
//                                iv_our.setImageResource(R.drawable.icon_yxh4);
170
//                            }else {
171
//                                iv_our.setImageResource(R.drawable.tab_our_selected_h);
172
//                            }
173
////                            iv_our.setImageResource(R.drawable.tab_our_selected_h);
174
////                        iv_havemessage.setVisibility(View.VISIBLE);
175
//                            iv_message.setVisibility(View.VISIBLE);
176
//                        } else if (MainMapActivity.have_pinglun > 0) {
177
////                        iv_havemessage.setVisibility(View.VISIBLE);
178
//                            iv_message.setVisibility(View.VISIBLE);
179
//                            if (MainApplication.festival_time.equals("1")){
180
//                                iv_our.setImageResource(R.drawable.icon_cjh4);
181
//                            }else if (MainApplication.festival_time.equals("2")){
182
//                                iv_our.setImageResource(R.drawable.icon_yxh4);
183
//                            }else {
184
//                        }
185
//                                iv_our.setImageResource(R.drawable.tab_our_selected_h);
186
//                            }
187
//                        }
188 154
                    } catch (JSONException e) {
189 155
                        e.printStackTrace();
190 156
                    }
191
192 157
                    break;
193
194
//                case 5:
195
////                    Log.e("log",msg.obj.toString());
196
//                    try {
197
//                        JSONArray jsonArray = new JSONArray(msg.obj.toString());
198
//                        Log.e("???",jsonArray.length()+"");
199
//                        Log.e("???",msg.obj.toString());
200
//                        if (jsonArray.length() == 0){
201
//                            Log.e("!!!",jsonArray.length()+"");
202
//                            iv_message.setVisibility(View.INVISIBLE);
203
//                            have_message = 0;
204
//                        }else{
205
//                            Log.e("@@@",jsonArray.length()+"");
206
//                            iv_message.setVisibility(View.VISIBLE);
207
//                            have_message = 1;
208
//                        }
209
//                    } catch (JSONException e) {
210
//                        e.printStackTrace();
211
//                    }
212
////                    if (msg.obj.toString() == null || msg.obj.toString().equals("") ||msg.obj.toString().equals("null")){
213
////                       iv_message.setVisibility(View.INVISIBLE);
214
////                    }
215
//                    break;
216
217
218 158
                default:
219 159
220 160
                    break;
@ -268,21 +208,12 @@ public class UserCenterActivity extends Activity implements View.OnClickListener
268 208
        registerReceiver(networkChangeReceiver, intentFilter);
269 209
        //透明状态栏
270 210
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
271
        //透明导航栏
272
//        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
273
274 211
        initView();
275 212
        activity = this;
276 213
        if (MainApplication.isLogin()) {
277 214
            getPingLun();
278 215
        }
279 216
280
281
//        getMessage();
282
283
//        getIntegration();
284
285
286 217
        // ATTENTION: This was auto-generated to implement the App Indexing API.
287 218
        // See https://g.co/AppIndexing/AndroidStudio for more information.
288 219
        client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
@ -298,12 +229,7 @@ public class UserCenterActivity extends Activity implements View.OnClickListener
298 229
                    } catch (Exception e) {
299 230
                        e.printStackTrace();
300 231
                    }
301
302
//                    saveBitmap(bm);
303
304 232
                    break;
305
306
307 233
                default:
308 234
                    break;
309 235
            }
@ -364,7 +290,6 @@ public class UserCenterActivity extends Activity implements View.OnClickListener
364 290
        iv_hongbao = (ImageView) findViewById(R.id.iv_hongbao);
365 291
        iv_chongdianbi = (ImageView) findViewById(R.id.iv_chongdianbi);
366 292
        yue = (TextView) findViewById(R.id.tv_yue);
367
//        iv_message = (ImageView) findViewById(R.id.iv_message);
368 293
        iv_message = (ImageView) findViewById(R.id.iv_have_message);
369 294
370 295
        ll_tab_find = (RelativeLayout) findViewById(R.id.ll_tab_find);
@ -379,39 +304,13 @@ public class UserCenterActivity extends Activity implements View.OnClickListener
379 304
380 305
381 306
        iv_our = (ImageView) findViewById(R.id.iv_our);
382
//        if (MainMapActivity.have_message == 1) {
383
//            Log.e("userCenter==",MainMapActivity.have_message+"");
384
//            iv_message.setVisibility(View.VISIBLE);
385
//        } else {
386
//            iv_message.setVisibility(View.INVISIBLE);
387
//        }
388
389
390
//        iv_havemessage = (ImageView) findViewById(R.id.iv_havemessage);
391
//        if (MainFragment.have_message == 1){
392
//            iv_havemessage.setVisibility(View.VISIBLE);
393
//        }else if(MainFragment.have_message == 0){
394
//            iv_havemessage.setVisibility(View.GONE);
395
//        }
396
397
398
//        if (have_message == 1){
399
//            iv_message.setVisibility(View.VISIBLE);
400
//        }else{
401
//            iv_message.setVisibility(View.INVISIBLE);
402
//        }
403 307
404 308
        rl_collection = (RelativeLayout) findViewById(R.id.rl_collection);
405 309
        rl_collection.setOnClickListener(this);
406 310
407
408
//        rl_more = (RelativeLayout) findViewById(R.id.rl_more);
409
//        rl_more.setOnClickListener(this);
410
411 311
        rl_message = (RelativeLayout) findViewById(R.id.rl_message);
412 312
        rl_message.setOnClickListener(this);
413 313
414
415 314
        rl_shareNo = (RelativeLayout) findViewById(R.id.rl_shareNo);
416 315
        rl_shareNo.setOnClickListener(this);
417 316
@ -422,6 +321,11 @@ public class UserCenterActivity extends Activity implements View.OnClickListener
422 321
        chat_share_bar = findViewById(R.id.chat_share_bar);
423 322
        chat_share_bar.setOnClickListener(this);
424 323
324
        rl_car_owner_certificate = findViewById(R.id.rl_car_owner_certificate);
325
        rl_car_owner_certificate.setOnClickListener(this);
326
327
        rl_publish_price = findViewById(R.id.rl_publish_price);
328
        rl_publish_price.setOnClickListener(this);
425 329
426 330
        rl_chongzhi = (RelativeLayout) findViewById(R.id.rl_chongzhi);
427 331
        rl_chongzhi.setOnClickListener(this);
@ -437,30 +341,6 @@ public class UserCenterActivity extends Activity implements View.OnClickListener
437 341
438 342
        rl_yue = (RelativeLayout) findViewById(R.id.rl_yue);
439 343
        rl_yue.setOnClickListener(this);
440
//        mTogBtn = (ToggleButton) findViewById(R.id.iosbutton); // 获取到控件
441
//        if (MainApplication.userTpye == "1") {
442
//            mTogBtn.setChecked(false);
443
//        } else if (MainApplication.userTpye == "2") {
444
//            mTogBtn.setChecked(true);
445
//        }
446
//
447
//        mTogBtn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
448
//
449
//            @Override
450
//            public void onCheckedChanged(CompoundButton buttonView,
451
//                                         boolean isChecked) {
452
//                // TODO Auto-generated method stub
453
//                if (isChecked) {
454
//                    MainApplication.userTpye = "2";
455
//                    Log.e("suit_car", "特斯拉");
456
//                    MainFragment.firstSelect();
457
//                } else {
458
//                    MainApplication.userTpye = "1";
459
//                    Log.e("suit_car", "国标");
460
//                    MainFragment.firstSelect();
461
//                }
462
//            }
463
//        });
464 344
465 345
        tab_main = (LinearLayout) findViewById(R.id.tab_main);
466 346
        tab_main.setOnClickListener(this);
@ -478,11 +358,6 @@ public class UserCenterActivity extends Activity implements View.OnClickListener
478 358
        llPerson = (RelativeLayout) findViewById(R.id.ll_person);
479 359
        llPerson.setOnClickListener(this);
480 360
481
482
        //退出登录按钮
483
//        tv_exit = (TextView) findViewById(R.id.tv_exit);
484
//        tv_exit.setOnClickListener(this);
485
486 361
        //登陆按钮
487 362
        userLogin = (TextView) findViewById(R.id.userLogin);
488 363
        userLogin.setOnClickListener(this);
@ -901,6 +776,27 @@ public class UserCenterActivity extends Activity implements View.OnClickListener
901 776
                MobclickAgent.onEvent(getApplicationContext(), "0815");
902 777
                break;
903 778
779
            case R.id.rl_car_owner_certificate: // 车主认证
780
                if (!MainApplication.isLogin()) {
781
                    Toast.makeText(getApplication(), "请先登录", Toast.LENGTH_SHORT).show();
782
                    startActivity(new Intent(getApplication(), LoginActivity.class));
783
                } else {
784
                    // 列表接口
785
                    // 1.无认证记录
786
                    startActivity(new Intent(getApplication(), CarOwnerCertificateActivity.class));
787
//                    MobclickAgent.onEvent(getApplicationContext(), "0810"); // TODO
788
                }
789
                break;
790
            case R.id.rl_publish_price: // 发表成交价
791
                if (!MainApplication.isLogin()) {
792
                    Toast.makeText(getApplication(), "请先登录", Toast.LENGTH_SHORT).show();
793
                    startActivity(new Intent(getApplication(), LoginActivity.class));
794
                } else {
795
                    // TODO 跳转html
796
                    System.out.println("come on");
797
                }
798
                break;
799
904 800
            case R.id.rl_chongzhi:
905 801
                if (!MainApplication.isLogin()) {
906 802
                    Toast.makeText(getApplication(), "请先登录", Toast.LENGTH_SHORT).show();

+ 97 - 0
app/src/main/java/com/electric/chargingpile/adapter/CarBrandGroupedListAdapter.java

@ -0,0 +1,97 @@
1
package com.electric.chargingpile.adapter;
2
3
import android.content.Context;
4
import android.view.LayoutInflater;
5
import android.view.View;
6
import android.view.ViewGroup;
7
import android.widget.Button;
8
import android.widget.ImageView;
9
10
import com.bumptech.glide.Glide;
11
import com.bumptech.glide.load.engine.DiskCacheStrategy;
12
import com.donkingliang.groupedadapter.adapter.GroupedRecyclerViewAdapter;
13
import com.donkingliang.groupedadapter.holder.BaseViewHolder;
14
import com.electric.chargingpile.R;
15
import com.electric.chargingpile.entity.CarBrandChildEntity;
16
import com.electric.chargingpile.entity.CarBrandGroupEntity;
17
18
import java.util.ArrayList;
19
20
public class CarBrandGroupedListAdapter extends GroupedRecyclerViewAdapter {
21
22
    protected ArrayList<CarBrandGroupEntity> groups;
23
24
    public CarBrandGroupedListAdapter(Context context, ArrayList<CarBrandGroupEntity> groups) {
25
        super(context);
26
        this.groups = groups;
27
    }
28
29
    public void clear() {
30
        groups.clear();
31
        notifyDataChanged();
32
    }
33
34
    public void setGroups(ArrayList<CarBrandGroupEntity> groups) {
35
        this.groups = groups;
36
        notifyDataChanged();
37
    }
38
39
    @Override
40
    public int getGroupCount() {
41
        return groups == null ? 0 : groups.size();
42
    }
43
44
    @Override
45
    public int getChildrenCount(int groupPosition) {
46
        ArrayList<CarBrandChildEntity> children = groups.get(groupPosition).getBrandList();
47
        return children == null ? 0 : children.size();
48
    }
49
50
    @Override
51
    public boolean hasHeader(int groupPosition) {
52
        return true;
53
    }
54
55
    @Override
56
    public boolean hasFooter(int groupPosition) {
57
        return false;
58
    }
59
60
    @Override
61
    public int getHeaderLayout(int viewType) {
62
        return R.layout.adapter_header_car_brand;
63
    }
64
65
    @Override
66
    public int getFooterLayout(int viewType) {
67
        return 0;
68
    }
69
70
    @Override
71
    public int getChildLayout(int viewType) {
72
        return R.layout.adapter_child_car_brand;
73
    }
74
75
    @Override
76
    public void onBindHeaderViewHolder(BaseViewHolder holder, int groupPosition) {
77
        CarBrandGroupEntity entity = groups.get(groupPosition);
78
        holder.setText(R.id.title, entity.getInitial());
79
    }
80
81
    @Override
82
    public void onBindFooterViewHolder(BaseViewHolder holder, int groupPosition) {
83
    }
84
85
    @Override
86
    public void onBindChildViewHolder(BaseViewHolder holder, int groupPosition, int childPosition) {
87
        CarBrandChildEntity entity = groups.get(groupPosition).getBrandList().get(childPosition);
88
        holder.setText(R.id.title, entity.getBrandName());
89
        if (childPosition == 0) {
90
            holder.setVisible(R.id.line, View.GONE);
91
        } else {
92
            holder.setVisible(R.id.line, View.VISIBLE);
93
        }
94
        ImageView icon = holder.getImageView(R.id.icon);
95
        Glide.with(mContext).load(entity.getIcon()).placeholder(android.R.color.white).fitCenter().into(icon);
96
    }
97
}

+ 95 - 0
app/src/main/java/com/electric/chargingpile/adapter/CarModelGroupedListAdapter.java

@ -0,0 +1,95 @@
1
package com.electric.chargingpile.adapter;
2
3
import android.content.Context;
4
import android.view.View;
5
import android.widget.ImageView;
6
7
import com.bumptech.glide.Glide;
8
import com.bumptech.glide.load.engine.DiskCacheStrategy;
9
import com.donkingliang.groupedadapter.adapter.GroupedRecyclerViewAdapter;
10
import com.donkingliang.groupedadapter.holder.BaseViewHolder;
11
import com.electric.chargingpile.R;
12
import com.electric.chargingpile.entity.CarCompanyEntity;
13
import com.electric.chargingpile.entity.CarSeriesEntity;
14
15
import java.util.ArrayList;
16
17
public class CarModelGroupedListAdapter extends GroupedRecyclerViewAdapter {
18
    protected ArrayList<CarCompanyEntity> groups;
19
20
    public CarModelGroupedListAdapter(Context context, ArrayList<CarCompanyEntity> groups) {
21
        super(context);
22
        this.groups = groups;
23
    }
24
25
    public void clear() {
26
        groups.clear();
27
        notifyDataChanged();
28
    }
29
30
    public void setGroups(ArrayList<CarCompanyEntity> groups) {
31
        this.groups = groups;
32
        notifyDataChanged();
33
    }
34
35
    @Override
36
    public int getGroupCount() {
37
        return groups == null ? 0 : groups.size();
38
    }
39
40
    @Override
41
    public int getChildrenCount(int groupPosition) {
42
        ArrayList<CarSeriesEntity> children = groups.get(groupPosition).getSerieslist();
43
        return children == null ? 0 : children.size();
44
    }
45
46
    @Override
47
    public boolean hasHeader(int groupPosition) {
48
        return true;
49
    }
50
51
    @Override
52
    public boolean hasFooter(int groupPosition) {
53
        return false;
54
    }
55
56
    @Override
57
    public int getHeaderLayout(int viewType) {
58
        return R.layout.adapter_header_car_model;
59
    }
60
61
    @Override
62
    public int getFooterLayout(int viewType) {
63
        return 0;
64
    }
65
66
    @Override
67
    public int getChildLayout(int viewType) {
68
        return R.layout.adapter_child_car_model;
69
    }
70
71
    @Override
72
    public void onBindHeaderViewHolder(BaseViewHolder holder, int groupPosition) {
73
        CarCompanyEntity entity = groups.get(groupPosition);
74
        holder.setText(R.id.title, entity.getCompanyName());
75
    }
76
77
    @Override
78
    public void onBindFooterViewHolder(BaseViewHolder holder, int groupPosition) {
79
80
    }
81
82
    @Override
83
    public void onBindChildViewHolder(BaseViewHolder holder, int groupPosition, int childPosition) {
84
        CarSeriesEntity entity = groups.get(groupPosition).getSerieslist().get(childPosition);
85
        holder.setText(R.id.title, entity.getSeriesName());
86
        if (childPosition == 0) {
87
            holder.setVisible(R.id.line, View.GONE);
88
        } else {
89
            holder.setVisible(R.id.line, View.VISIBLE);
90
        }
91
        ImageView icon = holder.getImageView(R.id.icon);
92
        Glide.with(mContext).load(entity.getIcon()).placeholder(android.R.color.white).diskCacheStrategy(DiskCacheStrategy.RESOURCE).fitCenter().into(icon);
93
    }
94
95
}

+ 59 - 0
app/src/main/java/com/electric/chargingpile/entity/CarBrandChildEntity.java

@ -0,0 +1,59 @@
1
package com.electric.chargingpile.entity;
2
3
import java.util.ArrayList;
4
5
public class CarBrandChildEntity {
6
    private int brandId;
7
    private String brandName;
8
    private int seriesNum;
9
    private String icon;
10
    private ArrayList<CarCompanyEntity> companyList;
11
12
    public CarBrandChildEntity(int brandId, String brandName, int seriesNum, String icon, ArrayList<CarCompanyEntity> companyList) {
13
        this.brandId = brandId;
14
        this.brandName = brandName;
15
        this.seriesNum = seriesNum;
16
        this.icon = icon;
17
        this.companyList = companyList;
18
    }
19
20
    public int getBrandId() {
21
        return brandId;
22
    }
23
24
    public void setBrandId(int brandId) {
25
        this.brandId = brandId;
26
    }
27
28
    public String getBrandName() {
29
        return brandName;
30
    }
31
32
    public void setBrandName(String brandName) {
33
        this.brandName = brandName;
34
    }
35
36
    public int getSeriesNum() {
37
        return seriesNum;
38
    }
39
40
    public void setSeriesNum(int seriesNum) {
41
        this.seriesNum = seriesNum;
42
    }
43
44
    public String getIcon() {
45
        return icon;
46
    }
47
48
    public void setIcon(String icon) {
49
        this.icon = icon;
50
    }
51
52
    public ArrayList<CarCompanyEntity> getCompanyList() {
53
        return companyList;
54
    }
55
56
    public void setCompanyList(ArrayList<CarCompanyEntity> companyList) {
57
        this.companyList = companyList;
58
    }
59
}

+ 30 - 0
app/src/main/java/com/electric/chargingpile/entity/CarBrandGroupEntity.java

@ -0,0 +1,30 @@
1
package com.electric.chargingpile.entity;
2
3
4
import java.util.ArrayList;
5
6
public class CarBrandGroupEntity {
7
    private String initial; // header
8
    private ArrayList<CarBrandChildEntity> brandList; // children
9
10
    public CarBrandGroupEntity(String initial, ArrayList<CarBrandChildEntity> brandList) {
11
        this.initial = initial;
12
        this.brandList = brandList;
13
    }
14
15
    public String getInitial() {
16
        return initial;
17
    }
18
19
    public void setInitial(String initial) {
20
        this.initial = initial;
21
    }
22
23
    public ArrayList<CarBrandChildEntity> getBrandList() {
24
        return brandList;
25
    }
26
27
    public void setBrandList(ArrayList<CarBrandChildEntity> brandList) {
28
        this.brandList = brandList;
29
    }
30
}

+ 50 - 0
app/src/main/java/com/electric/chargingpile/entity/CarCompanyEntity.java

@ -0,0 +1,50 @@
1
package com.electric.chargingpile.entity;
2
3
import java.util.ArrayList;
4
5
public class CarCompanyEntity {
6
    private int companyId;
7
    private String companyName;
8
    private int brandId;
9
    private ArrayList<CarSeriesEntity> serieslist;
10
11
    public CarCompanyEntity(int companyId, String companyName, int brandId, ArrayList<CarSeriesEntity> serieslist) {
12
        this.companyId = companyId;
13
        this.companyName = companyName;
14
        this.brandId = brandId;
15
        this.serieslist = serieslist;
16
    }
17
18
19
    public int getCompanyId() {
20
        return companyId;
21
    }
22
23
    public void setCompanyId(int companyId) {
24
        this.companyId = companyId;
25
    }
26
27
    public String getCompanyName() {
28
        return companyName;
29
    }
30
31
    public void setCompanyName(String companyName) {
32
        this.companyName = companyName;
33
    }
34
35
    public int getBrandId() {
36
        return brandId;
37
    }
38
39
    public void setBrandId(int brandId) {
40
        this.brandId = brandId;
41
    }
42
43
    public ArrayList<CarSeriesEntity> getSerieslist() {
44
        return serieslist;
45
    }
46
47
    public void setSerieslist(ArrayList<CarSeriesEntity> serieslist) {
48
        this.serieslist = serieslist;
49
    }
50
}

+ 67 - 0
app/src/main/java/com/electric/chargingpile/entity/CarSeriesEntity.java

@ -0,0 +1,67 @@
1
package com.electric.chargingpile.entity;
2
3
public class CarSeriesEntity {
4
    private int brandId;
5
    private String brandName;
6
    private int companyId;
7
    private int seriesId;
8
    private String seriesName;
9
    private String icon;
10
11
    public CarSeriesEntity(int brandId, String brandName, int companyId, int seriesId, String seriesName, String icon) {
12
        this.brandId = brandId;
13
        this.brandName = brandName;
14
        this.companyId = companyId;
15
        this.seriesId = seriesId;
16
        this.seriesName = seriesName;
17
        this.icon = icon;
18
    }
19
20
    public int getBrandId() {
21
        return brandId;
22
    }
23
24
    public void setBrandId(int brandId) {
25
        this.brandId = brandId;
26
    }
27
28
    public String getBrandName() {
29
        return brandName;
30
    }
31
32
    public void setBrandName(String brandName) {
33
        this.brandName = brandName;
34
    }
35
36
    public int getCompanyId() {
37
        return companyId;
38
    }
39
40
    public void setCompanyId(int companyId) {
41
        this.companyId = companyId;
42
    }
43
44
    public int getSeriesId() {
45
        return seriesId;
46
    }
47
48
    public void setSeriesId(int seriesId) {
49
        this.seriesId = seriesId;
50
    }
51
52
    public String getSeriesName() {
53
        return seriesName;
54
    }
55
56
    public void setSeriesName(String seriesName) {
57
        this.seriesName = seriesName;
58
    }
59
60
    public String getIcon() {
61
        return icon;
62
    }
63
64
    public void setIcon(String icon) {
65
        this.icon = icon;
66
    }
67
}

+ 21 - 0
app/src/main/java/com/electric/chargingpile/event/CarBrandEvent.java

@ -0,0 +1,21 @@
1
package com.electric.chargingpile.event;
2
3
import com.electric.chargingpile.entity.CarBrandGroupEntity;
4
5
import java.util.ArrayList;
6
7
public class CarBrandEvent {
8
    private ArrayList<CarBrandGroupEntity> groups;
9
10
    public CarBrandEvent(ArrayList<CarBrandGroupEntity> groups) {
11
        this.groups = groups;
12
    }
13
14
    public ArrayList<CarBrandGroupEntity> getGroups() {
15
        return groups;
16
    }
17
18
    public void setGroups(ArrayList<CarBrandGroupEntity> groups) {
19
        this.groups = groups;
20
    }
21
}

+ 20 - 0
app/src/main/java/com/electric/chargingpile/event/CarCompanyEvent.java

@ -0,0 +1,20 @@
1
package com.electric.chargingpile.event;
2
3
import com.electric.chargingpile.entity.CarCompanyEntity;
4
5
import java.util.ArrayList;
6
7
public class CarCompanyEvent {
8
    private ArrayList<CarCompanyEntity> companyList;
9
    public ArrayList<CarCompanyEntity> getCompanyList() {
10
        return companyList;
11
    }
12
13
    public void setCompanyList(ArrayList<CarCompanyEntity> companyList) {
14
        this.companyList = companyList;
15
    }
16
17
    public CarCompanyEvent(ArrayList<CarCompanyEntity> companyList) {
18
        this.companyList = companyList;
19
    }
20
}

+ 19 - 0
app/src/main/java/com/electric/chargingpile/event/CarSerieEvent.java

@ -0,0 +1,19 @@
1
package com.electric.chargingpile.event;
2
3
import com.electric.chargingpile.entity.CarSeriesEntity;
4
5
public class CarSerieEvent {
6
    private CarSeriesEntity carSeriesEntity;
7
8
    public CarSerieEvent(CarSeriesEntity carSeriesEntity) {
9
        this.carSeriesEntity = carSeriesEntity;
10
    }
11
12
    public CarSeriesEntity getCarSeriesEntity() {
13
        return carSeriesEntity;
14
    }
15
16
    public void setCarSeriesEntity(CarSeriesEntity carSeriesEntity) {
17
        this.carSeriesEntity = carSeriesEntity;
18
    }
19
}

+ 12 - 0
app/src/main/java/com/electric/chargingpile/util/DensityUtil.java

@ -28,4 +28,16 @@ public class DensityUtil {
28 28
        final float scale = context.getResources().getDisplayMetrics().density;
29 29
        return (int) (pxValue / scale + 0.5f);
30 30
    }
31

32
    /**
33
     * 将sp值转换为px值,保证文字大小不变
34
     *
35
     * @param spValue fontScale(DisplayMetrics类中属性scaledDensity)
36
     * @return
37
     */
38
    public static int sp2px(Context context, float spValue) {
39
        final float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
40
        return (int) (spValue * fontScale + 0.5f);
41
    }
42

31 43
}

+ 154 - 0
app/src/main/java/com/electric/chargingpile/view/LetterSideView.java

@ -0,0 +1,154 @@
1
package com.electric.chargingpile.view;
2
3
import android.content.Context;
4
import android.graphics.Canvas;
5
import android.graphics.Color;
6
import android.graphics.Paint;
7
import android.graphics.Rect;
8
import android.util.AttributeSet;
9
import android.view.MotionEvent;
10
import android.view.View;
11
import android.widget.TextView;
12
13
import com.electric.chargingpile.util.DensityUtil;
14
15
public class LetterSideView extends View {
16
    // 26个字母
17
    public static String[] letters = {
18
            "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N",
19
            "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "#"
20
    };
21
    private int choose = -1;  // 选中的字母的y坐标
22
    private int chosen = -1;
23
    private Paint paint = new Paint(); // 字母画笔
24
    private Paint circle = new Paint(); // 选中字符背景
25
    private TextView mTextDialog;  // 显示当前字母的文本框
26
    private int singleHeight;      // 一个字母的空间
27
    Rect rect = new Rect();     // 存放文字的高度
28
29
    public LetterSideView(Context context, AttributeSet attrs) {
30
        super(context, attrs);
31
    }
32
33
    @Override
34
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
35
        super.onLayout(changed, left, top, right, bottom);
36
        paint.setAntiAlias(true); // 设置抗锯齿
37
        paint.setTextSize(DensityUtil.sp2px(getContext(), 12f)); // 设置字母字体大小为12sp
38
        paint.getTextBounds("A", 0, 1, rect);  // 获取一个字母实际的宽高到rect
39
        singleHeight = (getHeight() - (getPaddingTop() + getPaddingBottom())) / letters.length;   // 获取一个字母的空间
40
41
        circle.setAntiAlias(true); // 设置抗锯齿
42
        circle.setColor(Color.parseColor("#C1CCD5"));
43
    }
44
45
    /**
46
     * 为SideBar设置显示字母的TextView
47
     *
48
     * @param mTextDialog 在activity传递过来的textView
49
     */
50
    public void setTextView(TextView mTextDialog) {
51
        this.mTextDialog = mTextDialog;
52
    }
53
54
    public void setPosition(int position) {
55
        chosen = position;
56
        invalidate();
57
    }
58
59
    /**
60
     * 绘制
61
     */
62
    @Override
63
    protected void onDraw(Canvas canvas) {
64
        super.onDraw(canvas);
65
        // 循环绘制字母
66
        for (int i = 0; i < letters.length; i++) {
67
            //paint.setTypeface(Typeface.DEFAULT_BOLD); // 设置默认字体加粗
68
69
70
            // 选中的状态
71
            if (i == chosen) {
72
                paint.setColor(Color.parseColor("#FFFFFF")); // 选中的字母改变颜色
73
                paint.setFakeBoldText(true); // 设置字体为粗体
74
                float yPos = getPaddingTop() + singleHeight * i + rect.height() / 2f;
75
                canvas.drawCircle(getWidth() / 2f, yPos, getWidth() * 0.35f, circle);
76
            } else {
77
                paint.setColor(Color.parseColor("#6F6F7D")); // 设置字体颜色
78
                paint.setFakeBoldText(false); // 设置字体为正常
79
            }
80
81
            // x坐标等于中间-字符宽度的一半.
82
            float xPos = getWidth() / 2 - paint.measureText(letters[i]) / 2;
83
            // Y轴坐标
84
            float yPos = getPaddingTop() + singleHeight * i + rect.height();
85
            canvas.drawText(letters[i], xPos, yPos, paint); // 绘制字母
86
        }
87
    }
88
89
    /**
90
     * 分发触摸事件
91
     *
92
     * @param event
93
     * @return
94
     */
95
    @Override
96
    public boolean dispatchTouchEvent(MotionEvent event) {
97
        final int action = event.getAction();
98
        final float y = event.getY(); // 点击y坐标
99
        chosen = choose;  // 上一个选中的字母
100
        // 点击y坐标所占总高度的比例  *   数组的长度就等于点击了 数组中的位置.
101
        final int c = (int) (y / (getHeight() - getPaddingTop() - getPaddingBottom()) * letters.length);
102
        switch (action) {
103
            case MotionEvent.ACTION_UP:
104
                //抬起来的时候设置背景为透明
105
                //setBackgroundDrawable(new ColorDrawable(0x00000000));
106
                choose = -1;
107
                invalidate();
108
                if (mTextDialog != null) {
109
                    mTextDialog.setVisibility(View.INVISIBLE);
110
                }
111
                break;
112
            default:
113
                //按下,滑动的时候设置背景为灰色
114
                //setBackgroundDrawable(new ColorDrawable(0x44000000));
115
                //setBackgroundResource(R.drawable.sidebar_background);
116
                if (chosen != c) { // 判断选中字母是否发生改变
117
                    if (c >= 0 && c < letters.length) {
118
                        if (listener != null) {
119
                            listener.onTouchLetterChanged(letters[c]);
120
                            listener.onTouchLetterPosition(c);
121
                        }
122
                        if (mTextDialog != null) {
123
                            mTextDialog.setText(letters[c]);
124
                            mTextDialog.setVisibility(View.VISIBLE);
125
                        }
126
                        // 设置选中字母在数组的位置
127
                        choose = c;
128
                        chosen = choose;
129
                        invalidate();
130
                    }
131
                }
132
                break;
133
        }
134
        return true;
135
    }
136
137
    // 触摸回调接口
138
    private OnTouchLetterChangedListener listener;
139
140
141
    public void setOnTouchLetterChangedListener(OnTouchLetterChangedListener onTouchLetterChangedListener) {
142
        this.listener = onTouchLetterChangedListener;
143
    }
144
145
    public interface OnTouchLetterChangedListener {
146
        /**
147
         * 触摸字母回调
148
         *
149
         * @param s 触摸的字符
150
         */
151
        void onTouchLetterChanged(String s);
152
        void onTouchLetterPosition(int position);
153
    }
154
}

+ 92 - 0
app/src/main/java/com/electric/chargingpile/view/TextImageView.java

@ -0,0 +1,92 @@
1
package com.electric.chargingpile.view;
2
3
import android.content.Context;
4
import android.content.res.TypedArray;
5
import android.graphics.Rect;
6
import android.graphics.drawable.Drawable;
7
import android.util.AttributeSet;
8
9
import androidx.appcompat.widget.AppCompatTextView;
10
11
import com.electric.chargingpile.R;
12
13
public class TextImageView extends AppCompatTextView {
14
    private int leftWidth;
15
    private int leftHeight;
16
    private int topWidth;
17
    private int topHeight;
18
    private int rightWidth;
19
    private int rightHeight;
20
    private int bottomWidth;
21
    private int bottomHeight;
22
23
24
    public TextImageView(Context context) {
25
        super(context);
26
    }
27
28
    public TextImageView(Context context, AttributeSet attrs) {
29
        super(context, attrs);
30
        init(context, attrs);
31
    }
32
33
    public TextImageView(Context context, AttributeSet attrs, int defStyleAttr) {
34
        super(context, attrs, defStyleAttr);
35
        init(context, attrs);
36
    }
37
38
    private void init(Context context, AttributeSet attrs) {
39
        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.TextImageView);
40
        leftWidth = typedArray.getDimensionPixelOffset(R.styleable.TextImageView_drawableLeftWidth, 0);
41
        leftHeight = typedArray.getDimensionPixelOffset(R.styleable.TextImageView_drawableLeftHeight, 0);
42
        topWidth = typedArray.getDimensionPixelOffset(R.styleable.TextImageView_drawableTopWidth, 0);
43
        topHeight = typedArray.getDimensionPixelOffset(R.styleable.TextImageView_drawableTopHeight, 0);
44
        rightWidth = typedArray.getDimensionPixelOffset(R.styleable.TextImageView_drawableRightWidth, 0);
45
        rightHeight = typedArray.getDimensionPixelOffset(R.styleable.TextImageView_drawableRightHeight, 0);
46
        bottomWidth = typedArray.getDimensionPixelOffset(R.styleable.TextImageView_drawableBottomWidth, 0);
47
        bottomHeight = typedArray.getDimensionPixelOffset(R.styleable.TextImageView_drawableBottomHeight, 0);
48
        typedArray.recycle();
49
        setDrawablesSize();
50
    }
51
52
    private void setDrawablesSize() {
53
        Drawable[] compoundDrawables = getCompoundDrawables();
54
        for (int i = 0; i < compoundDrawables.length; i++) {
55
            switch (i) {
56
                case 0:
57
                    setDrawableBounds(compoundDrawables[0], leftWidth, leftHeight);
58
                    break;
59
                case 1:
60
                    setDrawableBounds(compoundDrawables[1], topWidth, topHeight);
61
                    break;
62
                case 2:
63
                    setDrawableBounds(compoundDrawables[2], rightWidth, rightHeight);
64
                    break;
65
                case 3:
66
                    setDrawableBounds(compoundDrawables[3], bottomWidth, bottomHeight);
67
                    break;
68
                default:
69
                    break;
70
            }
71
        }
72
        setCompoundDrawables(compoundDrawables[0], compoundDrawables[1], compoundDrawables[2], compoundDrawables[3]);
73
    }
74
75
    private void setDrawableBounds(Drawable drawable, int width, int height) {
76
        if (drawable != null) {
77
            double scale = ((double) drawable.getIntrinsicHeight()) / ((double) drawable.getIntrinsicWidth());
78
            drawable.setBounds(0, 0, width, height);
79
            Rect bounds = drawable.getBounds();
80
            // 高宽只给一个值时,自适应
81
            if (bounds.right != 0 | bounds.bottom != 0) {
82
                bounds.right = (int) (bounds.bottom / scale);
83
                drawable.setBounds(bounds);
84
            }
85
            if (bounds.bottom == 0) {
86
                bounds.bottom = (int) (bounds.right * scale);
87
                drawable.setBounds(bounds);
88
            }
89
        }
90
    }
91
92
}

BIN
app/src/main/res/drawable-hdpi/icon_radio_normal.png


BIN
app/src/main/res/drawable-hdpi/icon_radio_selected.png


BIN
app/src/main/res/drawable-mdpi/icon_radio_normal.png


BIN
app/src/main/res/drawable-mdpi/icon_radio_selected.png


BIN
app/src/main/res/drawable-xhdpi/icon_radio_normal.png


BIN
app/src/main/res/drawable-xhdpi/icon_radio_selected.png


BIN
app/src/main/res/drawable-xxhdpi/icon_radio_normal.png


BIN
app/src/main/res/drawable-xxhdpi/icon_radio_selected.png


BIN
app/src/main/res/drawable-xxxhdpi/icon_radio_normal.png


BIN
app/src/main/res/drawable-xxxhdpi/icon_radio_selected.png


+ 8 - 0
app/src/main/res/drawable/bg_add_car_model_shape.xml

@ -0,0 +1,8 @@
1
<?xml version="1.0" encoding="utf-8"?>
2
<shape xmlns:android="http://schemas.android.com/apk/res/android"
3
    android:shape="rectangle">
4
    <corners android:radius="48dp" /> <!-- 圆角大小 -->
5
    <stroke
6
        android:width="1dp"
7
        android:color="#CFE5D6" /> <!-- 边框颜色 -->
8
</shape>

BIN
app/src/main/res/drawable/group_adapter_empty_view_image.png


+ 83 - 0
app/src/main/res/layout/activity_car_brand.xml

@ -0,0 +1,83 @@
1
<?xml version="1.0" encoding="utf-8"?>
2
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
    xmlns:app="http://schemas.android.com/apk/res-auto"
4
    xmlns:tools="http://schemas.android.com/tools"
5
    android:layout_width="match_parent"
6
    android:layout_height="match_parent"
7
    android:background="@color/white"
8
    tools:context=".activity.CarBrandActivity">
9
10
    <androidx.constraintlayout.widget.ConstraintLayout
11
        android:id="@+id/nav_bar"
12
        android:layout_width="match_parent"
13
        android:layout_height="44dp"
14
        app:layout_constraintTop_toTopOf="parent">
15
16
        <TextView
17
            android:id="@+id/nav_title"
18
            android:layout_width="match_parent"
19
            android:layout_height="match_parent"
20
            android:gravity="center"
21
            android:text="品牌"
22
            android:textColor="#444444"
23
            android:textSize="18sp" />
24
25
        <ImageView
26
            android:id="@+id/iv_back"
27
            android:layout_width="wrap_content"
28
            android:layout_height="match_parent"
29
            android:layout_alignParentLeft="true"
30
            android:layout_centerVertical="true"
31
            android:contentDescription="@null"
32
            android:paddingLeft="15dp"
33
            android:paddingRight="15dp"
34
            android:src="@drawable/icon_lvback1119"
35
            app:layout_constraintLeft_toLeftOf="parent" />
36
37
        <View
38
            android:layout_width="match_parent"
39
            android:layout_height="0.5dp"
40
            android:background="@color/ui_titleline"
41
            app:layout_constraintBottom_toBottomOf="parent" />
42
    </androidx.constraintlayout.widget.ConstraintLayout>
43
44
    <com.donkingliang.groupedadapter.widget.StickyHeaderLayout
45
        android:id="@+id/sticky_header_layout"
46
        android:layout_width="match_parent"
47
        android:layout_height="0dp"
48
        app:layout_constraintBottom_toBottomOf="parent"
49
        app:layout_constraintTop_toBottomOf="@+id/nav_bar">
50
51
        <androidx.recyclerview.widget.RecyclerView
52
            android:id="@+id/recycler_view"
53
            android:layout_width="match_parent"
54
            android:layout_height="match_parent" />
55
    </com.donkingliang.groupedadapter.widget.StickyHeaderLayout>
56
57
    <com.electric.chargingpile.view.LetterSideView
58
        android:id="@+id/letter_side_view"
59
        android:layout_width="30dp"
60
        android:layout_height="0dp"
61
        android:background="#F8FBFE"
62
        android:paddingTop="25dp"
63
        android:paddingBottom="25dp"
64
        android:visibility="gone"
65
        app:layout_constraintBottom_toBottomOf="parent"
66
        app:layout_constraintRight_toRightOf="parent"
67
        app:layout_constraintTop_toBottomOf="@+id/nav_bar"
68
        tools:visibility="visible" />
69
70
    <TextView
71
        android:id="@+id/text_view_dialog"
72
        android:layout_width="match_parent"
73
        android:layout_height="0dp"
74
        android:gravity="center"
75
        android:textColor="#CCCCCC"
76
        android:textSize="40sp"
77
        android:visibility="gone"
78
        app:layout_constraintBottom_toBottomOf="parent"
79
        app:layout_constraintTop_toBottomOf="@+id/nav_bar"
80
        tools:text="X"
81
        tools:visibility="visible" />
82
83
</androidx.constraintlayout.widget.ConstraintLayout>

+ 57 - 0
app/src/main/res/layout/activity_car_model.xml

@ -0,0 +1,57 @@
1
<?xml version="1.0" encoding="utf-8"?>
2
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
    xmlns:app="http://schemas.android.com/apk/res-auto"
4
    xmlns:tools="http://schemas.android.com/tools"
5
    android:layout_width="match_parent"
6
    android:layout_height="match_parent"
7
    android:background="@color/white"
8
    tools:context=".activity.CarModelActivity">
9
10
    <androidx.constraintlayout.widget.ConstraintLayout
11
        android:id="@+id/nav_bar"
12
        android:layout_width="match_parent"
13
        android:layout_height="44dp"
14
        app:layout_constraintTop_toTopOf="parent">
15
16
        <TextView
17
            android:id="@+id/nav_title"
18
            android:layout_width="match_parent"
19
            android:layout_height="match_parent"
20
            android:gravity="center"
21
            android:text="车型"
22
            android:textColor="#444444"
23
            android:textSize="18sp" />
24
25
        <ImageView
26
            android:id="@+id/iv_back"
27
            android:layout_width="wrap_content"
28
            android:layout_height="match_parent"
29
            android:layout_alignParentLeft="true"
30
            android:layout_centerVertical="true"
31
            android:contentDescription="@null"
32
            android:paddingLeft="15dp"
33
            android:paddingRight="15dp"
34
            android:src="@drawable/icon_lvback1119"
35
            app:layout_constraintLeft_toLeftOf="parent" />
36
37
        <View
38
            android:layout_width="match_parent"
39
            android:layout_height="0.5dp"
40
            android:background="@color/ui_titleline"
41
            app:layout_constraintBottom_toBottomOf="parent" />
42
    </androidx.constraintlayout.widget.ConstraintLayout>
43
44
    <com.donkingliang.groupedadapter.widget.StickyHeaderLayout
45
        android:id="@+id/sticky_header_layout"
46
        android:layout_width="match_parent"
47
        android:layout_height="0dp"
48
        android:background="#FFF2F6F9"
49
        app:layout_constraintBottom_toBottomOf="parent"
50
        app:layout_constraintTop_toBottomOf="@+id/nav_bar">
51
52
        <androidx.recyclerview.widget.RecyclerView
53
            android:id="@+id/recycler_view"
54
            android:layout_width="match_parent"
55
            android:layout_height="match_parent" />
56
    </com.donkingliang.groupedadapter.widget.StickyHeaderLayout>
57
</androidx.constraintlayout.widget.ConstraintLayout>

+ 363 - 0
app/src/main/res/layout/activity_car_owner_certificate.xml

@ -0,0 +1,363 @@
1
<?xml version="1.0" encoding="utf-8"?>
2
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
    xmlns:app="http://schemas.android.com/apk/res-auto"
4
    xmlns:tools="http://schemas.android.com/tools"
5
    android:layout_width="match_parent"
6
    android:layout_height="match_parent"
7
    android:background="@color/white"
8
    android:focusableInTouchMode="true"
9
    tools:context=".activity.CarOwnerCertificateActivity">
10
11
    <androidx.constraintlayout.widget.ConstraintLayout
12
        android:id="@+id/nav_bar"
13
        android:layout_width="match_parent"
14
        android:layout_height="44dp"
15
        app:layout_constraintTop_toTopOf="parent">
16
17
        <TextView
18
            android:id="@+id/nav_title"
19
            android:layout_width="match_parent"
20
            android:layout_height="match_parent"
21
            android:gravity="center"
22
            android:text="车主认证"
23
            android:textColor="#444444"
24
            android:textSize="18sp" />
25
26
        <ImageView
27
            android:id="@+id/iv_back"
28
            android:layout_width="wrap_content"
29
            android:layout_height="match_parent"
30
            android:layout_alignParentLeft="true"
31
            android:layout_centerVertical="true"
32
            android:contentDescription="@null"
33
            android:paddingLeft="15dp"
34
            android:paddingRight="15dp"
35
            android:src="@drawable/icon_lvback1119"
36
            app:layout_constraintLeft_toLeftOf="parent" />
37
38
        <View
39
            android:layout_width="match_parent"
40
            android:layout_height="0.5dp"
41
            android:background="@color/ui_titleline"
42
            app:layout_constraintBottom_toBottomOf="parent" />
43
    </androidx.constraintlayout.widget.ConstraintLayout>
44
45
    <ScrollView
46
        android:layout_width="match_parent"
47
        android:layout_height="0dp"
48
        android:orientation="vertical"
49
        android:scrollbars="none"
50
        app:layout_constraintBottom_toTopOf="@+id/submit_btn"
51
        app:layout_constraintTop_toBottomOf="@+id/nav_bar">
52
53
        <androidx.constraintlayout.widget.ConstraintLayout
54
            android:layout_width="match_parent"
55
            android:layout_height="wrap_content"
56
            android:paddingLeft="15dp"
57
            android:paddingRight="15dp">
58
59
            <!-- 车型 -->
60
            <androidx.constraintlayout.widget.ConstraintLayout
61
                android:id="@+id/car_model_constraint_layout"
62
                android:layout_width="match_parent"
63
                android:layout_height="0dp"
64
                android:layout_marginTop="15dp"
65
                app:layout_constraintDimensionRatio="h,518:95"
66
                app:layout_constraintTop_toTopOf="parent">
67
68
                <ImageView
69
                    android:id="@+id/add_car_model_icon"
70
                    android:layout_width="match_parent"
71
                    android:layout_height="match_parent"
72
                    android:scaleType="fitXY"
73
                    android:src="@drawable/icon_car_model"
74
                    app:layout_constraintBottom_toBottomOf="parent"
75
                    app:layout_constraintTop_toTopOf="parent" />
76
77
                <TextView
78
                    android:id="@+id/add_car_model_btn"
79
                    android:layout_width="80dp"
80
                    android:layout_height="32dp"
81
                    android:layout_marginRight="15dp"
82
                    android:background="@drawable/bg_add_car_model_shape"
83
                    android:gravity="center"
84
                    android:text="添加车型"
85
                    android:textColor="#506857"
86
                    android:textSize="14sp"
87
                    app:layout_constraintBottom_toBottomOf="parent"
88
                    app:layout_constraintRight_toRightOf="parent"
89
                    app:layout_constraintTop_toTopOf="parent" />
90
            </androidx.constraintlayout.widget.ConstraintLayout>
91
92
            <androidx.constraintlayout.widget.ConstraintLayout
93
                android:id="@+id/car_model_selected_constraint_layout"
94
                android:layout_width="match_parent"
95
                android:layout_height="wrap_content"
96
                android:layout_marginTop="15dp"
97
                android:background="@color/white"
98
                android:visibility="gone"
99
                app:layout_constraintTop_toBottomOf="@+id/car_model_constraint_layout"
100
                tools:background="#cccccc"
101
                tools:visibility="visible">
102
103
                <ImageView
104
                    android:id="@+id/car_icon"
105
                    android:layout_width="95dp"
106
                    android:layout_height="63dp"
107
                    android:scaleType="fitCenter"
108
                    app:layout_constraintBottom_toBottomOf="parent"
109
                    app:layout_constraintLeft_toLeftOf="parent"
110
                    app:layout_constraintTop_toTopOf="parent"
111
                    tools:background="#00ff00" />
112
113
                <TextView
114
                    android:id="@+id/car_name"
115
                    android:layout_width="wrap_content"
116
                    android:layout_height="wrap_content"
117
                    android:layout_marginLeft="10dp"
118
                    android:layout_marginTop="12dp"
119
                    android:textColor="#FF222222"
120
                    android:textSize="14sp"
121
                    app:layout_constraintLeft_toRightOf="@+id/car_icon"
122
                    app:layout_constraintTop_toTopOf="parent"
123
                    tools:text="蔚来ES6" />
124
125
                <TextView
126
                    android:id="@+id/car_series"
127
                    android:layout_width="wrap_content"
128
                    android:layout_height="wrap_content"
129
                    android:layout_marginBottom="10dp"
130
                    android:textColor="#FF0D1120"
131
                    android:textSize="14sp"
132
                    app:layout_constraintBottom_toBottomOf="parent"
133
                    app:layout_constraintLeft_toLeftOf="@+id/car_name"
134
135
                    tools:text="2020款 420KM 运动版" />
136
137
                <ImageView
138
                    android:layout_width="wrap_content"
139
                    android:layout_height="wrap_content"
140
                    android:src="@drawable/icon_right_cursor"
141
                    app:layout_constraintBottom_toBottomOf="parent"
142
                    app:layout_constraintRight_toRightOf="parent"
143
                    app:layout_constraintTop_toTopOf="parent" />
144
145
146
            </androidx.constraintlayout.widget.ConstraintLayout>
147
148
149
            <!-- 行驶证图片 -->
150
            <androidx.constraintlayout.widget.ConstraintLayout
151
                android:id="@+id/driving_license"
152
                android:layout_width="match_parent"
153
                android:layout_height="0dp"
154
                android:layout_marginTop="10dp"
155
                app:layout_constraintDimensionRatio="h,518:315"
156
                app:layout_constraintTop_toBottomOf="@+id/car_model_selected_constraint_layout">
157
158
                <ImageView
159
                    android:id="@+id/driving_license_icon"
160
                    android:layout_width="match_parent"
161
                    android:layout_height="match_parent"
162
                    android:src="@drawable/icon_driving_license" />
163
164
                <TextView
165
                    android:id="@+id/driving_license_text_view"
166
                    android:layout_width="wrap_content"
167
                    android:layout_height="wrap_content"
168
                    android:text="上传行驶证首页(选填)"
169
                    android:textColor="#3D5545"
170
                    android:textSize="14sp"
171
                    app:layout_constraintBottom_toBottomOf="parent"
172
                    app:layout_constraintLeft_toLeftOf="parent"
173
                    app:layout_constraintRight_toRightOf="parent"
174
                    app:layout_constraintTop_toTopOf="parent" />
175
176
                <ImageView
177
                    android:id="@+id/driving_license_upload_icon"
178
                    android:layout_width="wrap_content"
179
                    android:layout_height="wrap_content"
180
                    android:layout_marginBottom="5dp"
181
                    android:src="@drawable/icon_upload"
182
                    app:layout_constraintBottom_toTopOf="@+id/driving_license_text_view"
183
                    app:layout_constraintLeft_toLeftOf="parent"
184
                    app:layout_constraintRight_toRightOf="parent" />
185
186
            </androidx.constraintlayout.widget.ConstraintLayout>
187
188
            <!-- 行驶证信息 -->
189
            <LinearLayout
190
                android:id="@+id/driving_license_info"
191
                android:layout_width="match_parent"
192
                android:layout_height="wrap_content"
193
                android:layout_marginTop="5dp"
194
                android:layout_marginBottom="50dp"
195
                android:orientation="vertical"
196
                app:layout_constraintTop_toBottomOf="@+id/driving_license">
197
198
                <LinearLayout
199
                    android:layout_width="match_parent"
200
                    android:layout_height="50dp"
201
                    android:gravity="center_vertical"
202
                    android:orientation="horizontal">
203
204
                    <TextView
205
                        android:layout_width="90dp"
206
                        android:layout_height="wrap_content"
207
                        android:text="* 车牌号"
208
                        android:textColor="#0D1120"
209
                        android:textSize="14sp"
210
                        android:textStyle="bold" />
211
212
                    <EditText
213
                        android:layout_width="0dp"
214
                        android:layout_height="match_parent"
215
                        android:layout_weight="1"
216
                        android:background="@null"
217
                        android:hint="请输入正确的车牌号"
218
                        android:inputType="text"
219
                        android:textColor="#0D1120"
220
                        android:textColorHint="#CBCBCB"
221
                        android:textSize="14sp" />
222
                </LinearLayout>
223
224
                <View
225
                    android:layout_width="match_parent"
226
                    android:layout_height="1dp"
227
                    android:background="#F8F8F8" />
228
229
                <LinearLayout
230
                    android:layout_width="match_parent"
231
                    android:layout_height="50dp"
232
                    android:gravity="center_vertical"
233
                    android:orientation="horizontal">
234
235
                    <TextView
236
                        android:layout_width="90dp"
237
                        android:layout_height="wrap_content"
238
                        android:text="* 发动机号"
239
                        android:textColor="#0D1120"
240
                        android:textSize="14sp"
241
                        android:textStyle="bold" />
242
243
                    <EditText
244
                        android:layout_width="0dp"
245
                        android:layout_height="match_parent"
246
                        android:layout_weight="1"
247
                        android:background="@null"
248
                        android:hint="请输入发动机号"
249
                        android:inputType="text"
250
                        android:textColor="#0D1120"
251
                        android:textColorHint="#CBCBCB"
252
                        android:textSize="14sp" />
253
                </LinearLayout>
254
255
                <View
256
                    android:layout_width="match_parent"
257
                    android:layout_height="1dp"
258
                    android:background="#F8F8F8" />
259
260
                <LinearLayout
261
                    android:layout_width="match_parent"
262
                    android:layout_height="50dp"
263
                    android:gravity="center_vertical"
264
                    android:orientation="horizontal">
265
266
                    <TextView
267
                        android:layout_width="90dp"
268
                        android:layout_height="wrap_content"
269
                        android:text="注册时间"
270
                        android:textColor="#0D1120"
271
                        android:textSize="14sp"
272
                        android:textStyle="bold" />
273
274
                    <EditText
275
                        android:layout_width="0dp"
276
                        android:layout_height="match_parent"
277
                        android:layout_weight="1"
278
                        android:background="@null"
279
                        android:hint="请输入有效日期"
280
                        android:inputType="text"
281
                        android:textColor="#0D1120"
282
                        android:textColorHint="#CBCBCB"
283
                        android:textSize="14sp" />
284
                </LinearLayout>
285
286
                <View
287
                    android:layout_width="match_parent"
288
                    android:layout_height="1dp"
289
                    android:background="#F8F8F8" />
290
            </LinearLayout>
291
            <!-- 行驶证类型 -->
292
            <LinearLayout
293
                android:id="@+id/driving_license_type"
294
                android:layout_width="match_parent"
295
                android:layout_height="50dp"
296
                android:layout_marginTop="10dp"
297
                android:gravity="center_vertical"
298
                android:orientation="horizontal"
299
                app:layout_constraintTop_toBottomOf="@+id/driving_license_info">
300
301
                <com.electric.chargingpile.view.TextImageView
302
                    android:id="@+id/driving_license_type_first"
303
                    android:layout_width="wrap_content"
304
                    android:layout_height="match_parent"
305
                    android:drawableLeft="@drawable/icon_radio_selected"
306
                    android:drawablePadding="10dp"
307
                    android:gravity="center_vertical"
308
                    android:paddingRight="40dp"
309
                    android:text="自用"
310
                    app:drawableLeftHeight="17dp"
311
                    app:drawableLeftWidth="17dp" />
312
313
                <com.electric.chargingpile.view.TextImageView
314
                    android:id="@+id/driving_license_type_second"
315
                    android:layout_width="wrap_content"
316
                    android:layout_height="match_parent"
317
                    android:drawableLeft="@drawable/icon_radio_normal"
318
                    android:drawablePadding="10dp"
319
                    android:gravity="center_vertical"
320
                    android:paddingRight="40dp"
321
                    android:text="营运"
322
                    app:drawableLeftHeight="17dp"
323
                    app:drawableLeftWidth="17dp" />
324
325
326
                <com.electric.chargingpile.view.TextImageView
327
                    android:id="@+id/driving_license_type_third"
328
                    android:layout_width="wrap_content"
329
                    android:layout_height="match_parent"
330
                    android:drawableLeft="@drawable/icon_radio_normal"
331
                    android:drawablePadding="10dp"
332
                    android:gravity="center_vertical"
333
                    android:paddingRight="40dp"
334
                    android:text="公务"
335
                    app:drawableLeftHeight="17dp"
336
                    app:drawableLeftWidth="17dp" />
337
338
            </LinearLayout>
339
            <!-- 认证说明信息 -->
340
            <TextView
341
                android:layout_width="match_parent"
342
                android:layout_height="wrap_content"
343
                android:layout_marginTop="10dp"
344
                android:layout_marginBottom="30dp"
345
                android:text="认证说明\n\n1.车型信息和行驶证主页为必填项;\n2.最多可认证三款车型;\n3.默认首款认证车型为主车型;\n4.上传行驶证详细页面,并保证所有信息清晰;\n5.认证成功的首个车型可获得50元充电红包。"
346
                android:textColor="#0D1120"
347
                android:textSize="14sp"
348
                app:layout_constraintBottom_toBottomOf="parent"
349
                app:layout_constraintTop_toBottomOf="@+id/driving_license_type" />
350
        </androidx.constraintlayout.widget.ConstraintLayout>
351
    </ScrollView>
352
353
    <Button
354
        android:id="@+id/submit_btn"
355
        android:layout_width="match_parent"
356
        android:layout_height="44dp"
357
        android:background="#00CA42"
358
        android:text="确认提交"
359
        android:textColor="#ffffff"
360
        android:textSize="16sp"
361
        app:layout_constraintBottom_toBottomOf="parent" />
362
363
</androidx.constraintlayout.widget.ConstraintLayout>

+ 81 - 0
app/src/main/res/layout/activity_user_center.xml

@ -479,6 +479,87 @@
479 479
                        android:layout_width="match_parent"
480 480
                        android:layout_height="0.5dp"
481 481
                        android:background="@color/ui_line" />
482
                    <RelativeLayout
483
                        android:id="@+id/rl_car_owner_certificate"
484
                        android:layout_width="fill_parent"
485
                        android:layout_height="44dp"
486
                        android:background="@drawable/item_selector">
487
488
                        <TextView
489
                            android:layout_width="wrap_content"
490
                            android:layout_height="wrap_content"
491
                            android:layout_alignParentStart="true"
492
                            android:layout_alignParentLeft="true"
493
                            android:layout_alignParentTop="true"
494
                            android:layout_alignParentBottom="true"
495
                            android:layout_marginLeft="15dp"
496
                            android:drawableLeft="@drawable/icon_car_user_certificate"
497
                            android:drawablePadding="15dp"
498
                            android:gravity="center_vertical"
499
                            android:text="车主认证"
500
                            android:textColor="@color/ui_62"
501
                            android:textSize="15sp" />
502
503
                        <TextView
504
                            android:layout_width="wrap_content"
505
                            android:layout_height="wrap_content"
506
                            android:layout_alignParentTop="true"
507
                            android:layout_alignParentRight="true"
508
                            android:layout_alignParentBottom="true"
509
                            android:layout_marginRight="15dp"
510
                            android:drawableRight="@drawable/icon_more2_0"
511
                            android:drawablePadding="30px"
512
                            android:gravity="center_vertical"
513
                            android:text=""
514
                            android:textColor="@color/ui_68"
515
                            android:textSize="14sp" />
516
                    </RelativeLayout>
517
                    <View
518
                        android:layout_width="match_parent"
519
                        android:layout_height="0.5dp"
520
                        android:layout_marginLeft="16dp"
521
                        android:background="@color/ui_line" />
522
523
                    <RelativeLayout
524
                        android:id="@+id/rl_publish_price"
525
                        android:layout_width="fill_parent"
526
                        android:layout_height="44dp"
527
                        android:background="@drawable/item_selector">
528
529
                        <TextView
530
                            android:layout_width="wrap_content"
531
                            android:layout_height="wrap_content"
532
                            android:layout_alignParentStart="true"
533
                            android:layout_alignParentLeft="true"
534
                            android:layout_alignParentTop="true"
535
                            android:layout_alignParentBottom="true"
536
                            android:layout_marginLeft="15dp"
537
                            android:drawableLeft="@drawable/icon_publish_price"
538
                            android:drawablePadding="15dp"
539
                            android:gravity="center_vertical"
540
                            android:text="发表成交价"
541
                            android:textColor="@color/ui_62"
542
                            android:textSize="15sp" />
543
544
                        <TextView
545
                            android:layout_width="wrap_content"
546
                            android:layout_height="wrap_content"
547
                            android:layout_alignParentTop="true"
548
                            android:layout_alignParentRight="true"
549
                            android:layout_alignParentBottom="true"
550
                            android:layout_marginRight="15dp"
551
                            android:drawableRight="@drawable/icon_more2_0"
552
                            android:drawablePadding="30px"
553
                            android:gravity="center_vertical"
554
                            android:text=""
555
                            android:textColor="@color/ui_68"
556
                            android:textSize="14sp" />
557
                    </RelativeLayout>
558
                    <View
559
                        android:layout_width="match_parent"
560
                        android:layout_height="0.5dp"
561
                        android:layout_marginLeft="16dp"
562
                        android:background="@color/ui_line" />
482 563
483 564
                    <RelativeLayout
484 565
                        android:id="@+id/rl_chongzhi"

+ 42 - 0
app/src/main/res/layout/adapter_child_car_brand.xml

@ -0,0 +1,42 @@
1
<?xml version="1.0" encoding="utf-8"?>
2
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
    xmlns:app="http://schemas.android.com/apk/res-auto"
4
    xmlns:tools="http://schemas.android.com/tools"
5
    android:layout_width="match_parent"
6
    android:layout_height="55dp"
7
    android:orientation="vertical"
8
    android:paddingLeft="15dp"
9
    android:background="@color/white"
10
    tools:background="#cccccc">
11
12
    <View
13
        android:id="@+id/line"
14
        android:layout_width="match_parent"
15
        android:layout_height="1dp"
16
        android:background="#E6E6E6"
17
        app:layout_constraintTop_toTopOf="parent" />
18
19
    <ImageView
20
        android:id="@+id/icon"
21
        android:layout_width="40dp"
22
        android:layout_height="40dp"
23
        android:scaleType="fitCenter"
24
        app:layout_constraintBottom_toBottomOf="parent"
25
        app:layout_constraintLeft_toLeftOf="parent"
26
        app:layout_constraintTop_toTopOf="parent"
27
        tools:background="#00ff00" />
28
29
    <TextView
30
        android:id="@+id/title"
31
        android:layout_width="wrap_content"
32
        android:layout_height="wrap_content"
33
        android:layout_gravity="center_vertical"
34
        android:layout_marginLeft="10dp"
35
        android:textColor="#FF222222"
36
        android:textSize="14sp"
37
        app:layout_constraintBottom_toBottomOf="parent"
38
        app:layout_constraintLeft_toRightOf="@+id/icon"
39
        app:layout_constraintTop_toTopOf="parent"
40
        tools:text="奥迪" />
41
42
</androidx.constraintlayout.widget.ConstraintLayout>

+ 77 - 0
app/src/main/res/layout/adapter_child_car_model.xml

@ -0,0 +1,77 @@
1
<?xml version="1.0" encoding="utf-8"?>
2
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
    xmlns:app="http://schemas.android.com/apk/res-auto"
4
    xmlns:tools="http://schemas.android.com/tools"
5
    android:layout_width="match_parent"
6
    android:layout_height="100dp"
7
    android:paddingLeft="15dp"
8
    android:background="@color/white"
9
    tools:background="#cccccc">
10
11
    <View
12
        android:id="@+id/line"
13
        android:layout_width="match_parent"
14
        android:layout_height="1dp"
15
        android:background="#E6E6E6"
16
        app:layout_constraintTop_toTopOf="parent" />
17
18
    <ImageView
19
        android:id="@+id/icon"
20
        android:layout_width="120dp"
21
        android:layout_height="80dp"
22
        android:scaleType="fitCenter"
23
        app:layout_constraintBottom_toBottomOf="parent"
24
        app:layout_constraintLeft_toLeftOf="parent"
25
        app:layout_constraintTop_toTopOf="parent"
26
        tools:background="#00ff00" />
27
28
    <TextView
29
        android:id="@+id/title"
30
        android:layout_width="wrap_content"
31
        android:layout_height="wrap_content"
32
        android:layout_gravity="center_vertical"
33
        android:layout_marginLeft="10dp"
34
        android:layout_marginTop="27dp"
35
        android:textColor="#FF222222"
36
        android:textSize="14sp"
37
        app:layout_constraintLeft_toRightOf="@+id/icon"
38
        app:layout_constraintTop_toTopOf="parent"
39
        tools:text="奥迪" />
40
41
    <LinearLayout
42
        android:layout_width="wrap_content"
43
        android:layout_height="wrap_content"
44
        android:layout_marginLeft="10dp"
45
        android:layout_marginBottom="28dp"
46
        android:orientation="horizontal"
47
        app:layout_constraintBottom_toBottomOf="parent"
48
        app:layout_constraintLeft_toRightOf="@+id/icon">
49
50
        <TextView
51
            android:layout_width="wrap_content"
52
            android:layout_height="wrap_content"
53
            android:textColor="#FFE02020"
54
            android:textSize="14sp"
55
            tools:text="33.8-52.3" />
56
57
        <TextView
58
            android:id="@+id/price"
59
            android:layout_width="wrap_content"
60
            android:layout_height="wrap_content"
61
            android:layout_gravity="center_vertical"
62
            android:layout_marginLeft="5dp"
63
            android:text="万"
64
            android:textColor="#FF222222"
65
            android:textSize="12sp" />
66
67
        <TextView
68
            android:id="@+id/endurance"
69
            android:layout_width="wrap_content"
70
            android:layout_height="wrap_content"
71
            android:layout_marginLeft="20dp"
72
            android:textColor="#FF222222"
73
            android:textSize="12sp"
74
            tools:text="续航:300km" />
75
    </LinearLayout>
76
77
</androidx.constraintlayout.widget.ConstraintLayout>

+ 19 - 0
app/src/main/res/layout/adapter_header_car_brand.xml

@ -0,0 +1,19 @@
1
<?xml version="1.0" encoding="utf-8"?>
2
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
    xmlns:tools="http://schemas.android.com/tools"
4
    android:layout_width="match_parent"
5
    android:layout_height="25dp"
6
    android:background="#FFF2F6F9"
7
    android:paddingLeft="15dp"
8
    android:paddingRight="15dp">
9
    
10
    <TextView
11
        android:id="@+id/title"
12
        android:layout_width="match_parent"
13
        android:layout_height="match_parent"
14
        android:gravity="center_vertical"
15
        android:lines="1"
16
        android:textColor="#FF6F6F7D"
17
        android:textSize="12sp"
18
        tools:text="A" />
19
</LinearLayout>

+ 19 - 0
app/src/main/res/layout/adapter_header_car_model.xml

@ -0,0 +1,19 @@
1
<?xml version="1.0" encoding="utf-8"?>
2
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
    xmlns:tools="http://schemas.android.com/tools"
4
    android:layout_width="match_parent"
5
    android:layout_height="25dp"
6
    android:background="#FFF2F6F9"
7
    android:paddingLeft="15dp"
8
    android:paddingRight="15dp">
9
    
10
    <TextView
11
        android:id="@+id/title"
12
        android:layout_width="match_parent"
13
        android:layout_height="match_parent"
14
        android:gravity="center_vertical"
15
        android:lines="1"
16
        android:textColor="#FF6F6F7D"
17
        android:textSize="12sp"
18
        tools:text="A" />
19
</LinearLayout>

+ 13 - 0
app/src/main/res/layout/group_adapter_default_empty_view.xml

@ -0,0 +1,13 @@
1
<?xml version="1.0" encoding="utf-8"?>
2
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
    android:layout_width="match_parent"
4
    android:layout_height="match_parent"
5
    android:orientation="vertical">
6
7
    <ImageView
8
        android:layout_width="wrap_content"
9
        android:layout_height="wrap_content"
10
        android:layout_gravity="center"
11
        android:src="@drawable/group_adapter_empty_view_image"/>
12
13
</FrameLayout>

+ 5 - 0
app/src/main/res/values/strings.xml

@ -208,4 +208,9 @@
208 208
    <string name="personal_shar_info_content">快来分享吧\n小主大家都很期待你的精彩内容哦</string>
209 209
    <string name="query_all_addresses"><u>查看全部目的地</u></string>
210 210
    <string name="query_all_points"><u>查看全部站点</u></string>
211
212
    <item name="type_header" type="integer" />
213
    <item name="type_footer" type="integer" />
214
    <item name="type_child" type="integer" />
215
    <item name="type_empty" type="integer" />
211 216
</resources>

+ 11 - 0
app/src/main/res/values/styles.xml

@ -355,4 +355,15 @@
355 355
        <!--相册文件夹列表选中图标-->
356 356
        <item name="picture.folder_checked_dot">@drawable/picture_orange_oval</item>
357 357
    </style>
358

359
    <declare-styleable name="TextImageView">
360
        <attr name="drawableLeftWidth" format="dimension" />
361
        <attr name="drawableLeftHeight" format="dimension" />
362
        <attr name="drawableTopWidth" format="dimension" />
363
        <attr name="drawableTopHeight" format="dimension" />
364
        <attr name="drawableRightWidth" format="dimension" />
365
        <attr name="drawableRightHeight" format="dimension" />
366
        <attr name="drawableBottomWidth" format="dimension" />
367
        <attr name="drawableBottomHeight" format="dimension" />
368
    </declare-styleable>
358 369
</resources>

个人信息修改完成 · 2e20fd70e1 - Gogs: Go Git Service
Browse Source

个人信息修改完成

huyuguo 5 years ago
parent
commit
2e20fd70e1

+ 34 - 0
app/src/main/java/com/electric/chargingpile/activity/CarOwnerCertificateActivity.java

@ -1,6 +1,7 @@
1 1
package com.electric.chargingpile.activity;
2 2
3 3
import androidx.annotation.NonNull;
4
import androidx.annotation.Nullable;
4 5
import androidx.appcompat.app.AppCompatActivity;
5 6
import androidx.constraintlayout.widget.ConstraintLayout;
6 7
@ -25,6 +26,12 @@ import android.widget.TextView;
25 26
import android.widget.Toast;
26 27
27 28
import com.bumptech.glide.Glide;
29
import com.bumptech.glide.load.engine.DiskCacheStrategy;
30
import com.bumptech.glide.request.Request;
31
import com.bumptech.glide.request.target.CustomTarget;
32
import com.bumptech.glide.request.target.SizeReadyCallback;
33
import com.bumptech.glide.request.target.Target;
34
import com.bumptech.glide.request.transition.Transition;
28 35
import com.electric.chargingpile.R;
29 36
import com.electric.chargingpile.application.MainApplication;
30 37
import com.electric.chargingpile.data.CarOwnerCertificateBean;
@ -196,6 +203,33 @@ public class CarOwnerCertificateActivity extends AppCompatActivity implements Vi
196 203
            Gson gson = new Gson();
197 204
            CarSerieEvent event = new CarSerieEvent(gson.fromJson(carOwnerCertificateBean.getChexing(), CarSeriesEntity.class));
198 205
            onCarSeriesMessage(event);
206
207
            if (!TextUtils.isEmpty(carOwnerCertificateBean.getLicense_img1())) {
208
209
                Glide.with(this).asBitmap().load(MainApplication.pic_url + carOwnerCertificateBean.getLicense_img1()).diskCacheStrategy(DiskCacheStrategy.ALL).into(new CustomTarget<Bitmap>() {
210
                    @Override
211
                    public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
212
                        driving_license_icon.setImageBitmap(resource);
213
                        String base64 = bitmapToBase64(resource);
214
                        drivingLicenseBase64Data = "data:image/png;base64," + base64;
215
                    }
216
217
                    @Override
218
                    public void onLoadCleared(@Nullable Drawable placeholder) {
219
220
                    }
221
                });
222
//                Glide.with(this).load(MainApplication.pic_url + carOwnerCertificateBean.getLicense_img1()).into(driving_license_icon);
223
                driving_license_upload_icon.setVisibility(View.GONE);
224
                driving_license_text_view.setVisibility(View.GONE);
225
                driving_license_info.setVisibility(View.VISIBLE);
226
                plate_num.setText(carOwnerCertificateBean.getPlate_number());
227
                engine_num.setText(carOwnerCertificateBean.getEngine_number());
228
                register_date.setText(carOwnerCertificateBean.getRegdate());
229
            }
230
231
232
199 233
            if ("自用".equals(carOwnerCertificateBean.getCartype())) {
200 234
                drivingLicenseType = "自用";
201 235
                driving_license_type_first.setCompoundDrawables(selected, null, null, null);

+ 34 - 11
app/src/main/java/com/electric/chargingpile/activity/UserCenterActivity.java

@ -57,6 +57,7 @@ import com.electric.chargingpile.util.NetUtil;
57 57
import com.electric.chargingpile.util.OkHttpUtil;
58 58
import com.electric.chargingpile.util.PicassoUtil;
59 59
import com.electric.chargingpile.util.Util;
60
import com.electric.chargingpile.view.AlertDialogTwo;
60 61
import com.electric.chargingpile.view.ObservableScrollView;
61 62
import com.electric.chargingpile.view.RoundImageView;
62 63
import com.electric.chargingpile.view.ScrollViewListener;
@ -787,7 +788,7 @@ public class UserCenterActivity extends Activity implements View.OnClickListener
787 788
                    Toast.makeText(getApplication(), "请先登录", Toast.LENGTH_SHORT).show();
788 789
                    startActivity(new Intent(getApplication(), LoginActivity.class));
789 790
                } else {
790
                    getCarOwnerCertificateList();
791
                    getCarOwnerCertificateList("certificate");
791 792
                }
792 793
                break;
793 794
            case R.id.rl_publish_price: // 发表成交价
@ -795,11 +796,9 @@ public class UserCenterActivity extends Activity implements View.OnClickListener
795 796
                    Toast.makeText(getApplication(), "请先登录", Toast.LENGTH_SHORT).show();
796 797
                    startActivity(new Intent(getApplication(), LoginActivity.class));
797 798
                } else {
798
                    // TODO 跳转html
799
                    System.out.println("come on");
799
                    getCarOwnerCertificateList("price");
800 800
                }
801 801
                break;
802
803 802
            case R.id.rl_chongzhi:
804 803
                if (!MainApplication.isLogin()) {
805 804
                    Toast.makeText(getApplication(), "请先登录", Toast.LENGTH_SHORT).show();
@ -1058,9 +1057,9 @@ public class UserCenterActivity extends Activity implements View.OnClickListener
1058 1057
        });
1059 1058
    }
1060 1059
1061
    private void getCarOwnerCertificateList() {
1060
    private void getCarOwnerCertificateList(String from) {
1062 1061
        loadDialog.show();
1063
        String url = MainApplication.url + "/zhannew/basic/web/index.php/car/my?userid=" + MainApplication.userId ;
1062
        String url = MainApplication.url + "/zhannew/basic/web/index.php/car/my?userid=" + MainApplication.userId;
1064 1063
        OkHttpUtils.get().url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
1065 1064
            @Override
1066 1065
            public void onError(Call call, Exception e) {
@ -1076,12 +1075,36 @@ public class UserCenterActivity extends Activity implements View.OnClickListener
1076 1075
                if ("01".equals(rtnCode)) {
1077 1076
                    String data = JsonUtils.getKeyResult(response, "data");
1078 1077
                    List<CarOwnerCertificateBean> list = JsonUtils.parseToObjectList(data, CarOwnerCertificateBean.class);
1079
                    if (list.size() == 0) {
1080
                        startActivity(new Intent(getApplication(), CarOwnerCertificateActivity.class));
1078
                    if ("price".equals(from)) {
1079
                        if (list.size() == 0) {
1080
                            new AlertDialogTwo(UserCenterActivity.this).builder()
1081
                                    .setMsg("您还没有认证车主,认证车主可获双倍奖励哦。")
1082
                                    .setPositiveButton("继续发表", new View.OnClickListener() {
1083
                                        @Override
1084
                                        public void onClick(View v) {
1085
                                            Intent intent = new Intent(getApplication(), MyWebViewActivity.class);
1086
                                            intent.putExtra("url", "https://www.d1ev.com/special/models/wap/webView/index.html");
1087
                                            startActivity(intent);
1088
                                        }
1089
                                    }).setNegativeButton("去认证", new View.OnClickListener() {
1090
                                @Override
1091
                                public void onClick(View v) {
1092
                                    startActivity(new Intent(getApplication(), CarOwnerCertificateActivity.class));
1093
                                }
1094
                            }).show();
1095
                        } else {
1096
                            Intent intent = new Intent(getApplication(), MyWebViewActivity.class);
1097
                            intent.putExtra("url", "https://www.d1ev.com/special/models/wap/webView/index.html");
1098
                            startActivity(intent);
1099
                        }
1081 1100
                    } else {
1082
                        Intent intent = new Intent(getApplication(), CarOwnerCertificateListActivity.class);
1083
                        intent.putExtra("data", data);
1084
                        startActivity(intent);
1101
                        if (list.size() == 0) {
1102
                            startActivity(new Intent(getApplication(), CarOwnerCertificateActivity.class));
1103
                        } else {
1104
                            Intent intent = new Intent(getApplication(), CarOwnerCertificateListActivity.class);
1105
                            intent.putExtra("data", data);
1106
                            startActivity(intent);
1107
                        }
1085 1108
                    }
1086 1109
                } else {
1087 1110
                    String rtnMsg = JsonUtils.getKeyResult(response, "rtnMsg");

+ 106 - 313
app/src/main/java/com/electric/chargingpile/activity/UserInfoActivity.java

@ -22,7 +22,9 @@ import android.os.Environment;
22 22
import android.os.Handler;
23 23
import android.os.Message;
24 24
import android.provider.MediaStore;
25
25 26
import androidx.core.content.FileProvider;
27
26 28
import android.text.TextUtils;
27 29
import android.util.Log;
28 30
import android.view.Gravity;
@ -47,8 +49,10 @@ import android.widget.ToggleButton;
47 49
48 50
import com.electric.chargingpile.R;
49 51
import com.electric.chargingpile.application.MainApplication;
52
import com.electric.chargingpile.data.CarOwnerCertificateBean;
50 53
import com.electric.chargingpile.data.Cars;
51 54
import com.electric.chargingpile.data.Province;
55
import com.electric.chargingpile.entity.CarSeriesEntity;
52 56
import com.electric.chargingpile.manager.ProfileManager;
53 57
import com.electric.chargingpile.util.BarColorUtil;
54 58
import com.electric.chargingpile.util.DES3;
@ -60,14 +64,18 @@ import com.electric.chargingpile.util.PhotoUtils;
60 64
import com.electric.chargingpile.util.StatusConstants;
61 65
import com.electric.chargingpile.util.ToastUtil;
62 66
import com.electric.chargingpile.util.UploadUtil;
67
import com.electric.chargingpile.view.AlertDialogTwo;
63 68
import com.electric.chargingpile.view.CustomProgressDialog;
64 69
import com.electric.chargingpile.view.RoundImageView;
65 70
import com.electric.chargingpile.view.xrichtext.SDCardUtil;
71
import com.google.gson.Gson;
66 72
import com.squareup.okhttp.Request;
67 73
import com.squareup.okhttp.Response;
68 74
import com.squareup.picasso.Picasso;
69 75
import com.squareup.picasso.Target;
70 76
import com.umeng.analytics.MobclickAgent;
77
import com.zhy.http.okhttp.OkHttpUtils;
78
import com.zhy.http.okhttp.callback.StringCallback;
71 79
72 80
import org.json.JSONArray;
73 81
import org.json.JSONException;
@ -83,6 +91,7 @@ import java.util.HashMap;
83 91
import java.util.List;
84 92
import java.util.Map;
85 93
94
import okhttp3.Call;
86 95
import pub.devrel.easypermissions.AfterPermissionGranted;
87 96
import pub.devrel.easypermissions.EasyPermissions;
88 97
@ -92,17 +101,14 @@ public class UserInfoActivity extends Activity implements View.OnClickListener,
92 101
    private ImageView back;
93 102
    private EditText et_nickName;
94 103
    private EditText et_realName;
95
    private TextView et_che;
96 104
    private ToggleButton btn_sex, btn_car;
97
    private RelativeLayout rl_icon, rl_select_car, rl_isBuy;
105
    private RelativeLayout rl_icon;
98 106
    private Button cancleButton, btn_one, btn_two;
99 107
    private PopupWindow popupWindow;
100 108
    private View popupWindowView;
101 109
    private RoundImageView iconPic;
102 110
    private TextView tv_save, onclick;
103 111
    private String sex = "1";
104
    private String nocar = "";
105
    private String havecar = "";
106 112
    private Bitmap download_bmp;
107 113
    LoadingDialog dialog;
108 114
    String name0 = "";
@ -124,9 +130,8 @@ public class UserInfoActivity extends Activity implements View.OnClickListener,
124 130
    String chexing;
125 131
    String yichexing;
126 132
    private ImageView point;
127
    public static final int REQUSET = 11;
128 133
    String select_pinpai = "", select_chexing = "";
129
    private TextView tv_point, tv_buy;
134
    private TextView tv_point;
130 135
    private RelativeLayout rl_point;
131 136
    private android.view.animation.Animation animation;
132 137
    private File fileUri = new File(Environment.getExternalStorageDirectory().getPath() + "/photo.jpg");
@ -134,6 +139,13 @@ public class UserInfoActivity extends Activity implements View.OnClickListener,
134 139
    private Uri imageUri;
135 140
    private Uri cropImageUri;
136 141
    private static final int RC_CAMERA_PERM = 123;
142
    private LoadingDialog loadDialog;
143
    // 1.去认证车主(获得充电优惠)      > 2.认证车主             审核中  3.认证车主             宝马
144
    private int certificateStatus = 0; // 1 去认证  2审核中  3认证车主
145
    private RelativeLayout go_certificate;
146
    private TextView go_title;
147
    private TextView go_desc;
148
    private ImageView go_cursor;
137 149
138 150
    @Override
139 151
    protected void onCreate(Bundle savedInstanceState) {
@ -144,28 +156,21 @@ public class UserInfoActivity extends Activity implements View.OnClickListener,
144 156
        dialog.setCanceledOnTouchOutside(false);
145 157
        mContext = this;
146 158
        initView();
147
//        getFromServer();
148 159
        spinner();
149 160
        getFromServer();
150 161
    }
151 162
152 163
    public void onEventMainThread(Province b) {
153
        Log.e("ffff", b.getName() + "   " + b.getCities().get(b.getId()).getName());
154
//        Toast.makeText(this, b.getName()+ "   " + b.getCities().get(b.getId()).getName(), Toast.LENGTH_SHORT).show();
155
        et_che.setText(b.getName() + " - " + b.getCities().get(b.getId()).getName());
156 164
        car_brand = b.getName();
157 165
        car_type = b.getCities().get(b.getId()).getName();
158 166
    }
159 167
160 168
    private void initView() {
161
        tv_buy = (TextView) findViewById(R.id.tv_buy);
169
        loadDialog = new LoadingDialog(this);
170
        loadDialog.setCanceledOnTouchOutside(false);
162 171
        rl_point = (RelativeLayout) findViewById(R.id.rl_point);
163
        rl_isBuy = (RelativeLayout) findViewById(R.id.rl_isBuy);
164
        rl_isBuy.setOnClickListener(this);
165 172
        tv_point = (TextView) findViewById(R.id.tv_point);
166 173
        animation = AnimationUtils.loadAnimation(UserInfoActivity.this, R.anim.nn);
167
        rl_select_car = (RelativeLayout) findViewById(R.id.rl_select_car);
168
        rl_select_car.setOnClickListener(this);
169 174
170 175
        animation = AnimationUtils.loadAnimation(UserInfoActivity.this, R.anim.nn);
171 176
        point = (ImageView) findViewById(R.id.tv_one);
@ -179,20 +184,11 @@ public class UserInfoActivity extends Activity implements View.OnClickListener,
179 184
            }
180 185
        });
181 186
        et_realName = (EditText) findViewById(R.id.et_realName);
182
        et_che = (TextView) findViewById(R.id.et_che);
183 187
        Log.e(TAG, "initView: " + MainApplication.userCar);
184 188
        if (MainApplication.userCar.equals("")) {
185
            tv_buy.setText("");
186
            rl_select_car.setVisibility(View.GONE);
187 189
        } else if ("待购".equals(MainApplication.userCar)) {
188
            tv_buy.setText("未购买");
189
            rl_select_car.setVisibility(View.GONE);
190
            et_che.setText("");
191 190
        } else {
192 191
            String car = MainApplication.userCar.replace("$$", " ");
193
            tv_buy.setText("已购买");
194
            rl_select_car.setVisibility(View.VISIBLE);
195
            et_che.setText(car);
196 192
            String[] strarray = car.split(" ");
197 193
            if (strarray.length > 1) {
198 194
                car_brand = strarray[0];
@ -242,25 +238,11 @@ public class UserInfoActivity extends Activity implements View.OnClickListener,
242 238
        tv_save = (TextView) findViewById(R.id.tv_make_sure);
243 239
        tv_save.setOnClickListener(this);
244 240
245
//        rl_brand = (RelativeLayout) findViewById(R.id.rl_1);
246
//        rl_brand.setOnClickListener(this);
247
//        rl_type = (RelativeLayout) findViewById(R.id.rl_2);
248
//        rl_type.setOnClickListener(this);
249
//        long appTime1 = System.currentTimeMillis()/1000;
250
////        Log.d("appTime(long)---", appTime1+"");
251
//        String apptime = String.valueOf(appTime1);
252
//        int updateapptime = Integer.valueOf(apptime);
253
//
254
//        if(MainFragment.cha>0){
255
//            cha = updateapptime - (MainFragment.cha);
256
//        }else if (MainFragment.cha<0){
257
//            cha = updateapptime+(MainFragment.cha);
258
//        }else {
259
//            cha = updateapptime;
260
//        }
261
//        chatime = String.valueOf(cha);
262
//        Log.i("updatetime----",updateapptime+"");
263
//        Log.i("cha",chatime);
241
        go_certificate = findViewById(R.id.go_certificate);
242
        go_certificate.setOnClickListener(this);
243
        go_title = findViewById(R.id.go_title);
244
        go_desc = findViewById(R.id.go_desc);
245
        go_cursor = findViewById(R.id.go_cursor);
264 246
    }
265 247
266 248
    private void setIcon() {
@ -288,38 +270,15 @@ public class UserInfoActivity extends Activity implements View.OnClickListener,
288 270
            iconPic.setImageResource(R.drawable.icon_face2_0);
289 271
            photo = ((BitmapDrawable) iconPic.getDrawable()).getBitmap();
290 272
        }
291
//        if (ImageTools.findPhotoFromSDCard(MainApplication.storePath,"user_icon")){
292
//            Bitmap bmp = BitmapFactory.decodeFile(MainApplication.storePath+"/user_icon.png");
293
//            photo = bmp;
294
//            iconPic.setImageBitmap(bmp);
295
//        }else {
296
//            Log.e(TAG, "setIcon: "+MainApplication.userIcon );
297
//            new Task().execute(MainApplication.userIcon);
298
//        }
299
300 273
    }
301 274
302 275
    private void spinner() {
303 276
        List<Cars> cars = new ArrayList<Cars>();
304 277
        Cars car = new Cars("E140ev", "1", "1");
305
//        Cars car1=new Cars("E150ev","1","2");
306
//        Cars car2=new Cars("EV160","1","3");
307
//        Cars car3=new Cars("EV200","1","4");
308 278
        cars.add(car);
309
//        cars.add(car1);
310
//        cars.add(car2);
311
//        cars.add(car3);
312
//
313 279
        List<Cars> cars2 = new ArrayList<Cars>();
314 280
        Cars car0 = new Cars("车型", "1", "1");
315
//        Cars car11=new Cars("2222","1","2");
316
//        Cars car22=new Cars("33333","1","3");
317
//        Cars car33=new Cars("4444","1","4");
318 281
        cars2.add(car0);
319
//        cars2.add(car11);
320
//        cars2.add(car22);
321
//        cars2.add(car33);
322
//		// spinner方面的东西
323 282
        spinnerProvince = (Spinner) this
324 283
                .findViewById(R.id.spinner_province_search_event);
325 284
        spinnerCity = (Spinner) this
@ -328,24 +287,7 @@ public class UserInfoActivity extends Activity implements View.OnClickListener,
328 287
        p.setCities(cars2);
329 288
        p.setId(1);
330 289
        p.setName("品牌");
331
//		Province p2=new Province("比亚迪1", 2, cars2);
332
//		Province p3=new Province("比亚迪2", 2, cars);
333
//		Province p4=new Province("比亚迪3", 2, cars);
334
//		Province p5=new Province("比亚迪4", 2, cars);
335
//		Province p6=new Province("比亚迪5", 2, cars);
336
//		Province p7=new Province("比亚迪6", 2, cars);
337
//		Province p8=new Province("比亚迪7", 2, cars);
338
//		Province p9=new Province("比亚迪8", 2, cars);
339 290
        pr.add(p);
340
//		pr.add(p2);
341
//		pr.add(p3);
342
//		pr.add(p4);
343
//		pr.add(p5);
344
//		pr.add(p6);
345
//		pr.add(p7);
346
//		pr.add(p8);
347
//		pr.add(p9);
348
//		pr.add(p2);
349 291
        ArrayAdapter<Province> provinceAdapter = new ArrayAdapter<Province>(UserInfoActivity.this, R.layout.simple_spinner_item, pr);
350 292
        spinnerProvince.setAdapter(provinceAdapter);
351 293
@ -374,7 +316,6 @@ public class UserInfoActivity extends Activity implements View.OnClickListener,
374 316
                                   int position, long id) {
375 317
            onProvinChange(position);
376 318
            Province d = pr.get(position);
377
//            btnP.setText(d.getName());
378 319
            try {
379 320
                car_brand = d.getName();
380 321
            } catch (Exception e) {
@ -396,14 +337,12 @@ public class UserInfoActivity extends Activity implements View.OnClickListener,
396 337
    final class CityAdapter extends ProvinceAdapter {
397 338
        @Override
398 339
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
399
//			currentCity = currentProvince.getCities().get(position);
400 340
            car_type = (String) spinnerCity.getSelectedItem();
401 341
            Log.e("car_type", car_type);
402 342
        }
403 343
    }
404 344
405 345
    public void onProvinChange(int position) {
406
//		currentProvince = parse.getProvinces().get(position);
407 346
        List<Cars> car = pr.get(position).getCities();
408 347
        List<String> strName = new ArrayList<String>();
409 348
        for (int i = 0; i < car.size(); i++) {
@ -421,101 +360,12 @@ public class UserInfoActivity extends Activity implements View.OnClickListener,
421 360
            spinnerCity.setSelection(default_type);
422 361
            default_type = -1;
423 362
        }
424
425
//        Log.e("default_type",default_type+"");
426
//        if (default_type==-1){
427
//            spinnerCity.setSelection(0);
428
//            default_type=-1;
429
//        }else{
430
//            spinnerCity.setSelection(default_type);
431
//        }
432
433
//		if (currentProvince.getCities().size() > 0) {
434
//			cityAdapter.notifyDataSetChanged();
435
//			spinnerCity.setSelection(0);
436
//		}
437 363
    }
438 364
439 365
440 366
    @Override
441 367
    public void onClick(View v) {
442 368
        switch (v.getId()) {
443
            case R.id.rl_select_car:
444
                MobclickAgent.onEvent(getApplicationContext(), "0802", new HashMap<String, String>().put("type", "车型"));
445
//                startActivityForResult(new Intent(UserInfoActivity.this,
446
//                        ChePaiActivity.class), 55);
447
                startActivityForResult(new Intent(UserInfoActivity.this, SelectCarActivity.class), REQUSET);
448
                break;
449
            case R.id.rl_isBuy:
450
                MobclickAgent.onEvent(getApplicationContext(), "0802", new HashMap<String, String>().put("type", "是否购车"));
451
                LayoutInflater inflater1 = (LayoutInflater) getSystemService(mContext.LAYOUT_INFLATER_SERVICE);
452
                View popupWindowView = inflater1.inflate(R.layout.layout_isbuy, null);
453
                final PopupWindow popupWindow1 = new PopupWindow(popupWindowView,
454
                        ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT,
455
                        true);
456
                popupWindow1.setBackgroundDrawable(getResources().getDrawable(R.drawable.bg_yinying531));
457
                popupWindow1.setOutsideTouchable(true);
458
                popupWindowView.setOnKeyListener(new View.OnKeyListener() {
459
                    @Override
460
                    public boolean onKey(View v, int keyCode, KeyEvent event) {
461
                        if ((keyCode == KeyEvent.KEYCODE_MENU) && (popupWindow1.isShowing())) {
462
                            popupWindow1.dismiss();
463
                            return true;
464
                        }
465
                        return false;
466
                    }
467
                });
468
                popupWindowView.setOnTouchListener(new View.OnTouchListener() {
469
470
                    @Override
471
                    public boolean onTouch(View v, MotionEvent event) {
472
                        if (popupWindow1.isShowing()) {
473
                            popupWindow1.dismiss();
474
                        }
475
                        return false;
476
                    }
477
                });
478
                // 设置PopupWindow的弹出和消失效果
479
                popupWindow1.setAnimationStyle(R.style.popupAnimation);
480
                Button cancleButton = (Button) popupWindowView
481
                        .findViewById(R.id.cancleButton);
482
                cancleButton.setOnClickListener(new View.OnClickListener() {
483
                    @Override
484
                    public void onClick(View view) {
485
                        popupWindow1.dismiss();
486
                    }
487
                });
488
                Button btn_one = (Button) popupWindowView.findViewById(R.id.tvTwo);
489
                btn_one.setOnClickListener(new View.OnClickListener() {
490
                    @Override
491
                    public void onClick(View view) {
492
                        tv_buy.setText("已购买");
493
                        rl_select_car.setVisibility(View.VISIBLE);
494
495
//                        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
496
//                        intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(
497
//                                Environment.getExternalStorageDirectory(), "androidapp.jpg")));
498
//                        ((Activity) mContext).startActivityForResult(intent, 2);
499
                        popupWindow1.dismiss();
500
                    }
501
                });
502
                Button btn_two = (Button) popupWindowView.findViewById(R.id.tvThree);
503
                btn_two.setOnClickListener(new View.OnClickListener() {
504
                    @Override
505
                    public void onClick(View view) {
506
                        tv_buy.setText("未购买");
507
                        rl_select_car.setVisibility(View.GONE);
508
//                        Intent intent = new Intent(Intent.ACTION_PICK, null);
509
//                        intent.setDataAndType(
510
//                                MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
511
//                                "image/*");
512
//                        startActivityForResult(intent, 1);
513
                        popupWindow1.dismiss();
514
                    }
515
                });
516
517
                popupWindow1.showAtLocation(cancleButton, Gravity.CENTER, 0, 0);
518
                break;
519 369
520 370
            case R.id.onclick:
521 371
@ -542,29 +392,25 @@ public class UserInfoActivity extends Activity implements View.OnClickListener,
542 392
                    dialog.show();
543 393
                }
544 394
                break;
395
396
            case R.id.go_certificate:
397
                // 1 去认证  2审核中  3认证车主
398
                if (certificateStatus == 0) {
399
                    getCarOwnerCertificateList(true);
400
                } else if (certificateStatus == 1) {
401
                    startActivity(new Intent(getApplication(), CarOwnerCertificateActivity.class));
402
                }
403
                break;
545 404
        }
546 405
    }
547 406
548 407
    private boolean checkText() {
549 408
        String nickName = et_nickName.getText().toString().trim();
550
        String isBuy = tv_buy.getText().toString().trim();
551
        String carType = et_che.getText().toString().trim();
552 409
553 410
        if (TextUtils.isEmpty(nickName)) {
554 411
            Toast.makeText(this, "请输入您的昵称", Toast.LENGTH_SHORT).show();
555 412
            return false;
556 413
        }
557
        if (TextUtils.isEmpty(isBuy)) {
558
            Toast.makeText(this, "请选择您是否购买了新能源汽车", Toast.LENGTH_SHORT).show();
559
            return false;
560
        }
561
        if (isBuy.equals("已购买")) {
562
            if (TextUtils.isEmpty(carType)) {
563
                Toast.makeText(this, "请选择您购买的车型", Toast.LENGTH_SHORT).show();
564
                return false;
565
            }
566
        }
567
568 414
        return true;
569 415
    }
570 416
@ -659,15 +505,6 @@ public class UserInfoActivity extends Activity implements View.OnClickListener,
659 505
        String token = String.valueOf(updatetime);
660 506
        Log.i("token---", token);
661 507
662
        if (tv_buy.getText().toString().equals("未购买")) {
663
            havecar = "待购";
664
        } else {
665
            if (car_brand != null && null != car_type) {
666
                havecar = car_brand + "$$" + car_type;
667
            }
668
        }
669
670
        nocar = "";
671 508
        try {
672 509
            if (null != photo) {
673 510
                Bitmap bm = imageZoom(photo);
@ -683,10 +520,6 @@ public class UserInfoActivity extends Activity implements View.OnClickListener,
683 520
        par.put("username", et_realName.getText().toString());
684 521
        par.put("nickname", et_nickName.getText().toString());
685 522
        par.put("sex", sex);
686
        par.put("chexing", havecar);
687
        par.put("yichexing", nocar);
688
        Log.e("chexing", havecar);
689
        Log.e("yichexing", nocar);
690 523
691 524
        try {
692 525
            par.put("token", DES3.encode(token));
@ -842,14 +675,6 @@ public class UserInfoActivity extends Activity implements View.OnClickListener,
842 675
843 676
        switch (requestCode) {
844 677
            // 如果是直接从相册获取
845
            case REQUSET:
846
                select_pinpai = data.getStringExtra("pinpai");
847
                select_chexing = data.getStringExtra("chexing");
848
849
                et_che.setText(select_pinpai + " " + select_chexing);
850
                car_brand = select_pinpai;
851
                car_type = select_chexing;
852
                break;
853 678
            case 1:
854 679
                if (SDCardUtil.hasSdcard()) {
855 680
                    cropImageUri = Uri.fromFile(fileCropUri);
@ -916,8 +741,6 @@ public class UserInfoActivity extends Activity implements View.OnClickListener,
916 741
        matrix.postScale(scaleWidth, scaleHeight);
917 742
        Bitmap bitmap = Bitmap.createBitmap(bgimage, 0, 0, (int) width,
918 743
                (int) height, matrix, true);
919
//        iv_2.setImageBitmap(bitmap);
920
//        tv_2.setText(bitmap.getRowBytes() * bitmap.getHeight() + "");
921 744
        return bitmap;
922 745
    }
923 746
@ -1040,66 +863,13 @@ public class UserInfoActivity extends Activity implements View.OnClickListener,
1040 863
    }
1041 864
1042 865
1043
    /*
1044
     *bitmap转base64
1045
     */
1046
//    public static Bitmap base64ToBitmap(String base64String){
1047
//        byte[] bytes = Base64.decode(base64String);
1048
//        Bitmap bitmap= BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
1049
//        return bitmap;
1050
//    }
1051
1052 866
    Handler handle = new Handler() {
1053 867
        public void handleMessage(Message msg) {
1054 868
            switch (msg.what) {
1055 869
                case StatusConstants.REQUEST_WHAT_SUCCESS:
1056 870
                    LogUtils.getLogger().e(msg.obj.toString());
1057
//                    Toast.makeText(UserInfoActivity.this, msg.obj.toString(), 1).show();
1058 871
                    break;
1059 872
                case 1:
1060
//
1061
//				Gson g = new Gson();
1062
//				pr.clear();
1063
//				pr = g.fromJson(msg.obj.toString(), new TypeToken<List<Province>>() {
1064
//				}.getType());
1065
//				String s=msg.obj.toString();
1066
//				JSONObject
1067
//				Province p= new Province(s.get, code, cities)
1068
//				pr.add(arg0)
1069
//				spinner();
1070
//                    if (!chexing.equals("") && yichexing.equals("")){
1071
//                        String[] strarray=chexing.split("\\$\\$");
1072
//
1073
//                        if(strarray.length>1){
1074
//                            name0=strarray[0];//江淮
1075
//                            name1=strarray[1];//iEV3
1076
//                        }
1077
//                        Log.e("name0+name1",name0+name1);
1078
//                        et_che.setText(name0 + " - " + name1);
1079
//                        Log.e(TAG, "handleMessage: "+ et_che.getText().toString());
1080
//                        if (et_che.getText().toString().equals(" - ")){
1081
//                            tv_buy.setText("未购买");
1082
//                            rl_select_car.setVisibility(View.GONE);
1083
//                        }else {
1084
//                            tv_buy.setText("已购买");
1085
//                            rl_select_car.setVisibility(View.VISIBLE);
1086
//                        }
1087
//                        car_brand = name0;
1088
//                        car_type = name1;
1089
//                    }else if(chexing.equals("") && !yichexing.equals("")){
1090
//                        String[] strarray=yichexing.split("\\$\\$");
1091
//
1092
//                        if(strarray.length>1){
1093
//                            name0=strarray[0];//江淮
1094
//                            name1=strarray[1];//iEV3
1095
//                        }
1096
//                        Log.e("name0+name1",name0+name1);
1097
//                        et_che.setText(name0 + " - " + name1);
1098
//                        car_brand = name0;
1099
//                        car_type = name1;
1100
//                }
1101
1102
1103 873
                    try {
1104 874
                        JSONArray jsonary = new JSONArray(msg.obj.toString());
1105 875
                        for (int i = 0; i < jsonary.length(); i++) {
@ -1124,24 +894,12 @@ public class UserInfoActivity extends Activity implements View.OnClickListener,
1124 894
                            pr.remove(prov);
1125 895
                            pr.add(prov);
1126 896
1127
//                            spinnerProvince.setSelection(de);
1128
//                                    spinnerCity
1129 897
                        }
1130 898
1131 899
                    } catch (JSONException e) {
1132 900
                        e.printStackTrace();
1133 901
                    }
1134
//				pr =(List<Province>) JsonUtils.parseToObjectBean(msg.obj.toString(), Province.class);
1135
//                    Log.e("pe", pr.size()+"");
1136
//                    Log.e("pe", pr.get(0).getCities().size()+"");
1137
//                    Log.e("pe", pr.get(1).getCities().size()+"");
1138
//                    Log.e("pe", pr.get(2).getCities().size()+"");
1139
//                    Log.e("pe", pr.get(3).getCities().size()+"");
1140
//				Log.e("pe", pr.size()+"");
1141
//				Log.e("pe", pr.size()+"");
1142 902
1143
1144
//
1145 903
                    ArrayAdapter<Province> provinceAdapter = new ArrayAdapter<Province>(UserInfoActivity.this, R.layout.simple_spinner_item, pr);
1146 904
                    spinnerProvince.setAdapter(provinceAdapter);
1147 905
                    provinceAdapter.notifyDataSetChanged();
@ -1166,38 +924,15 @@ public class UserInfoActivity extends Activity implements View.OnClickListener,
1166 924
1167 925
                        if (rtnCode.equals("01")) {
1168 926
                            dialog.cancel();
1169
//                            SharedPreferences mySharedPreferences= getSharedPreferences("userInfo",
1170
//                                    Activity.MODE_PRIVATE);
1171
//                            SharedPreferences.Editor editor = mySharedPreferences.edit();
1172
//                            editor.putString("nickname", et_nickName.getText().toString());
1173
//                            editor.putString("username", et_realName.getText().toString());
1174
//                            editor.putString("sex", sex);
1175
//                            editor.putString("chexing", havecar);
1176
//                            editor.putString("yichexing", nocar);
1177
//
1178
////                            String data = JsonUtils.getKeyResult(msg.obj.toString(),"data");
1179
////                            String userid = JsonUtils.getKeyResult(data,"userid");
1180
////                            String username = JsonUtils.getKeyResult(data,"username");
1181
////                            String userpic = JsonUtils.getKeyResult(data,"userpic");
1182
////                            String nickname = JsonUtils.getKeyResult(data,"nickname");
1183
////                            LogUtils.getLogger().e(userid+"---"+username+"---"+userpic+"---"+nickname);
1184
////                            Log.e(TAG, "handleMessage: "+userid+"---"+username+"---"+userpic+"---"+nickname );
1185
//
1186
//                            editor.commit();
1187 927
                            String picurl = JsonUtils.getKeyResult(msg.obj.toString(), "picurl");
1188 928
                            MainApplication.userIcon = MainApplication.url + picurl;
1189 929
                            ProfileManager.getInstance().setUsericon(getApplicationContext(), MainApplication.userIcon);
1190
                            MainApplication.userCar = havecar;
1191
                            ProfileManager.getInstance().setUsercar(getApplicationContext(), havecar);
1192 930
                            MainApplication.userNickname = et_nickName.getText().toString();
1193 931
                            ProfileManager.getInstance().setNickname(getApplicationContext(), et_nickName.getText().toString());
1194 932
                            Intent intent = new Intent();
1195 933
                            intent.putExtra("nickname", et_nickName.getText().toString().trim());
1196 934
                            intent.putExtra("userphoto", ss);
1197 935
                            setResult(RESULT_SUCCESS, intent);
1198
//                            MainApplication.userIcon="V";
1199
//                            ProfileManager.getInstance().setUsericon(UserInfoActivity.this, "V");
1200
//                            ImageTools.saveImageToGallery(getApplicationContext(),photo,"user_icon");
1201 936
1202 937
                            String plusScore = jsonObject.getString("plusScore");
1203 938
                            if (!plusScore.equals("")) {
@ -1209,12 +944,6 @@ public class UserInfoActivity extends Activity implements View.OnClickListener,
1209 944
                                        rl_point.setVisibility(View.GONE);
1210 945
                                    }
1211 946
                                }, 1000);
1212
//                                if (photo != null) {
1213
//                                    photo.recycle();
1214
//                                    photo = null;
1215
////                                            bitmap.recycle();
1216
//
1217
//                                }
1218 947
                                new Handler().postDelayed(new Runnable() {
1219 948
                                    public void run() {
1220 949
@ -1223,11 +952,6 @@ public class UserInfoActivity extends Activity implements View.OnClickListener,
1223 952
                                }, 1500);
1224 953
                            } else {
1225 954
                                ToastUtil.showToast(UserInfoActivity.this, "保存成功", Toast.LENGTH_SHORT);
1226
//                                if (photo != null) {
1227
//                                    photo.recycle();
1228
//                                    photo = null;
1229
//
1230
//                                }
1231 955
                                UserInfoActivity.this.finish();
1232 956
                            }
1233 957
@ -1241,10 +965,7 @@ public class UserInfoActivity extends Activity implements View.OnClickListener,
1241 965
                    } catch (JSONException e) {
1242 966
                        e.printStackTrace();
1243 967
                    }
1244
1245
//                    Toast.makeText(UserInfoActivity.this, msg.obj.toString(), Toast.LENGTH_SHORT).show();
1246 968
                    break;
1247
1248 969
                case 5:
1249 970
                    Toast.makeText(UserInfoActivity.this, msg.obj.toString(), Toast.LENGTH_SHORT).show();
1250 971
                    break;
@ -1314,6 +1035,7 @@ public class UserInfoActivity extends Activity implements View.OnClickListener,
1314 1035
    protected void onResume() {
1315 1036
        super.onResume();
1316 1037
        MobclickAgent.onResume(this);
1038
        getCarOwnerCertificateList(false);
1317 1039
    }
1318 1040
1319 1041
    @Override
@ -1326,4 +1048,75 @@ public class UserInfoActivity extends Activity implements View.OnClickListener,
1326 1048
    protected void onDestroy() {
1327 1049
        super.onDestroy();
1328 1050
    }
1051
1052
    private void getCarOwnerCertificateList(Boolean showLoading) {
1053
        if (showLoading) {
1054
            loadDialog.show();
1055
        }
1056
        String url = MainApplication.url + "/zhannew/basic/web/index.php/car/my?userid=" + MainApplication.userId;
1057
        OkHttpUtils.get().url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
1058
            @Override
1059
            public void onError(Call call, Exception e) {
1060
                e.printStackTrace();
1061
                loadDialog.dismiss();
1062
                Toast.makeText(getApplicationContext(), e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
1063
                go_title.setText("去认证车主(获得充电优惠)");
1064
                go_desc.setText("");
1065
                go_cursor.setVisibility(View.VISIBLE);
1066
            }
1067
1068
            @Override
1069
            public void onResponse(String response) {
1070
                loadDialog.dismiss();
1071
                String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
1072
                if ("01".equals(rtnCode)) {
1073
                    String data = JsonUtils.getKeyResult(response, "data");
1074
                    List<CarOwnerCertificateBean> list = JsonUtils.parseToObjectList(data, CarOwnerCertificateBean.class);
1075
                    CarSeriesEntity carSeriesEntity = null;
1076
                    // 1 去认证  2审核中  3认证车主
1077
                    if (list.size() == 0) {
1078
                        certificateStatus = 1;
1079
                    } else {
1080
                        certificateStatus = 2;
1081
                        for (CarOwnerCertificateBean bean : list) {
1082
                            if (bean.getStatus() == 1 && bean.getMain() == 1) {
1083
                                certificateStatus = 3;
1084
                                Gson gson = new Gson();
1085
                                carSeriesEntity = gson.fromJson(bean.getChexing(), CarSeriesEntity.class);
1086
                                break;
1087
                            }
1088
                        }
1089
                    }
1090
1091
                    if (certificateStatus == 2) {
1092
                        go_title.setText("认证车主");
1093
                        go_desc.setText("审核中");
1094
                        go_cursor.setVisibility(View.GONE);
1095
                    } else if (certificateStatus == 3) {
1096
                        go_title.setText("认证车主");
1097
                        if (carSeriesEntity != null) {
1098
                            go_desc.setText(carSeriesEntity.getSeriesName());
1099
                        }
1100
                        go_cursor.setVisibility(View.GONE);
1101
                    } else {
1102
                        go_title.setText("去认证车主(获得充电优惠)");
1103
                        go_desc.setText("");
1104
                        go_cursor.setVisibility(View.VISIBLE);
1105
                    }
1106
1107
                    if (certificateStatus == 1) {
1108
                        startActivity(new Intent(getApplication(), CarOwnerCertificateActivity.class));
1109
                    }
1110
1111
                } else {
1112
                    String rtnMsg = JsonUtils.getKeyResult(response, "rtnMsg");
1113
                    Toast.makeText(getApplicationContext(), rtnMsg, Toast.LENGTH_SHORT).show();
1114
1115
                    go_title.setText("去认证车主(获得充电优惠)");
1116
                    go_desc.setText("");
1117
                    go_cursor.setVisibility(View.VISIBLE);
1118
                }
1119
            }
1120
        });
1121
    }
1329 1122
}

+ 1 - 2
app/src/main/java/com/electric/chargingpile/adapter/CarOwnerCertificateListAdapter.java

@ -49,8 +49,7 @@ public class CarOwnerCertificateListAdapter extends RecyclerView.Adapter<CarOwne
49 49
        CarOwnerCertificateBean bean = mList.get(position);
50 50
        Gson gson = new Gson();
51 51
        CarSeriesEntity carSeriesEntity = gson.fromJson(bean.getChexing(), CarSeriesEntity.class);
52
//        Glide.with(mContext).load(carSeriesEntity.getIcon()).into(holder.master_pic);
53
//        Picasso.with(mContext).load(carSeriesEntity.getMasterPic()).into(holder.master_pic);
52
        Glide.with(mContext).load(carSeriesEntity.getIcon()).into(holder.master_pic);
54 53
        holder.name.setText(carSeriesEntity.getCompanyName());
55 54
        holder.detail_name.setText(carSeriesEntity.getSeriesName());
56 55

+ 6 - 2
app/src/main/java/com/electric/chargingpile/application/MainApplication.java

@ -75,10 +75,14 @@ public class MainApplication extends MultiDexApplication {
75 75
    public static Boolean firstSsyd;
76 76
    public static String password = "";
77 77
    public static String url = "http://59.110.68.162";// 充电桩测试环境
78
//        public static String url = "http://cdz.evcharge.cc";// 充电桩正式环境
78
    public static String pic_url = "http://59.110.68.162/zhannew/uploadfile/";
79
//    public static String url = "http://cdz.evcharge.cc";// 充电桩正式环境
80
//    public static String pic_url = "http://cdz.evcharge.cc/zhannew/uploadfile/";
81

79 82
//    public static String urlNew = "http://123.56.67.7:83/api/0300";// 一电测试环境
80 83
    public static String urlNew = "https://api.touchev.com:83/api/0300";// 一电正式环境
81
    public static String pic_url = "http://cdz.evcharge.cc/zhannew/uploadfile/";
84

85

82 86
    //	public static String url = "https://cdz.d1ev.com";
83 87
    public static String build_flag = "0";
84 88
    public static String support = "0"; // true:本APP支付  false:其他方式支付

+ 0 - 11
app/src/main/java/com/electric/chargingpile/entity/CarSeriesEntity.java

@ -13,17 +13,6 @@ public class CarSeriesEntity {
13 13
    private String maxSalePrice;
14 14
    private String minSalePrice;
15 15
16
//    public CarSeriesEntity(String brandId, String brandName, String companyId, String companyName, String seriesId, String seriesName, String salePrice, String icon) {
17
//        this.brandId = brandId;
18
//        this.brandName = brandName;
19
//        this.companyId = companyId;
20
//        this.companyName = companyName;
21
//        this.seriesId = seriesId;
22
//        this.seriesName = seriesName;
23
//        this.salePrice = salePrice;
24
//        this.icon = icon;
25
//    }
26
27 16
    public String getBrandId() {
28 17
        return brandId;
29 18
    }

+ 211 - 253
app/src/main/res/layout/activity_user_info.xml

@ -1,10 +1,11 @@
1 1
<?xml version="1.0" encoding="utf-8"?>
2 2
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
    xmlns:tools="http://schemas.android.com/tools"
3 4
    android:layout_width="match_parent"
4 5
    android:layout_height="match_parent"
5
    android:orientation="vertical"
6 6
    android:focusable="true"
7
    android:focusableInTouchMode="true">
7
    android:focusableInTouchMode="true"
8
    android:orientation="vertical">
8 9
9 10
    <RelativeLayout
10 11
        android:layout_width="fill_parent"
@ -17,10 +18,10 @@
17 18
            android:layout_height="match_parent"
18 19
            android:layout_centerVertical="true"
19 20
            android:contentDescription="@null"
20
            android:paddingBottom="4dp"
21 21
            android:paddingLeft="16dp"
22
            android:paddingRight="16dp"
23 22
            android:paddingTop="4dp"
23
            android:paddingRight="16dp"
24
            android:paddingBottom="4dp"
24 25
            android:src="@drawable/icon_lvback1119" />
25 26
26 27
        <TextView
@ -36,18 +37,18 @@
36 37
            android:id="@+id/iv_right"
37 38
            android:layout_width="wrap_content"
38 39
            android:layout_height="match_parent"
39
            android:paddingBottom="4dp"
40
            android:layout_alignParentTop="true"
41
            android:layout_alignParentEnd="true"
42
            android:layout_alignParentRight="true"
43
            android:gravity="center"
40 44
            android:paddingLeft="16dp"
41
            android:paddingRight="16dp"
42 45
            android:paddingTop="4dp"
43
            android:textSize="15sp"
44
            android:visibility="gone"
46
            android:paddingRight="16dp"
47
            android:paddingBottom="4dp"
45 48
            android:text="跳过"
46
            android:gravity="center"
47 49
            android:textColor="@color/white"
48
            android:layout_alignParentTop="true"
49
            android:layout_alignParentRight="true"
50
            android:layout_alignParentEnd="true" />
50
            android:textSize="15sp"
51
            android:visibility="gone" />
51 52
    </RelativeLayout>
52 53
53 54
@ -70,38 +71,40 @@
70 71
                android:layout_width="fill_parent"
71 72
                android:layout_height="62dp"
72 73
                android:background="@color/white">
74
73 75
                <TextView
74 76
                    android:layout_width="wrap_content"
75 77
                    android:layout_height="match_parent"
78
                    android:gravity="center"
79
                    android:paddingLeft="15dp"
76 80
                    android:text="头像"
77 81
                    android:textColor="@color/title_row"
78
                    android:textSize="15sp"
79
                    android:paddingLeft="15dp"
80
                    android:gravity="center"/>
82
                    android:textSize="15sp" />
81 83
82 84
                <com.electric.chargingpile.view.RoundImageView
83 85
                    android:id="@+id/iv_user_icon"
84 86
                    android:layout_width="45dp"
85 87
                    android:layout_height="45dp"
86
                    android:src="@drawable/icon_face2_0"
87
                    android:layout_centerVertical="true"
88
                    android:layout_alignParentRight="true"
89 88
                    android:layout_alignParentEnd="true"
89
                    android:layout_alignParentRight="true"
90
                    android:layout_centerVertical="true"
91
                    android:layout_marginEnd="32dp"
90 92
                    android:layout_marginRight="32dp"
91
                    android:layout_marginEnd="32dp" />
93
                    android:src="@drawable/icon_face2_0" />
94
92 95
                <ImageView
93 96
                    android:layout_width="wrap_content"
94 97
                    android:layout_height="match_parent"
95
                    android:src="@drawable/icon_more2_0"
96
                    android:layout_centerVertical="true"
97
                    android:layout_alignParentRight="true"
98 98
                    android:layout_alignParentEnd="true"
99
                    android:layout_alignParentRight="true"
100
                    android:layout_centerVertical="true"
101
                    android:layout_marginEnd="15dp"
99 102
                    android:layout_marginRight="15dp"
100
                    android:layout_marginEnd="15dp" />
101
103
                    android:src="@drawable/icon_more2_0" />
102 104
103 105
104 106
            </RelativeLayout>
107
105 108
            <View
106 109
                android:layout_width="match_parent"
107 110
                android:layout_height="0.5dp"
@ -112,208 +115,166 @@
112 115
                android:layout_width="fill_parent"
113 116
                android:layout_height="45dp"
114 117
                android:background="@color/white">
118
115 119
                <TextView
116 120
                    android:layout_width="wrap_content"
117 121
                    android:layout_height="match_parent"
122
                    android:gravity="center"
123
                    android:paddingLeft="15dp"
118 124
                    android:text="昵称"
119 125
                    android:textColor="@color/title_row"
120
                    android:textSize="15sp"
121
                    android:paddingLeft="15dp"
122
                    android:gravity="center"/>
126
                    android:textSize="15sp" />
123 127
124 128
                <EditText
125 129
                    android:id="@+id/et_nickName"
126 130
                    android:layout_width="wrap_content"
127 131
                    android:layout_height="130px"
128
                    android:background="@color/white"
129
                    android:hint="请输入昵称"
132
                    android:layout_alignParentTop="true"
133
                    android:layout_alignParentEnd="true"
130 134
135
                    android:layout_alignParentRight="true"
136
                    android:layout_marginEnd="15dp"
137
                    android:layout_marginRight="15dp"
138
                    android:background="@color/white"
131 139
                    android:gravity="center|right"
140
                    android:hint="请输入昵称"
141
                    android:maxLength="16"
132 142
                    android:singleLine="true"
133
                    android:textColorHint="@color/ui_68"
134 143
                    android:textColor="@color/ui_62"
135
                    android:textSize="15sp"
136
                    android:maxLength="16"
137
                    android:layout_alignParentTop="true"
138
                    android:layout_alignParentRight="true"
139
                    android:layout_alignParentEnd="true"
140
                    android:layout_marginRight="15dp"
141
                    android:layout_marginEnd="15dp" />
144
                    android:textColorHint="@color/ui_68"
145
                    android:textSize="15sp" />
142 146
143 147
            </RelativeLayout>
144 148
145 149
            <View
146 150
                android:layout_width="match_parent"
147 151
                android:layout_height="0.5dp"
148
                android:background="@color/ui_line"
149 152
                android:layout_marginLeft="15dp"
150
                android:visibility="visible"/>
151
153
                android:background="@color/ui_line"
154
                android:visibility="visible" />
152 155
153 156
154 157
            <RelativeLayout
155
                android:id="@+id/rl_isBuy"
158
                android:id="@+id/go_certificate"
156 159
                android:layout_width="fill_parent"
157
                android:background="@color/white"
158 160
                android:layout_height="45dp"
161
                android:background="@color/white"
159 162
                android:visibility="visible">
163
160 164
                <TextView
165
                    android:id="@+id/go_title"
161 166
                    android:layout_width="wrap_content"
162 167
                    android:layout_height="match_parent"
163
                    android:text="是否购买新能源汽车"
168
                    android:gravity="center"
169
                    android:paddingLeft="15dp"
164 170
                    android:textColor="@color/title_row"
165 171
                    android:textSize="15sp"
166
                    android:paddingLeft="15dp"
167
                    android:gravity="center"/>
172
                    android:text="去认证车主(获得充电优惠)" />
168 173
169 174
                <TextView
170
                    android:id="@+id/tv_buy"
175
                    android:id="@+id/go_desc"
171 176
                    android:layout_width="wrap_content"
172 177
                    android:layout_height="45dp"
178
                    android:layout_alignParentTop="true"
179
                    android:layout_alignParentEnd="true"
180
                    android:layout_alignParentRight="true"
181
                    android:layout_marginEnd="15dp"
182
                    android:layout_marginRight="15dp"
173 183
                    android:background="@color/white"
174
                    android:text="未购买"
175
                    android:hint="请选择"
176 184
                    android:gravity="center|right"
177 185
                    android:singleLine="true"
178
                    android:textColorHint="@color/ui_68"
186
                    tools:text="审核中"
179 187
                    android:textColor="@color/ui_62"
180
                    android:textSize="15sp"
181
                    android:layout_alignParentTop="true"
182
                    android:layout_marginRight="8dp"
183
                    android:layout_toLeftOf="@+id/imageView14"
184
                    android:layout_toStartOf="@+id/imageView14" />
188
                    android:textColorHint="@color/ui_68"
189
                    android:textSize="15sp" />
185 190
186 191
                <ImageView
192
                    android:id="@+id/go_cursor"
187 193
                    android:layout_width="wrap_content"
188 194
                    android:layout_height="match_parent"
189
                    android:src="@drawable/icon_more2_0"
190
                    android:layout_centerVertical="true"
191
                    android:layout_alignParentRight="true"
192 195
                    android:layout_alignParentEnd="true"
196
                    android:layout_alignParentRight="true"
197
                    android:layout_centerVertical="true"
193 198
                    android:layout_marginRight="15dp"
194
                    android:id="@+id/imageView14" />
199
                    android:src="@drawable/icon_more2_0" />
195 200
196 201
            </RelativeLayout>
197 202
198 203
            <View
199 204
                android:layout_width="match_parent"
200 205
                android:layout_height="0.5dp"
201
                android:background="@color/ui_line"
202 206
                android:layout_marginLeft="15dp"
203
                android:visibility="visible"/>
204
205
206
207
            <RelativeLayout
208
                android:id="@+id/rl_select_car"
209
                android:layout_width="fill_parent"
210
                android:background="@color/white"
211
                android:layout_height="45dp"
212
                android:visibility="visible">
213
                <TextView
214
                    android:layout_width="wrap_content"
215
                    android:layout_height="match_parent"
216
                    android:text="品牌型号"
217
                    android:textColor="@color/title_row"
218
                    android:textSize="15sp"
219
                    android:paddingLeft="15dp"
220
                    android:gravity="center"/>
221
222
                <TextView
223
                    android:id="@+id/et_che"
224
                    android:layout_width="wrap_content"
225
                    android:layout_height="45dp"
226
                    android:background="@color/white"
227
                    android:hint="请选择品牌车型"
228
                    android:gravity="center|right"
229
                    android:singleLine="true"
230
                    android:textColorHint="@color/ui_68"
231
                    android:textColor="@color/ui_62"
232
                    android:textSize="15sp"
233
                    android:layout_alignParentTop="true"
234
                    android:layout_marginRight="8dp"
235
                    android:layout_toLeftOf="@+id/imageView13"
236
                    android:layout_toStartOf="@+id/imageView13" />
237
238
                <ImageView
239
                    android:layout_width="wrap_content"
240
                    android:layout_height="match_parent"
241
                    android:src="@drawable/icon_more2_0"
242
                    android:layout_centerVertical="true"
243
                    android:layout_alignParentRight="true"
244
                    android:layout_alignParentEnd="true"
245
                    android:layout_marginRight="15dp"
246
                    android:id="@+id/imageView13" />
247
248
            </RelativeLayout>
249
207
                android:background="@color/ui_line"
208
                android:visibility="visible" />
250 209
251 210
            <com.zhy.autolayout.AutoRelativeLayout
252 211
                android:layout_width="fill_parent"
253 212
                android:layout_height="139px"
254 213
                android:visibility="gone">
214
255 215
                <TextView
256 216
                    android:layout_width="wrap_content"
257 217
                    android:layout_height="match_parent"
218
                    android:gravity="center"
219
                    android:paddingLeft="44px"
258 220
                    android:text="性别"
259 221
                    android:textColor="@color/title_row"
260
                    android:textSize="15sp"
261
                    android:paddingLeft="44px"
262
                    android:gravity="center"/>
222
                    android:textSize="15sp" />
263 223
264 224
                <ToggleButton
265 225
                    android:id="@+id/sex_button"
266 226
                    android:layout_width="wrap_content"
267 227
                    android:layout_height="wrap_content"
228
                    android:layout_alignParentEnd="true"
229
                    android:layout_alignParentRight="true"
230
                    android:layout_centerVertical="true"
268 231
                    android:layout_gravity="center_horizontal"
232
                    android:layout_marginRight="5dp"
269 233
                    android:background="@android:color/transparent"
270 234
                    android:button="@drawable/sex_btn"
271 235
                    android:gravity="center"
272 236
                    android:textOff=""
273
                    android:textOn=""
274
                    android:layout_marginRight="5dp"
275
                    android:layout_centerVertical="true"
276
                    android:layout_alignParentRight="true"
277
                    android:layout_alignParentEnd="true" />
237
                    android:textOn="" />
278 238
279 239
            </com.zhy.autolayout.AutoRelativeLayout>
280 240
281 241
            <View
282 242
                android:layout_width="match_parent"
283 243
                android:layout_height="0.5dp"
284
                android:background="@color/ui_line"
285 244
                android:layout_marginLeft="44px"
286
                android:visibility="gone"/>
245
                android:background="@color/ui_line"
246
                android:visibility="gone" />
287 247
288 248
            <com.zhy.autolayout.AutoRelativeLayout
289 249
                android:layout_width="fill_parent"
290 250
                android:layout_height="139px"
291 251
                android:visibility="gone">
252
292 253
                <TextView
293 254
                    android:layout_width="wrap_content"
294 255
                    android:layout_height="match_parent"
256
                    android:gravity="center"
257
                    android:paddingLeft="44px"
295 258
                    android:text="真实姓名"
296 259
                    android:textColor="@color/title_row"
297
                    android:textSize="15sp"
298
                    android:paddingLeft="44px"
299
                    android:gravity="center"/>
260
                    android:textSize="15sp" />
300 261
301 262
                <EditText
302 263
                    android:id="@+id/et_realName"
303 264
                    android:layout_width="wrap_content"
304 265
                    android:layout_height="139px"
266
                    android:layout_alignParentTop="true"
267
                    android:layout_alignParentEnd="true"
268
                    android:layout_alignParentRight="true"
269
                    android:layout_marginEnd="44px"
270
                    android:layout_marginRight="44px"
305 271
                    android:background="@color/white"
272
                    android:gravity="center|right"
306 273
                    android:hint="请输入真实姓名"
307 274
                    android:singleLine="true"
308
                    android:textColorHint="@color/ui_68"
309 275
                    android:textColor="@color/ui_62"
310
                    android:gravity="center|right"
311
                    android:textSize="15sp"
312
                    android:layout_alignParentTop="true"
313
                    android:layout_alignParentRight="true"
314
                    android:layout_alignParentEnd="true"
315
                    android:layout_marginRight="44px"
316
                    android:layout_marginEnd="44px" />
276
                    android:textColorHint="@color/ui_68"
277
                    android:textSize="15sp" />
317 278
318 279
            </com.zhy.autolayout.AutoRelativeLayout>
319 280
@ -324,113 +285,112 @@
324 285
                android:background="@color/ui_line" />
325 286
326 287
327
328 288
        </LinearLayout>
329 289
330 290
        <com.zhy.autolayout.AutoLinearLayout
331 291
            android:layout_width="match_parent"
332 292
            android:layout_height="wrap_content"
333
            android:orientation="vertical"
293
            android:layout_marginTop="15dp"
334 294
            android:background="@color/white"
335
            android:layout_marginTop="15dp">
295
            android:orientation="vertical">
336 296
337
        <View
338
            android:layout_width="match_parent"
339
            android:layout_height="0.5dp"
340
            android:background="@color/ui_line"
341
            android:visibility="gone"/>
297
            <View
298
                android:layout_width="match_parent"
299
                android:layout_height="0.5dp"
300
                android:background="@color/ui_line"
301
                android:visibility="gone" />
342 302
343
        <com.zhy.autolayout.AutoRelativeLayout
344
            android:layout_width="fill_parent"
345
            android:layout_height="139px"
346
            android:background="@color/white"
347
            android:visibility="gone">
303
            <com.zhy.autolayout.AutoRelativeLayout
304
                android:layout_width="fill_parent"
305
                android:layout_height="139px"
306
                android:background="@color/white"
307
                android:visibility="gone">
348 308
349 309
350
            <ToggleButton
351
                android:id="@+id/car_button"
352
                android:layout_width="wrap_content"
353
                android:layout_height="wrap_content"
354
                android:layout_gravity="center_horizontal"
355
                android:background="@android:color/transparent"
356
                android:button="@drawable/car_btn"
357
                android:layout_marginLeft="44px"
358
                android:gravity="center"
359
                android:textOff=""
360
                android:textOn=""
361
                android:layout_centerVertical="true"
362
                android:visibility="gone"/>
310
                <ToggleButton
311
                    android:id="@+id/car_button"
312
                    android:layout_width="wrap_content"
313
                    android:layout_height="wrap_content"
314
                    android:layout_centerVertical="true"
315
                    android:layout_gravity="center_horizontal"
316
                    android:layout_marginLeft="44px"
317
                    android:background="@android:color/transparent"
318
                    android:button="@drawable/car_btn"
319
                    android:gravity="center"
320
                    android:textOff=""
321
                    android:textOn=""
322
                    android:visibility="gone" />
363 323
364 324
365
        </com.zhy.autolayout.AutoRelativeLayout>
325
            </com.zhy.autolayout.AutoRelativeLayout>
366 326
367 327
328
            <com.zhy.autolayout.AutoLinearLayout
329
                android:layout_width="fill_parent"
330
                android:layout_height="45dp"
331
                android:background="@color/white"
332
                android:orientation="horizontal"
333
                android:visibility="gone">
368 334
369
        <com.zhy.autolayout.AutoLinearLayout
370
            android:layout_width="fill_parent"
371
            android:layout_height="45dp"
372
            android:background="@color/white"
373
            android:orientation="horizontal"
374
            android:visibility="gone">
375
           <com.zhy.autolayout.AutoLinearLayout
376
               android:id="@+id/rl_1"
377
               android:layout_width="0dp"
378
               android:layout_weight="1"
379
               android:layout_height="match_parent"
380
               android:orientation="horizontal">
381
                <TextView
382
                    android:id="@+id/onclick"
383
                    android:layout_width="wrap_content"
335
                <com.zhy.autolayout.AutoLinearLayout
336
                    android:id="@+id/rl_1"
337
                    android:layout_width="0dp"
384 338
                    android:layout_height="match_parent"
385
                    android:text="品牌"
386
                    android:paddingLeft="16dp"
387
                    android:textSize="16sp"
388
                    android:textColor="@color/hintColor"
389
                    android:gravity="center_vertical"/>
390
               <Spinner
391
                   android:id = "@+id/spinner_province_search_event"
392
                   android:layout_width = "match_parent"
393
                   android:layout_height ="match_parent"
394
                   android:gravity="center"
395
                   android:spinnerMode="dialog">
396
               </Spinner >
397
398
399
               <!--<ImageView-->
400
                   <!--android:layout_width="wrap_content"-->
401
                   <!--android:layout_height="wrap_content"-->
402
                   <!--android:src="@drawable/icon_xiala2_0"-->
403
                   <!--android:layout_centerVertical="true"-->
404
                   <!--android:layout_alignParentRight="true"-->
405
                   <!--android:layout_alignParentEnd="true"-->
406
                   <!--android:layout_marginRight="16dp" />-->
407
           </com.zhy.autolayout.AutoLinearLayout>
339
                    android:layout_weight="1"
340
                    android:orientation="horizontal">
408 341
342
                    <TextView
343
                        android:id="@+id/onclick"
344
                        android:layout_width="wrap_content"
345
                        android:layout_height="match_parent"
346
                        android:gravity="center_vertical"
347
                        android:paddingLeft="16dp"
348
                        android:text="品牌"
349
                        android:textColor="@color/hintColor"
350
                        android:textSize="16sp" />
351
352
                    <Spinner
353
                        android:id="@+id/spinner_province_search_event"
354
                        android:layout_width="match_parent"
355
                        android:layout_height="match_parent"
356
                        android:gravity="center"
357
                        android:spinnerMode="dialog"></Spinner>
358
359
360
                    <!--<ImageView-->
361
                    <!--android:layout_width="wrap_content"-->
362
                    <!--android:layout_height="wrap_content"-->
363
                    <!--android:src="@drawable/icon_xiala2_0"-->
364
                    <!--android:layout_centerVertical="true"-->
365
                    <!--android:layout_alignParentRight="true"-->
366
                    <!--android:layout_alignParentEnd="true"-->
367
                    <!--android:layout_marginRight="16dp" />-->
368
                </com.zhy.autolayout.AutoLinearLayout>
409 369
410
            <com.zhy.autolayout.AutoLinearLayout
411
                android:id="@+id/rl_2"
412
                android:layout_width="0dp"
413
                android:layout_weight="1"
414
                android:layout_height="match_parent"
415
                android:orientation="horizontal">
416 370
417
                <TextView
418
                    android:layout_width="wrap_content"
371
                <com.zhy.autolayout.AutoLinearLayout
372
                    android:id="@+id/rl_2"
373
                    android:layout_width="0dp"
419 374
                    android:layout_height="match_parent"
420
                    android:text="车型"
421
                    android:paddingLeft="44px"
422
                    android:textSize="16sp"
423
                    android:textColor="@color/hintColor"
424
                    android:gravity="center_vertical"/>
425
426
                <Spinner
427
                    android:id = "@+id/spinner_city_search_event"
428
                    android:layout_width = "match_parent"
429
                    android:layout_height ="match_parent"
430
                    android:gravity="center"
431
                    android:spinnerMode="dialog">
432
                </Spinner >
433
                <!--<ImageView-->
375
                    android:layout_weight="1"
376
                    android:orientation="horizontal">
377
378
                    <TextView
379
                        android:layout_width="wrap_content"
380
                        android:layout_height="match_parent"
381
                        android:gravity="center_vertical"
382
                        android:paddingLeft="44px"
383
                        android:text="车型"
384
                        android:textColor="@color/hintColor"
385
                        android:textSize="16sp" />
386
387
                       <Spinner
388
                        android:id="@+id/spinner_city_search_event"
389
                        android:layout_width="match_parent"
390
                        android:layout_height="match_parent"
391
                        android:gravity="center"
392
                        android:spinnerMode="dialog"></Spinner>
393
                    <!--<ImageView-->
434 394
                    <!--android:layout_width="wrap_content"-->
435 395
                    <!--android:layout_height="wrap_content"-->
436 396
                    <!--android:src="@drawable/icon_xiala2_0"-->
@ -439,24 +399,23 @@
439 399
                    <!--android:layout_alignParentEnd="true"-->
440 400
                    <!--android:layout_marginRight="16dp" />-->
441 401
442
            </com.zhy.autolayout.AutoLinearLayout>
402
                </com.zhy.autolayout.AutoLinearLayout>
443 403
444
        </com.zhy.autolayout.AutoLinearLayout>
445
446
        <View
447
            android:layout_width="match_parent"
448
            android:layout_height="0.5dp"
449
            android:background="@color/ui_line"
450
            android:layout_marginLeft="16dp"
451
            android:visibility="gone"/>
404
            </com.zhy.autolayout.AutoLinearLayout>
452 405
406
            <View
407
                android:layout_width="match_parent"
408
                android:layout_height="0.5dp"
409
                android:layout_marginLeft="16dp"
410
                android:background="@color/ui_line"
411
                android:visibility="gone" />
453 412
454 413
455
        <View
456
            android:layout_width="match_parent"
457
            android:layout_height="0.5dp"
458
            android:background="@color/ui_line"
459
            android:visibility="gone"/>
414
            <View
415
                android:layout_width="match_parent"
416
                android:layout_height="0.5dp"
417
                android:background="@color/ui_line"
418
                android:visibility="gone" />
460 419
461 420
        </com.zhy.autolayout.AutoLinearLayout>
462 421
@ -513,49 +472,49 @@
513 472
                android:layout_width="match_parent"
514 473
                android:layout_height="39dp"
515 474
                android:layout_alignParentBottom="true"
516
                android:layout_marginTop="15dp"
517 475
                android:layout_marginLeft="15dp"
476
                android:layout_marginTop="15dp"
518 477
                android:layout_marginRight="15dp"
519 478
                android:layout_marginBottom="8dp"
520 479
                android:background="@drawable/textview_greenstyle"
521
                android:textColor="@color/white"
522
                android:textSize="16sp"
480
                android:gravity="center"
523 481
                android:text="保存"
524
                android:gravity="center" />
482
                android:textColor="@color/white"
483
                android:textSize="16sp" />
525 484
526 485
            <ImageView
527 486
                android:id="@+id/tv_one"
528 487
                android:layout_width="wrap_content"
529 488
                android:layout_height="wrap_content"
530
                android:layout_gravity="center"
489
                android:layout_above="@+id/tv_make_sure"
531 490
532
                android:gravity="center"
491
                android:layout_centerHorizontal="true"
533 492
493
                android:layout_gravity="center"
494
                android:layout_marginBottom="20dp"
495
                android:background="@drawable/icon_5point"
496
                android:gravity="center"
534 497
                android:padding="5dp"
535 498
                android:scaleType="fitXY"
536
                android:background="@drawable/icon_5point"
537 499
                android:textColor="#000000"
538
                android:visibility="gone"
539
                android:layout_marginBottom="20dp"
540
                android:layout_above="@+id/tv_make_sure"
541
                android:layout_centerHorizontal="true" />
500
                android:visibility="gone" />
542 501
543 502
544 503
            <RelativeLayout
545 504
                android:id="@+id/rl_point"
546 505
                android:layout_width="80dp"
547 506
                android:layout_height="80dp"
548
                android:layout_marginBottom="50dp"
549
                android:layout_centerHorizontal="true"
550 507
                android:layout_alignParentBottom="true"
551
                android:visibility="gone"
552
                android:background="@drawable/icon_point_bg">
508
                android:layout_centerHorizontal="true"
509
                android:layout_marginBottom="50dp"
510
                android:background="@drawable/icon_point_bg"
511
                android:visibility="gone">
553 512
554 513
                <LinearLayout
555 514
                    android:layout_width="wrap_content"
556 515
                    android:layout_height="wrap_content"
557
                    android:orientation="vertical"
558
                    android:layout_centerInParent="true">
516
                    android:layout_centerInParent="true"
517
                    android:orientation="vertical">
559 518
560 519
                    <LinearLayout
561 520
                        android:layout_width="wrap_content"
@ -566,17 +525,17 @@
566 525
                            android:layout_width="wrap_content"
567 526
                            android:layout_height="wrap_content"
568 527
                            android:text="+"
569
                            android:textSize="16sp"
570
                            android:textColor="@color/white"/>
528
                            android:textColor="@color/white"
529
                            android:textSize="16sp" />
571 530
572 531
                        <TextView
573 532
                            android:id="@+id/tv_point"
574 533
                            android:layout_width="wrap_content"
575 534
                            android:layout_height="wrap_content"
576
                            android:text="20"
577
                            android:textSize="19sp"
578 535
                            android:layout_marginLeft="2dp"
579
                            android:textColor="@color/white"/>
536
                            android:text="20"
537
                            android:textColor="@color/white"
538
                            android:textSize="19sp" />
580 539
581 540
582 541
                    </LinearLayout>
@ -585,16 +544,15 @@
585 544
                        android:layout_width="wrap_content"
586 545
                        android:layout_height="wrap_content"
587 546
                        android:layout_gravity="center_horizontal"
547
                        android:layout_marginTop="2dp"
588 548
                        android:text="充电币"
589
                        android:textSize="13sp"
590 549
                        android:textColor="@color/white"
591
                        android:layout_marginTop="2dp"/>
550
                        android:textSize="13sp" />
592 551
593 552
594 553
                </LinearLayout>
595 554
596 555
597
598 556
            </RelativeLayout>
599 557
600 558
        </com.zhy.autolayout.AutoRelativeLayout>