mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-23 00:13:16 +00:00
遅れて追加されたアイテムをUIに反映できるように
This commit is contained in:
parent
aaff0be438
commit
12ba9234a4
|
@ -15,6 +15,7 @@ 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;
|
||||||
|
|
||||||
|
@ -23,6 +24,7 @@ import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
@ -67,18 +69,6 @@ public class HomeTopFragment extends Fragment {
|
||||||
// Inflate the layout for this fragment
|
// Inflate the layout for this fragment
|
||||||
View view = inflater.inflate(R.layout.fragment_home_top, container, false);
|
View view = inflater.inflate(R.layout.fragment_home_top, container, false);
|
||||||
|
|
||||||
ArrayList<ListItem> 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;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,6 +76,18 @@ public class HomeTopFragment extends Fragment {
|
||||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, 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);
|
CollapsingToolbarLayout collapsingToolbarLayout = view.findViewById(R.id.collapsing_toolbar);
|
||||||
Toolbar toolbar = view.findViewById(R.id.toolbar);
|
Toolbar toolbar = view.findViewById(R.id.toolbar);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user