表示アニメーションを500ms以上かかった場合のみに

This commit is contained in:
ろむねこ 2024-01-26 18:38:02 +09:00
parent 9d750b5244
commit 58e74dbb16
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168

View File

@ -214,16 +214,22 @@ public class LibraryPageFragment extends Fragment {
* RecyclerViewのアイテムとUIを更新する * RecyclerViewのアイテムとUIを更新する
*/ */
private void updateItem(String pageId) { private void updateItem(String pageId) {
long startTime = System.currentTimeMillis();
lacertaLibrary.getLibraryPage(pageId, 10).thenAccept(libraryItemPage -> { lacertaLibrary.getLibraryPage(pageId, 10).thenAccept(libraryItemPage -> {
long endTime = System.currentTimeMillis();
this.libraryItemPage = libraryItemPage; this.libraryItemPage = libraryItemPage;
logger.debug("LibraryTopFragment", "Item selected! libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size()); logger.debug("LibraryTopFragment", "Item selected! libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size());
getActivity().runOnUiThread(() -> { if (endTime - startTime > 500) { // 500ms以上かかった場合は表示アニメーションをする
listItemAdapter.notifyItemRangeRemoved(0, libraryItemPage.getListItems().size() - 1); getActivity().runOnUiThread(() -> {
}); listItemAdapter.setLibraryItemPage(libraryItemPage);
listItemAdapter.setLibraryItemPage(libraryItemPage); listItemAdapter.notifyItemRangeInserted(0, this.libraryItemPage.getListItems().size());
getActivity().runOnUiThread(() -> { });
listItemAdapter.notifyItemRangeInserted(0, libraryItemPage.getListItems().size() - 1); } else {
}); listItemAdapter.setLibraryItemPage(libraryItemPage);
getActivity().runOnUiThread(() -> {
listItemAdapter.notifyDataSetChanged();
});
}
}); });
} }