|
|
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
|
}
|
|
|
@ -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
|
}
|
|
|
@ -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
|
}
|
|
|
@ -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
|
}
|
|
|
@ -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
|
}
|
|
|
@ -0,0 +1,5 @@
|
|
|
1
|
package com.donkingliang.groupedadapter.widget;
|
|
|
2
|
|
|
|
3
|
public interface StickyHeaderPositionListener {
|
|
|
4
|
public void onHeaderPositionChange(int groupPosition);
|
|
|
5
|
}
|
|
|
@ -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
|
}
|
|
|
@ -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
|
}
|
|
|
@ -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
|
}
|
|
|
@ -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();
|
|
|
@ -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
|
}
|
|
|
@ -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
|
}
|
|
|
@ -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
|
}
|
|
|
@ -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
|
}
|
|
|
@ -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
|
}
|
|
|
@ -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
|
}
|
|
|
@ -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
|
}
|
|
|
@ -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
|
}
|
|
|
@ -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
|
}
|
|
|
@ -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
|
}
|
|
|
@ -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
|
}
|
|
|
@ -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
|
}
|
|
|
@ -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>
|
|
|
@ -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>
|
|
|
@ -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>
|
|
|
@ -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>
|
|
|
@ -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"
|
|
|
@ -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>
|
|
|
@ -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>
|
|
|
@ -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>
|
|
|
@ -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>
|
|
|
@ -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>
|
|
|
@ -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>
|
|
|
@ -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>
|