diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2015-05-16 23:05:58 +0200 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2015-05-17 01:04:19 +0200 |
commit | b509c3ed399c07de02cbf777010cc4806db16cda (patch) | |
tree | 8aab45d50f2765dceb3a340665c40a9df926a52c /OpenKeychain/src | |
parent | 5c44f8400970de5943fd6c5e804dfa394f3deb01 (diff) | |
download | open-keychain-b509c3ed399c07de02cbf777010cc4806db16cda.tar.gz open-keychain-b509c3ed399c07de02cbf777010cc4806db16cda.tar.bz2 open-keychain-b509c3ed399c07de02cbf777010cc4806db16cda.zip |
fix fragment handling in ViewKeyActivity
Conflicts:
OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java
Diffstat (limited to 'OpenKeychain/src')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java | 40 |
1 files changed, 12 insertions, 28 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index 5466c0b9a..7d57538b6 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -274,9 +274,19 @@ public class ViewKeyActivity extends BaseNfcActivity implements result.createNotify(this).show(); } - startFragment(savedInstanceState, mDataUri); + // Fragments are stored, no need to recreate those + if (savedInstanceState != null) { + return; + } - if (savedInstanceState == null && getIntent().hasExtra(EXTRA_NFC_AID)) { + FragmentManager manager = getSupportFragmentManager(); + // Create an instance of the fragment + final ViewKeyFragment frag = ViewKeyFragment.newInstance(mDataUri); + manager.beginTransaction() + .replace(R.id.view_key_fragment, frag) + .commit(); + + if (getIntent().hasExtra(EXTRA_NFC_AID)) { Intent intent = getIntent(); byte[] nfcFingerprints = intent.getByteArrayExtra(EXTRA_NFC_FINGERPRINTS); String nfcUserId = intent.getStringExtra(EXTRA_NFC_USER_ID); @@ -291,26 +301,6 @@ public class ViewKeyActivity extends BaseNfcActivity implements setContentView(R.layout.view_key_activity); } - private void startFragment(Bundle savedInstanceState, Uri dataUri) { - // However, if we're being restored from a previous state, - // then we don't need to do anything and should return or else - // we could end up with overlapping fragments. - if (savedInstanceState != null) { - return; - } - - // Create an instance of the fragment - ViewKeyFragment frag = ViewKeyFragment.newInstance(dataUri); - - // Add the fragment to the 'fragment_container' FrameLayout - // NOTE: We use commitAllowingStateLoss() to prevent weird crashes! - getSupportFragmentManager().beginTransaction() - .replace(R.id.view_key_fragment, frag) - .commitAllowingStateLoss(); - // do it immediately! - getSupportFragmentManager().executePendingTransactions(); - } - @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); @@ -435,12 +425,6 @@ public class ViewKeyActivity extends BaseNfcActivity implements startActivityForResult(intent, 0); } - @Override - protected void onSaveInstanceState(Bundle outState) { - //Note:-Done due to the same weird crashes as for commitAllowingStateLoss() - //super.onSaveInstanceState(outState); - } - private void showQrCodeDialog() { Intent qrCodeIntent = new Intent(this, QrCodeViewActivity.class); |