This commit is contained in:
ろむねこ 2024-01-22 13:41:55 +09:00
parent f02440348b
commit 65c6ca77ed
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168
2 changed files with 46 additions and 31 deletions

View File

@ -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);
// }
}

View File

@ -29,7 +29,7 @@
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:id="@+id/home_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"