[英]How to make SwipeRefreshLayout work when the RecyclerView is empty
[英]How to make Paging library work with reverse recyclerview?
如何使用最新的分頁與無休止的反向回收視圖進行聊天?
我有線性布局,反向布局為真:
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
layoutManager.setReverseLayout(true);
layoutManager.setStackFromEnd(true);
和內部滾動偵聽器:
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
int visibleItemCount = layoutManager.getChildCount();
int totalItemCount = layoutManager.getItemCount();
int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition();
if (!isLoading && !isLastPage) {
if ((visibleItemCount + firstVisibleItemPosition) >= totalItemCount
&& firstVisibleItemPosition >= 0
&& totalItemCount >= PAGE_SIZE) {
loadMoreItems();
}
}
}
獲取消息的查詢:
SELECT * FROM Message WHERE chatId = :chatId ORDER BY dbId ASC
用於下面的房間;
@Query("SELECT * FROM Message WHERE chatId = :chatId ORDER BY dbId ASC")
DataSource.Factory<Integer,Message> fetchAll(String chatId);
問題是如果我在查詢中使用ASC,列表會自動滾動並獲取其他消息。 如果使用DESC,則消息列表不按順序排列。
有人可以幫忙嗎?
我覺得這很有意思
layoutManager.setStackFromEnd(假);
layoutManager.setReverseLayout(真);
如果您在房間數據庫中有一個增量列表(行索引/控制),您可以在DESC模式下對其進行排序
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.