画面推移で発生する問題を概ね解消した

This commit is contained in:
r-ca 2024-01-23 00:56:31 +09:00
parent 5fafbec247
commit 67de02b502
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9
2 changed files with 28 additions and 20 deletions

View File

@ -8,6 +8,7 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.navigation.Navigation;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -29,6 +30,7 @@ import org.w3c.dom.Text;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import javax.inject.Inject; import javax.inject.Inject;
@ -159,10 +161,19 @@ public class LibraryPageFragment extends Fragment {
@Override @Override
public void onFolderSelected(String folderId, String folderName) { public void onFolderSelected(String folderId, String folderName) {
logger.debug("LibraryTopFragment", "Folder selected! folderId: " + folderId + ", folderName: " + folderName); logger.debug("LibraryTopFragment", "Folder selected! folderId: " + folderId + ", folderName: " + folderName);
// 画面遷移 // // 画面遷移
FragmentNavigation fragmentNavigation = (FragmentNavigation) getActivity(); // FragmentNavigation fragmentNavigation = (FragmentNavigation) getActivity();
// folderId: 推移先で表示するフォルダのID, folderName: 推移先で表示するフォルダの名前, parentId: このフラグメントで表示しているフォルダのID(推移先の親) // // folderId: 推移先で表示するフォルダのID, folderName: 推移先で表示するフォルダの名前, parentId: このフラグメントで表示しているフォルダのID(推移先の親)
fragmentNavigation.navigateToFragment(LibraryPageFragment.newInstance(folderId, folderName, libraryItemPage != null ? libraryItemPage.getParentId() : null), false); // 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 @Override
@ -251,7 +262,8 @@ public class LibraryPageFragment extends Fragment {
toolbar.setNavigationIcon(one.nem.lacerta.shared.ui.R.drawable.arrow_back_24px); toolbar.setNavigationIcon(one.nem.lacerta.shared.ui.R.drawable.arrow_back_24px);
toolbar.setNavigationOnClickListener(v -> { toolbar.setNavigationOnClickListener(v -> {
//this.libraryItemPage = lacertaLibrary.getLibraryPage(this.libraryItemPage.getParentId(), 10).join(); //this.libraryItemPage = lacertaLibrary.getLibraryPage(this.libraryItemPage.getParentId(), 10).join();
processBack(); // Back
Navigation.findNavController(requireView()).popBackStack();
}); });
} else { } else {
toolbar.setNavigationIcon(null); 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());
}
}
} }

View File

@ -8,5 +8,15 @@
android:id="@+id/feature_library_top_fragment" android:id="@+id/feature_library_top_fragment"
android:name="one.nem.lacerta.feature.library.LibraryPageFragment" android:name="one.nem.lacerta.feature.library.LibraryPageFragment"
android:label="fragment_library_top" android:label="fragment_library_top"
tools:layout="@layout/fragment_library_top" /> tools:layout="@layout/fragment_library_top" >
<action
android:id="@+id/action_feature_library_top_fragment_self"
app:destination="@id/feature_library_top_fragment"
app:enterAnim="@anim/nav_default_enter_anim"
app:exitAnim="@anim/nav_default_exit_anim"
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
app:popExitAnim="@anim/nav_default_pop_exit_anim"
app:popUpTo="@id/feature_library_top_fragment"
app:popUpToInclusive="false"/>
</fragment>
</navigation> </navigation>