- AsyncListUtil https://android.jlelse.eu/how-to-use-asynclistutil-16b5175bb468
- PagedListAdapter - to handle paging
Last active
September 18, 2017 03:38
-
-
Save dohaivu/7b0ea982209dc746f4aebbd6c19cf37f to your computer and use it in GitHub Desktop.
RecyclerView #android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void onCreate(Bundle savedInstanceState) { | |
DividerItemDecoration decoration = new DividerItemDecoration(getApplicationContext(), VERTICAL); | |
recyclerView.addItemDecoration(decoration); | |
} | |
// override onDraw ItemDecoration.java, draw a devider line | |
@Override | |
public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state) { | |
canvas.save(); | |
final int leftWithMargin = convertDpToPixel(56); | |
final int right = parent.getWidth(); | |
final int childCount = parent.getChildCount(); | |
for (int i = 0; i < childCount; i++) { | |
final View child = parent.getChildAt(i); | |
int adapterPosition = parent.getChildAdapterPosition(child); | |
left = (adapterPosition == lastPosition) ? 0 : leftWithMargin; | |
parent.getDecoratedBoundsWithMargins(child, mBounds); | |
final int bottom = mBounds.bottom + Math.round(ViewCompat.getTranslationY(child)); | |
final int top = bottom - mDivider.getIntrinsicHeight(); | |
mDivider.setBounds(left, top, right, bottom); | |
mDivider.draw(canvas); | |
} | |
canvas.restore(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment