Fix OnboardingViewModel range exception (#26317)

Fix onboarding range exception
This commit is contained in:
Simone Arpe
2024-10-31 16:14:36 +01:00
committed by GitHub
parent 23cf8080bb
commit 5574170fd2
3 changed files with 11 additions and 3 deletions
@@ -6,6 +6,7 @@
package org.chromium.chrome.browser.crypto_wallet.fragments.onboarding;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -137,6 +138,9 @@ public class OnboardingRecoveryPhraseFragment extends BaseOnboardingWalletFragme
keyringService.getWalletMnemonic(
mOnboardingViewModel.getPassword(),
result -> {
if (TextUtils.isEmpty(result)) {
return;
}
mRecoveryPhrases = Utils.getRecoveryPhraseAsList(result);
mRecoveryPhraseAdapter.setRecoveryPhraseList(mRecoveryPhrases);
mRecoveryPhraseRecyclerView.setAdapter(mRecoveryPhraseAdapter);
@@ -195,7 +195,9 @@ public class OnboardingVerifyRecoveryPhraseFragment extends BaseOnboardingWallet
super.onResume();
if (mVerificationStep != null && mWordToMatch == null) {
mWordToMatch = mOnboardingViewModel.getVerificationStep(mVerificationStep);
mCheckWord.setText(getString(R.string.enter_word, mWordToMatch.first + 1));
if (mWordToMatch != null) {
mCheckWord.setText(getString(R.string.enter_word, mWordToMatch.first + 1));
}
}
}
@@ -64,10 +64,12 @@ public class OnboardingViewModel extends ViewModel {
return mPassword;
}
@NonNull
@Nullable
public Pair<Integer, String> getVerificationStep(@NonNull final VerificationStep step) {
assert mVerificationWords.size() != 0 : "Verification word list must not be empty.";
if (mVerificationWords.size() <= step.getValue()) {
return null;
}
return extractPositionAndWordAtIndex(step.getValue());
}