From e96d213c33e44b173eff4db1cdd63d088a13a32c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Fri, 26 Jan 2024 18:33:02 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=91=E3=82=B9=E3=82=92=E3=82=B5=E3=83=96?= =?UTF-8?q?=E3=82=BF=E3=82=A4=E3=83=88=E3=83=AB=E3=81=AB=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E3=81=99=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 --- .../feature/library/LibraryPageFragment.java | 27 ++++++++++++++++--- .../main/res/layout/fragment_library_top.xml | 4 +-- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java index df1ad96b..0bf1c21a 100644 --- a/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java +++ b/feature/library/src/main/java/one/nem/lacerta/feature/library/LibraryPageFragment.java @@ -23,6 +23,7 @@ import dagger.hilt.android.AndroidEntryPoint; import one.nem.lacerta.component.viewer.ViewerMainActivity; import one.nem.lacerta.data.LacertaLibrary; import one.nem.lacerta.model.LibraryItemPage; +import one.nem.lacerta.model.ListItemType; import one.nem.lacerta.utils.FeatureSwitch; import one.nem.lacerta.utils.LacertaLogger; @@ -43,6 +44,7 @@ public class LibraryPageFragment extends Fragment { String folderId; String title; String parentId; + Toolbar toolbar; @Inject @@ -128,12 +130,19 @@ public class LibraryPageFragment extends Fragment { logger.debug("LibraryTopFragment", "getArguments() is null(maybe root)"); this.libraryItemPage = new LibraryItemPage(); } + this.toolbar = view.findViewById(R.id.library_toolbar); // Toolbar Setup - toolbarSetup(view.findViewById(R.id.library_toolbar), this.folderId != null, this.title != null ? this.title : "ライブラリ"); + toolbarSetup(this.toolbar, this.folderId != null, this.title != null ? this.title : "ライブラリ"); + if(this.folderId == null) { + updateToolbarSubtitle(this.toolbar, null); //負荷軽減のため+邪魔なので(folderIdがnullの場合は、ルートフォルダを表示しているので) + } else { + lacertaLibrary.getPublicPath(this.folderId, ListItemType.ITEM_TYPE_FOLDER).thenAccept(publicPath -> { + updateToolbarSubtitle(this.toolbar, "/" + publicPath.parent().getStringPath()); + }); + } // RecyclerView Setup - RecyclerView recyclerView = view.findViewById(R.id.library_item_recycler_view); this.listItemAdapter = new ListItemAdapter(new DocumentSelectListener() { @Override @@ -168,6 +177,7 @@ public class LibraryPageFragment extends Fragment { recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); // Get library page and update RecyclerView items + lacertaLibrary.getLibraryPage(this.folderId, 10).thenAccept(libraryItemPage -> { this.libraryItemPage = libraryItemPage; @@ -216,6 +226,7 @@ public class LibraryPageFragment extends Fragment { lacertaLibrary.createFolder(pageId, input.getText().toString()).thenAccept(folderId -> { // Refresh updateItem(pageId); + }); }); builder.setNegativeButton("キャンセル", (dialog, which) -> { @@ -226,7 +237,7 @@ public class LibraryPageFragment extends Fragment { } /** - * RecyclerViewのアイテムを更新する + * RecyclerViewのアイテムとUIを更新する */ private void updateItem(String pageId) { lacertaLibrary.getLibraryPage(pageId, 10).thenAccept(libraryItemPage -> { @@ -242,6 +253,16 @@ public class LibraryPageFragment extends Fragment { }); } + /** + * Toolbarのサブタイトルを更新 + * @param subtitle サブタイトル + */ + private void updateToolbarSubtitle(Toolbar toolbar, String subtitle) { + getActivity().runOnUiThread(() -> { + toolbar.setSubtitle(subtitle); + }); + } + /** * ToolbarをInitする * diff --git a/feature/library/src/main/res/layout/fragment_library_top.xml b/feature/library/src/main/res/layout/fragment_library_top.xml index f9d53d56..29f1bcbf 100644 --- a/feature/library/src/main/res/layout/fragment_library_top.xml +++ b/feature/library/src/main/res/layout/fragment_library_top.xml @@ -13,7 +13,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - - +