Hey, everyone, I’ve been trying to find a way to r...
# android
s
Hey, everyone, I’ve been trying to find a way to reverse the order of the items in a paged list (or its data source) but I’m having 0 luck and can’t find any articles on how to do that. Does anyone know a way to achieve this?
a
Something like this?
Copy code
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
linearLayoutManager.setReverseLayout(true);
linearLayoutManager.setStackFromEnd(true);
myRecyclerView.setLayoutManager(linearLayoutManager);
s
Sadly I’m using a GridLayoutManager so setStackFromEnd is not applicable :S
I’m currently using Paging Library with Room DB, my query looks like this:
Copy code
@Query("SELECT * from NOTES ORDER BY creationDate DESC")
    fun getAllNotesDesc(): DataSource.Factory<Int, Note>
I tried a switch/case for DESC/ASC sort, but that also doesn’t work.
I also tried sorting the PagedList before submitting it to the Adapter, but I get an exception, it seems the PagedList is immutable.
s
GridLayoutmanager is child class of linearlayout manager so this method be available for grid layout manager as well
s
Copy code
java.lang.UnsupportedOperationException: GridLayoutManager does not support stack from end. Consider using reverse layout
and only using reverse layout doesn’t have the desired effect