From 06771d2e74f9cb1e8722b77a209452ec9ec5e6b8 Mon Sep 17 00:00:00 2001 From: r-ca Date: Tue, 23 Jan 2024 04:27:20 +0900 Subject: [PATCH] =?UTF-8?q?Resume=E6=99=82=E3=81=AB=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E3=81=95=E3=82=8C=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lacerta/feature/home/HomeTopFragment.java | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 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 5fea2c36..943d2b31 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 @@ -51,6 +51,8 @@ public class HomeTopFragment extends Fragment { @Inject LacertaLibrary lacertaLibrary; + private ListItemAdapter listItemAdapter; + public HomeTopFragment() { // Required empty public constructor } @@ -85,7 +87,7 @@ public class HomeTopFragment extends Fragment { Toolbar toolbar = view.findViewById(R.id.home_toolbar); toolbarSetup(toolbar, false, "ホーム"); - ListItemAdapter listItemAdapter = new ListItemAdapter(new DocumentSelectListener() { + this.listItemAdapter = new ListItemAdapter(new DocumentSelectListener() { @Override public void onDocumentSelect(String documentId, String documentName) { Intent intent = new Intent(getContext(), ViewerMainActivity.class); @@ -98,18 +100,29 @@ public class HomeTopFragment extends Fragment { recyclerView.setAdapter(listItemAdapter); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); + updateList(); + } + + @Override + public void onResume() { + super.onResume(); + + updateList(); + } + + private void updateList() { lacertaLibrary.getRecentDocument(10).thenAccept(listItems -> { if (listItems == null) { return; } - listItemAdapter.setListItems(listItems); + this.listItemAdapter.setListItems(listItems); getActivity().runOnUiThread(() -> { Log.d("HomeTopFragment", "onViewCreated: " + listItems.size()); if (FeatureSwitch.RecyclerView.useSimpleNotifyMethod) { - listItemAdapter.notifyDataSetChanged(); + this.listItemAdapter.notifyDataSetChanged(); } else { // IndexOutOfBoundsExceptionを吐くことがあったので いったん - listItemAdapter.notifyItemRangeInserted(0, listItems.size() - 1); + this.listItemAdapter.notifyItemRangeInserted(0, listItems.size() - 1); } }); });