deal with user closing fragment while doing wallet stuff

This commit is contained in:
m2049r 2017-08-16 12:39:00 +02:00
parent fb62074d20
commit 952fb3a7f1
1 changed files with 6 additions and 2 deletions

View File

@ -280,7 +280,8 @@ public class LoginActivity extends Activity
newWallet.close(); newWallet.close();
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
public void run() { public void run() {
genFragment.showMnemonic(mnemonic); if (genFragment.isAdded())
genFragment.showMnemonic(mnemonic);
} }
}); });
} }
@ -290,6 +291,8 @@ public class LoginActivity extends Activity
@Override @Override
public void onAccept(final String name, final String password) { public void onAccept(final String name, final String password) {
final GenerateFragment genFragment = (GenerateFragment)
getFragmentManager().findFragmentById(R.id.fragment_container);
File newWalletFolder = new File(getStorageRoot(), ".new"); File newWalletFolder = new File(getStorageRoot(), ".new");
if (!newWalletFolder.isDirectory()) { if (!newWalletFolder.isDirectory()) {
Log.e(TAG, "New wallet dir " + newWalletFolder.getAbsolutePath() + "is not a directory"); Log.e(TAG, "New wallet dir " + newWalletFolder.getAbsolutePath() + "is not a directory");
@ -324,7 +327,8 @@ public class LoginActivity extends Activity
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
public void run() { public void run() {
if (rc) { if (rc) {
getFragmentManager().popBackStack(); if (genFragment.isAdded())
getFragmentManager().popBackStack();
Toast.makeText(LoginActivity.this, Toast.makeText(LoginActivity.this,
getString(R.string.generate_wallet_created), Toast.LENGTH_SHORT).show(); getString(R.string.generate_wallet_created), Toast.LENGTH_SHORT).show();
} else { } else {