Browse Source

fix navigation issue (#13)

V1.2.0-btc-release
JunZhang 5 years ago
committed by GitHub
parent
commit
2b56db73a6
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 39
      app/src/main/java/com/cobo/cold/ui/fragment/setup/ConfirmMnemonicFragment.java
  2. 15
      app/src/main/java/com/cobo/cold/ui/fragment/setup/MnemonicInputFragment.java

39
app/src/main/java/com/cobo/cold/ui/fragment/setup/ConfirmMnemonicFragment.java

@ -17,7 +17,6 @@
package com.cobo.cold.ui.fragment.setup;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
@ -25,17 +24,7 @@ import androidx.databinding.ObservableField;
import com.cobo.cold.R;
import com.cobo.cold.Utilities;
import com.cobo.cold.db.PresetData;
import com.cobo.cold.db.entity.CoinEntity;
import com.cobo.cold.ui.SetupVaultActivity;
import com.cobo.cold.util.Keyboard;
import com.cobo.cold.viewmodel.SetupVaultViewModel;
import java.util.List;
import static com.cobo.cold.Utilities.IS_SETUP_VAULT;
import static com.cobo.cold.viewmodel.SetupVaultViewModel.VAULT_STATE_CREATED;
import static com.cobo.cold.viewmodel.SetupVaultViewModel.VAULT_STATE_CREATING;
public class ConfirmMnemonicFragment extends MnemonicInputFragment {
@ -58,34 +47,6 @@ public class ConfirmMnemonicFragment extends MnemonicInputFragment {
});
}
@Override
protected void subscribeVaultState(SetupVaultViewModel viewModel) {
viewModel.getVaultCreateState().observe(this, state -> {
if (state == VAULT_STATE_CREATING) {
showModal();
} else if (state == VAULT_STATE_CREATED) {
Utilities.setVaultCreated(mActivity);
Utilities.setVaultId(mActivity, viewModel.getVaultId());
Utilities.setCurrentBelongTo(mActivity, "main");
Utilities.setMnemonicCount(mActivity, viewModel.getMnemonicCount().get());
Runnable onComplete = () -> {
if (dialog != null && dialog.getDialog() != null && dialog.getDialog().isShowing()) {
dialog.dismiss();
}
Bundle data = new Bundle();
data.putBoolean(IS_SETUP_VAULT, ((SetupVaultActivity) mActivity).isSetupVault);
navigate(R.id.action_to_setupSyncFragment, data);
};
List<CoinEntity> coins = PresetData.generateCoins(mActivity);
viewModel.presetData(coins, onComplete);
}
});
}
private void verifyMnemonic() {
String mnemonic = mBinding.table.getWordsList()
.stream()

15
app/src/main/java/com/cobo/cold/ui/fragment/setup/MnemonicInputFragment.java

@ -17,6 +17,7 @@
package com.cobo.cold.ui.fragment.setup;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
@ -34,6 +35,7 @@ import com.cobo.cold.databinding.CreateVaultModalBinding;
import com.cobo.cold.databinding.MnemonicInputFragmentBinding;
import com.cobo.cold.db.PresetData;
import com.cobo.cold.db.entity.CoinEntity;
import com.cobo.cold.ui.MainActivity;
import com.cobo.cold.ui.SetupVaultActivity;
import com.cobo.cold.ui.modal.ModalDialog;
import com.cobo.cold.util.Keyboard;
@ -99,9 +101,16 @@ public class MnemonicInputFragment extends SetupVaultBaseFragment<MnemonicInputF
if (dialog != null && dialog.getDialog() != null && dialog.getDialog().isShowing()) {
dialog.dismiss();
}
Bundle data = new Bundle();
data.putBoolean(IS_SETUP_VAULT, ((SetupVaultActivity) mActivity).isSetupVault);
navigate(R.id.action_to_setupSyncFragment, data);
if (((SetupVaultActivity) mActivity).isSetupVault) {
Bundle data = new Bundle();
data.putBoolean(IS_SETUP_VAULT, ((SetupVaultActivity) mActivity).isSetupVault);
navigate(R.id.action_to_setupSyncFragment, data);
} else {
Intent intent = new Intent(mActivity,MainActivity.class);
startActivity(intent);
mActivity.finish();
}
};
List<CoinEntity> coins = PresetData.generateCoins(mActivity);

Loading…
Cancel
Save