Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to implement messenger-like adapter #733

Open
iskugor opened this issue May 21, 2019 · 2 comments
Open

How to implement messenger-like adapter #733

iskugor opened this issue May 21, 2019 · 2 comments

Comments

@iskugor
Copy link

iskugor commented May 21, 2019

Hello! :)

I'm wondering, what would be the best way to implement messenger-like adapter?

So, we have sorted list where newest items are on top of list (list is sorted by item timestamp), when item is updated (new message arrives) it's moved to the top of the list (as item timestamp is updated) and items can be removed (if user unsubscribes).

My idea is to have my own sorted data list and then compare it with items in adapter, but I wonder if there's something better?

Thanks for your help.

@tcqq
Copy link

tcqq commented May 29, 2019

+1

@VaslD
Copy link

VaslD commented Nov 13, 2019

LayoutManagers already have a reverseLayout field/property to populate the RecyclerView from bottom. Is this what you're trying to achieve?

You can sort your data and add items to the adapter in any sorted order (ascending or descending as long as sorted), just change the layout order to the opposite one I guess? But as a side note, appending an ArrayList is considerably more efficient than inserting into 0th location I believe, so you should do more appends than head-pushing for performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants