From 67de02b5028a3bd97912d6aa2d76b3040a2e3901 Mon Sep 17 00:00:00 2001 From: r-ca Date: Tue, 23 Jan 2024 00:56:31 +0900 Subject: [PATCH] =?UTF-8?q?=E7=94=BB=E9=9D=A2=E6=8E=A8=E7=A7=BB=E3=81=A7?= =?UTF-8?q?=E7=99=BA=E7=94=9F=E3=81=99=E3=82=8B=E5=95=8F=E9=A1=8C=E3=82=92?= =?UTF-8?q?=E6=A6=82=E3=81=AD=E8=A7=A3=E6=B6=88=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/library/LibraryPageFragment.java | 36 +++++++++---------- .../navigation/feature_library_navigation.xml | 12 ++++++- 2 files changed, 28 insertions(+), 20 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 905fafa8..876d62e6 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 @@ -8,6 +8,7 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; +import androidx.navigation.Navigation; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -29,6 +30,7 @@ import org.w3c.dom.Text; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import javax.inject.Inject; @@ -159,10 +161,19 @@ public class LibraryPageFragment extends Fragment { @Override public void onFolderSelected(String folderId, String folderName) { logger.debug("LibraryTopFragment", "Folder selected! folderId: " + folderId + ", folderName: " + folderName); - // 画面遷移 - FragmentNavigation fragmentNavigation = (FragmentNavigation) getActivity(); - // folderId: 推移先で表示するフォルダのID, folderName: 推移先で表示するフォルダの名前, parentId: このフラグメントで表示しているフォルダのID(推移先の親) - fragmentNavigation.navigateToFragment(LibraryPageFragment.newInstance(folderId, folderName, libraryItemPage != null ? libraryItemPage.getParentId() : null), false); +// // 画面遷移 +// FragmentNavigation fragmentNavigation = (FragmentNavigation) getActivity(); +// // folderId: 推移先で表示するフォルダのID, folderName: 推移先で表示するフォルダの名前, parentId: このフラグメントで表示しているフォルダのID(推移先の親) +// fragmentNavigation.navigateToFragment(LibraryPageFragment.newInstance(folderId, folderName, libraryItemPage != null ? libraryItemPage.getParentId() : null), false); + Bundle bundle = new Bundle(); + bundle.putString("folderId", folderId); + bundle.putString("title", folderName); + bundle.putString("publicPath", libraryItemPage != null ? libraryItemPage.getParentId() : null); + try { + Navigation.findNavController(requireView()).navigate(R.id.action_feature_library_top_fragment_self, bundle); + } catch (IllegalStateException e) { + logger.error("LibraryTopFragment", "IllegalStateException: " + e.getMessage()); + } } @Override @@ -251,7 +262,8 @@ public class LibraryPageFragment extends Fragment { toolbar.setNavigationIcon(one.nem.lacerta.shared.ui.R.drawable.arrow_back_24px); toolbar.setNavigationOnClickListener(v -> { //this.libraryItemPage = lacertaLibrary.getLibraryPage(this.libraryItemPage.getParentId(), 10).join(); - processBack(); + // Back + Navigation.findNavController(requireView()).popBackStack(); }); } else { toolbar.setNavigationIcon(null); @@ -268,18 +280,4 @@ public class LibraryPageFragment extends Fragment { }); }); } - - /** - * Backボタンが押された時の処理 - */ - private void processBack() { - if (this.parentId != null) { - FragmentNavigation fragmentNavigation = (FragmentNavigation) getActivity(); - fragmentNavigation.navigateToFragment(LibraryPageFragment.newInstance(this.parentId)); - } else { // Root - FragmentNavigation fragmentNavigation = (FragmentNavigation) getActivity(); - fragmentNavigation.navigateToFragment(LibraryPageFragment.newInstance()); - } - } - } diff --git a/feature/library/src/main/res/navigation/feature_library_navigation.xml b/feature/library/src/main/res/navigation/feature_library_navigation.xml index 136b7b98..3a5dcd14 100644 --- a/feature/library/src/main/res/navigation/feature_library_navigation.xml +++ b/feature/library/src/main/res/navigation/feature_library_navigation.xml @@ -8,5 +8,15 @@ android:id="@+id/feature_library_top_fragment" android:name="one.nem.lacerta.feature.library.LibraryPageFragment" android:label="fragment_library_top" - tools:layout="@layout/fragment_library_top" /> + tools:layout="@layout/fragment_library_top" > + + \ No newline at end of file