挿入時にアニメーションが発生するように

This commit is contained in:
r-ca 2024-01-20 23:51:34 +09:00
parent c53c4ed9a1
commit 017a2413b6
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9

View File

@ -15,7 +15,6 @@ import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.drawerlayout.widget.DrawerLayout; import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -77,7 +76,7 @@ public class HomeTopFragment extends Fragment {
super.onViewCreated(view, savedInstanceState); super.onViewCreated(view, savedInstanceState);
RecyclerView recyclerView = view.findViewById(R.id.home_item_recycler_view); RecyclerView recyclerView = view.findViewById(R.id.home_item_recycler_view);
recyclerView.setItemAnimator(new DefaultItemAnimator());
ListItemAdapter listItemAdapter = new ListItemAdapter(); ListItemAdapter listItemAdapter = new ListItemAdapter();
recyclerView.setAdapter(listItemAdapter); recyclerView.setAdapter(listItemAdapter);
@ -85,7 +84,9 @@ public class HomeTopFragment extends Fragment {
lacertaLibrary.getRecentDocument(10).thenAccept(listItems -> { lacertaLibrary.getRecentDocument(10).thenAccept(listItems -> {
listItemAdapter.setListItems(listItems); listItemAdapter.setListItems(listItems);
getActivity().runOnUiThread(listItemAdapter::notifyDataSetChanged); getActivity().runOnUiThread(() -> {
listItemAdapter.notifyItemRangeInserted(0, listItems.size());
});
}); });
CollapsingToolbarLayout collapsingToolbarLayout = view.findViewById(R.id.collapsing_toolbar); CollapsingToolbarLayout collapsingToolbarLayout = view.findViewById(R.id.collapsing_toolbar);