Fix problem with Navigation from the ImportBrainkeyFragment and CreateAccountFragment when an account is imported/created and the user has to be taken back to the MainFragment.
This commit is contained in:
parent
78909498c0
commit
8894c48e5c
4 changed files with 49 additions and 40 deletions
|
@ -2,6 +2,7 @@ package cy.agorise.bitsybitshareswallet.fragments
|
|||
|
||||
import android.preference.PreferenceManager
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import cy.agorise.bitsybitshareswallet.R
|
||||
import cy.agorise.bitsybitshareswallet.database.entities.Authority
|
||||
import cy.agorise.bitsybitshareswallet.repositories.AuthorityRepository
|
||||
import cy.agorise.bitsybitshareswallet.repositories.UserAccountRepository
|
||||
|
@ -72,7 +73,7 @@ abstract class BaseAccountFragment : ConnectedFragment() {
|
|||
}
|
||||
|
||||
// Send the user back to HomeFragment
|
||||
findNavController().popBackStack()
|
||||
findNavController().navigate(R.id.home_action)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package cy.agorise.bitsybitshareswallet.fragments
|
||||
|
||||
import android.os.Bundle
|
||||
import android.preference.PreferenceManager
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
|
@ -33,6 +34,8 @@ import cy.agorise.bitsybitshareswallet.models.FaucetResponse
|
|||
import cy.agorise.bitsybitshareswallet.network.ServiceGenerator
|
||||
import retrofit2.Call
|
||||
import retrofit2.Response
|
||||
import java.util.*
|
||||
import kotlin.concurrent.timerTask
|
||||
|
||||
|
||||
class CreateAccountFragment : BaseAccountFragment() {
|
||||
|
@ -226,8 +229,11 @@ class CreateAccountFragment : BaseAccountFragment() {
|
|||
// Execute the call asynchronously. Get a positive or negative callback.
|
||||
call.enqueue(object : Callback<FaucetResponse> {
|
||||
override fun onResponse(call: Call<FaucetResponse>, response: Response<FaucetResponse>) {
|
||||
// The network call was a success and we got a response
|
||||
getCreatedAccountInfo(response.body())
|
||||
// The network call was a success and we got a response, obtain the info of the newly created account
|
||||
// with a delay to let the nodes update their information
|
||||
Timer().schedule(timerTask {
|
||||
getCreatedAccountInfo(response.body())
|
||||
}, 4000)
|
||||
}
|
||||
|
||||
override fun onFailure(call: Call<FaucetResponse>, t: Throwable) {
|
||||
|
|
|
@ -53,7 +53,7 @@ class HomeFragment : Fragment() {
|
|||
.getString(Constants.KEY_CURRENT_ACCOUNT_ID, "") ?: ""
|
||||
|
||||
if (agreedLicenseVersion != Constants.CURRENT_LICENSE_VERSION || userId == "") {
|
||||
findNavController().navigate(R.id.setup_action)
|
||||
findNavController().navigate(R.id.license_action)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ class HomeFragment : Fragment() {
|
|||
mUserAccountViewModel = ViewModelProviders.of(this).get(UserAccountViewModel::class.java)
|
||||
|
||||
mUserAccountViewModel.getUserAccount(userId).observe(this, Observer<UserAccount>{ user ->
|
||||
tvAccountName.text = user.name
|
||||
tvAccountName.text = user?.name ?: ""
|
||||
})
|
||||
|
||||
// Navigate to the Receive Transaction Fragment
|
||||
|
|
|
@ -37,8 +37,8 @@
|
|||
app:popExitAnim="@anim/slide_out_right"/>
|
||||
|
||||
<action
|
||||
android:id="@+id/setup_action"
|
||||
app:destination="@id/navigation_setup"/>
|
||||
android:id="@+id/license_action"
|
||||
app:destination="@id/license_dest"/>
|
||||
|
||||
</fragment>
|
||||
|
||||
|
@ -78,46 +78,48 @@
|
|||
android:defaultValue="false" />
|
||||
</fragment>
|
||||
|
||||
<navigation
|
||||
android:id="@+id/navigation_setup"
|
||||
app:startDestination="@id/license_dest">
|
||||
<fragment
|
||||
android:id="@+id/license_dest"
|
||||
android:name="cy.agorise.bitsybitshareswallet.fragments.LicenseFragment"
|
||||
android:label="@string/app_name"
|
||||
tools:layout="@layout/fragment_license">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/license_dest"
|
||||
android:name="cy.agorise.bitsybitshareswallet.fragments.LicenseFragment"
|
||||
android:label="@string/app_name"
|
||||
tools:layout="@layout/fragment_license">
|
||||
<action
|
||||
android:id="@+id/import_brainkey_action"
|
||||
app:destination="@id/import_brainkey_dest"/>
|
||||
|
||||
<action
|
||||
android:id="@+id/import_brainkey_action"
|
||||
app:destination="@id/import_brainkey_dest"
|
||||
app:popUpTo="@id/license_dest"
|
||||
app:popUpToInclusive="true"/>
|
||||
</fragment>
|
||||
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/import_brainkey_dest"
|
||||
android:name="cy.agorise.bitsybitshareswallet.fragments.ImportBrainkeyFragment"
|
||||
android:label="@string/app_name"
|
||||
tools:layout="@layout/fragment_import_brainkey">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/import_brainkey_dest"
|
||||
android:name="cy.agorise.bitsybitshareswallet.fragments.ImportBrainkeyFragment"
|
||||
android:label="@string/app_name"
|
||||
tools:layout="@layout/fragment_import_brainkey">
|
||||
<action
|
||||
android:id="@+id/create_account_action"
|
||||
app:destination="@id/create_account_dest"
|
||||
app:enterAnim="@anim/slide_in_right"
|
||||
app:exitAnim="@anim/slide_out_left"
|
||||
app:popEnterAnim="@anim/slide_in_left"
|
||||
app:popExitAnim="@anim/slide_out_right"/>
|
||||
|
||||
<action
|
||||
android:id="@+id/create_account_action"
|
||||
app:destination="@id/create_account_dest"
|
||||
app:enterAnim="@anim/slide_in_right"
|
||||
app:exitAnim="@anim/slide_out_left"
|
||||
app:popEnterAnim="@anim/slide_in_left"
|
||||
app:popExitAnim="@anim/slide_out_right"/>
|
||||
<action
|
||||
android:id="@+id/home_action"
|
||||
app:popUpTo="@id/home_dest"/>
|
||||
|
||||
</fragment>
|
||||
</fragment>
|
||||
|
||||
<fragment
|
||||
android:id="@+id/create_account_dest"
|
||||
android:name="cy.agorise.bitsybitshareswallet.fragments.CreateAccountFragment"
|
||||
android:label="@string/app_name"
|
||||
tools:layout="@layout/fragment_create_account"/>
|
||||
<fragment
|
||||
android:id="@+id/create_account_dest"
|
||||
android:name="cy.agorise.bitsybitshareswallet.fragments.CreateAccountFragment"
|
||||
android:label="@string/app_name"
|
||||
tools:layout="@layout/fragment_create_account">
|
||||
|
||||
</navigation>
|
||||
<action
|
||||
android:id="@+id/home_action"
|
||||
app:popUpTo="@id/home_dest"/>
|
||||
|
||||
</fragment>
|
||||
|
||||
</navigation>
|
Loading…
Reference in a new issue