From 12ba9234a46fbd1c51c11366421c51842e7dd6d7 Mon Sep 17 00:00:00 2001 From: r-ca Date: Sat, 20 Jan 2024 23:49:13 +0900 Subject: [PATCH] =?UTF-8?q?=E9=81=85=E3=82=8C=E3=81=A6=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=E3=81=95=E3=82=8C=E3=81=9F=E3=82=A2=E3=82=A4=E3=83=86=E3=83=A0?= =?UTF-8?q?=E3=82=92UI=E3=81=AB=E5=8F=8D=E6=98=A0=E3=81=A7=E3=81=8D?= =?UTF-8?q?=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 | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 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 46a452d5..f8cc7ba2 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 @@ -15,6 +15,7 @@ import androidx.appcompat.widget.Toolbar; import androidx.core.content.ContextCompat; import androidx.drawerlayout.widget.DrawerLayout; import androidx.fragment.app.Fragment; +import androidx.recyclerview.widget.DefaultItemAnimator; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -23,6 +24,7 @@ import com.google.android.material.appbar.CollapsingToolbarLayout; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.CompletableFuture; import javax.inject.Inject; @@ -67,18 +69,6 @@ public class HomeTopFragment extends Fragment { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_home_top, container, false); - ArrayList recentDocument = lacertaLibrary.getRecentDocument(10); - - Log.d("docs", Integer.toString(recentDocument.size())); - - RecyclerView recyclerView = view.findViewById(R.id.home_item_recycler_view); - - recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); - - ListItemAdapter listItemAdapter = new ListItemAdapter(recentDocument); - - recyclerView.setAdapter(listItemAdapter); - return view; } @@ -86,6 +76,18 @@ public class HomeTopFragment extends Fragment { public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); + RecyclerView recyclerView = view.findViewById(R.id.home_item_recycler_view); + recyclerView.setItemAnimator(new DefaultItemAnimator()); + + ListItemAdapter listItemAdapter = new ListItemAdapter(); + recyclerView.setAdapter(listItemAdapter); + recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); + + lacertaLibrary.getRecentDocument(10).thenAccept(listItems -> { + listItemAdapter.setListItems(listItems); + getActivity().runOnUiThread(listItemAdapter::notifyDataSetChanged); + }); + CollapsingToolbarLayout collapsingToolbarLayout = view.findViewById(R.id.collapsing_toolbar); Toolbar toolbar = view.findViewById(R.id.toolbar);