From 8a2b4ed12df20bbdbf828260070f00d81ed79feb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Fri, 26 Jan 2024 18:41:05 +0900 Subject: [PATCH] =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E3=82=A2=E3=83=8B=E3=83=A1?= =?UTF-8?q?=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3=E3=82=92500ms=E4=BB=A5?= =?UTF-8?q?=E4=B8=8A=E3=81=8B=E3=81=8B=E3=81=A3=E3=81=9F=E5=A0=B4=E5=90=88?= =?UTF-8?q?=E3=81=AE=E3=81=BF=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lacerta/feature/home/HomeTopFragment.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/feature/home/src/main/java/one/nem/lacerta/feature/home/HomeTopFragment.java b/feature/home/src/main/java/one/nem/lacerta/feature/home/HomeTopFragment.java index e27bcfbd..3f010479 100644 --- a/feature/home/src/main/java/one/nem/lacerta/feature/home/HomeTopFragment.java +++ b/feature/home/src/main/java/one/nem/lacerta/feature/home/HomeTopFragment.java @@ -106,20 +106,22 @@ public class HomeTopFragment extends Fragment { } private void updateList() { + long startTime = System.currentTimeMillis(); lacertaLibrary.getRecentDocument(10).thenAccept(listItems -> { + long endTime = System.currentTimeMillis(); if (listItems == null) { return; } this.listItemAdapter.setListItems(listItems); - getActivity().runOnUiThread(() -> { - Log.d("HomeTopFragment", "onViewCreated: " + listItems.size()); - if (FeatureSwitch.RecyclerView.useSimpleNotifyMethod) { + if (endTime - startTime > 500) { // 500ms以上かかった場合は表示アニメーションをする + getActivity().runOnUiThread(() -> { + this.listItemAdapter.notifyItemRangeInserted(0, listItems.size()); + }); + } else { + getActivity().runOnUiThread(() -> { this.listItemAdapter.notifyDataSetChanged(); - } else { - // IndexOutOfBoundsExceptionを吐くことがあったので いったん - this.listItemAdapter.notifyItemRangeInserted(0, listItems.size() - 1); - } - }); + }); + } }); }