From 952fb3a7f123bfd581e9630dc3a94b9b97080c3f Mon Sep 17 00:00:00 2001 From: m2049r <30435443+m2049r@users.noreply.github.com> Date: Wed, 16 Aug 2017 12:39:00 +0200 Subject: [PATCH] deal with user closing fragment while doing wallet stuff --- app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java b/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java index b9d2c757..b9becc42 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java +++ b/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java @@ -280,7 +280,8 @@ public class LoginActivity extends Activity newWallet.close(); runOnUiThread(new Runnable() { public void run() { - genFragment.showMnemonic(mnemonic); + if (genFragment.isAdded()) + genFragment.showMnemonic(mnemonic); } }); } @@ -290,6 +291,8 @@ public class LoginActivity extends Activity @Override 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"); if (!newWalletFolder.isDirectory()) { Log.e(TAG, "New wallet dir " + newWalletFolder.getAbsolutePath() + "is not a directory"); @@ -324,7 +327,8 @@ public class LoginActivity extends Activity runOnUiThread(new Runnable() { public void run() { if (rc) { - getFragmentManager().popBackStack(); + if (genFragment.isAdded()) + getFragmentManager().popBackStack(); Toast.makeText(LoginActivity.this, getString(R.string.generate_wallet_created), Toast.LENGTH_SHORT).show(); } else {