(View view, RecyclerView parent, int pos)
| 577 | } |
| 578 | |
| 579 | private View getView(View view, RecyclerView parent, int pos) { |
| 580 | if (pos == NO_POSITION) |
| 581 | return null; |
| 582 | |
| 583 | if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) |
| 584 | return null; |
| 585 | |
| 586 | TupleAccountFolder prev = adapterNavAccount.getItemAtPosition(pos - 1); |
| 587 | TupleAccountFolder account = adapterNavAccount.getItemAtPosition(pos); |
| 588 | if (pos > 0 && prev == null) |
| 589 | return null; |
| 590 | if (account == null) |
| 591 | return null; |
| 592 | |
| 593 | if (pos > 0) { |
| 594 | if (Objects.equals(prev.category, account.category)) |
| 595 | return null; |
| 596 | } else { |
| 597 | if (account.category == null) |
| 598 | return null; |
| 599 | } |
| 600 | |
| 601 | View header = inflater.inflate(R.layout.item_nav_group, parent, false); |
| 602 | TextView tvCategory = header.findViewById(R.id.tvCategory); |
| 603 | |
| 604 | tvCategory.setText(account.category); |
| 605 | |
| 606 | header.measure(View.MeasureSpec.makeMeasureSpec(parent.getWidth(), View.MeasureSpec.EXACTLY), |
| 607 | View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)); |
| 608 | header.layout(0, 0, header.getMeasuredWidth(), header.getMeasuredHeight()); |
| 609 | |
| 610 | return header; |
| 611 | } |
| 612 | }; |
| 613 | rvAccount.addItemDecoration(categoryDecorator); |
| 614 | } |
no test coverage detected