]> git.ktnx.net Git - mobile-ledger.git/commitdiff
replace <fragment> with FragmentContainerView as recommended
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 15 Aug 2020 12:44:52 +0000 (15:44 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 15 Aug 2020 12:48:13 +0000 (12:48 +0000)
supposedly more flexible about fragment transactions

app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionActivity.java
app/src/main/res/layout/activity_new_transaction.xml

index 45e75b5b9b585b3532bf0c6cf76ed849e11abb34..7499641741c4a09c19725fbcfac141bc67587492 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2019 Damyan Ivanov.
+ * Copyright © 2020 Damyan Ivanov.
  * This file is part of MoLe.
  * MoLe is free software: you can distribute it and/or modify it
  * under the term of the GNU General Public License as published by
@@ -26,7 +26,7 @@ import android.view.View;
 import androidx.appcompat.widget.Toolbar;
 import androidx.lifecycle.ViewModelProvider;
 import androidx.navigation.NavController;
-import androidx.navigation.Navigation;
+import androidx.navigation.fragment.NavHostFragment;
 
 import net.ktnx.mobileledger.BuildConfig;
 import net.ktnx.mobileledger.R;
@@ -53,7 +53,9 @@ public class NewTransactionActivity extends ProfileThemedActivity implements Tas
         Data.observeProfile(this,
                 mobileLedgerProfile -> toolbar.setSubtitle(mobileLedgerProfile.getName()));
 
-        navController = Navigation.findNavController(this, R.id.new_transaction_nav);
+        NavHostFragment navHostFragment = (NavHostFragment) Objects.requireNonNull(
+                getSupportFragmentManager().findFragmentById(R.id.new_transaction_nav));
+        navController = navHostFragment.getNavController();
 
         Objects.requireNonNull(getSupportActionBar())
                .setDisplayHomeAsUpEnabled(true);
index 7a37dbf841e93a42c9b07c8b1ca5c656d21279fa..d95d8fb00e340eea936848640f588f9b76c05735 100644 (file)
 
         </com.google.android.material.appbar.AppBarLayout>
 
-        <fragment
+        <androidx.fragment.app.FragmentContainerView
             android:id="@+id/new_transaction_nav"
             android:name="androidx.navigation.fragment.NavHostFragment"
             android:layout_width="0dp"
             android:layout_height="0dp"
+            app:defaultNavHost="true"
             app:layout_constraintBottom_toBottomOf="parent"
             app:layout_constraintEnd_toEndOf="parent"
             app:layout_constraintStart_toStartOf="parent"