From 65c6ca77eda6b9321403a3de5f64cc2cc475c2f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 13:41:55 +0900 Subject: [PATCH] Works --- .../lacerta/feature/home/HomeTopFragment.java | 75 +++++++++++-------- .../src/main/res/layout/fragment_home_top.xml | 2 +- 2 files changed, 46 insertions(+), 31 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 a5d26c13..a59a73fd 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 @@ -8,6 +8,7 @@ import android.view.Menu; import android.view.MenuInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Toast; import androidx.annotation.NonNull; @@ -15,6 +16,7 @@ import androidx.appcompat.app.ActionBarDrawerToggle; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.core.content.ContextCompat; +import androidx.core.view.MenuProvider; import androidx.drawerlayout.widget.DrawerLayout; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.LinearLayoutManager; @@ -71,39 +73,52 @@ public class HomeTopFragment extends Fragment { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_home_top, container, false); - setHasOptionsMenu(true); +// setHasOptionsMenu(true); + Toolbar toolbar = view.findViewById(R.id.home_toolbar); + toolbar.setNavigationIcon(one.nem.lacerta.shared.ui.R.drawable.arrow_back_24px); + toolbar.setNavigationOnClickListener(v -> { + Toast.makeText(getContext(), "Works!!!!!!!!!!!!", Toast.LENGTH_SHORT).show(); + }); + toolbar.inflateMenu(R.menu.drawer_menu); + toolbar.setOnMenuItemClickListener(item -> { + if (item.getItemId() == R.id.item_placeholder) { + Toast.makeText(getContext(), "Works!", Toast.LENGTH_SHORT).show(); + return true; + } + return false; + }); return view; } - @Override - public void onViewCreated(View view, Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - - RecyclerView recyclerView = view.findViewById(R.id.home_item_recycler_view); - - - ListItemAdapter listItemAdapter = new ListItemAdapter(documentId -> { - Log.d("HomeTopFragment", "onViewCreated: " + documentId); - Intent intent = new Intent(getContext(), ViewerMainActivity.class); - intent.putExtra("documentId", documentId); - startActivity(intent); - }); - recyclerView.setAdapter(listItemAdapter); - recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); - - lacertaLibrary.getRecentDocument(10).thenAccept(listItems -> { - listItemAdapter.setListItems(listItems); - getActivity().runOnUiThread(() -> { - listItemAdapter.notifyItemRangeInserted(0, listItems.size()); - }); - }); - } - - @Override - public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) { - inflater.inflate(R.menu.drawer_menu, menu); - super.onCreateOptionsMenu(menu, inflater); - } +// @Override +// public void onViewCreated(View view, Bundle savedInstanceState) { +// super.onViewCreated(view, savedInstanceState); +// +// RecyclerView recyclerView = view.findViewById(R.id.home_item_recycler_view); +// +// +// ListItemAdapter listItemAdapter = new ListItemAdapter(documentId -> { +// Log.d("HomeTopFragment", "onViewCreated: " + documentId); +// Intent intent = new Intent(getContext(), ViewerMainActivity.class); +// intent.putExtra("documentId", documentId); +// startActivity(intent); +// }); +// recyclerView.setAdapter(listItemAdapter); +// recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); +// +// lacertaLibrary.getRecentDocument(10).thenAccept(listItems -> { +// listItemAdapter.setListItems(listItems); +// getActivity().runOnUiThread(() -> { +// listItemAdapter.notifyItemRangeInserted(0, listItems.size()); +// }); +// }); +// } +// +// @Override +// public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) { +// inflater.inflate(R.menu.drawer_menu, menu); +// super.onCreateOptionsMenu(menu, inflater); +// } } diff --git a/feature/home/src/main/res/layout/fragment_home_top.xml b/feature/home/src/main/res/layout/fragment_home_top.xml index 3fc0b723..e3b70845 100644 --- a/feature/home/src/main/res/layout/fragment_home_top.xml +++ b/feature/home/src/main/res/layout/fragment_home_top.xml @@ -29,7 +29,7 @@ app:layout_scrollFlags="scroll|exitUntilCollapsed">