summaryrefslogtreecommitdiffhomepage
path: root/app/src/main/java/com
diff options
context:
space:
mode:
authorSamuel Holland <samuel@sholland.org>2017-08-14 10:44:29 -0500
committerSamuel Holland <samuel@sholland.org>2017-08-14 10:44:29 -0500
commitbd8498cbbd5dcf52027d163e388853a325d54168 (patch)
tree7fed81ef316a54b94ec1e895eedabdba2675ce13 /app/src/main/java/com
parent20d314e800891df6d44ce5012739ba4d9c2a5e00 (diff)
ConfigActivity: Avoid crash when started while locked
Diffstat (limited to 'app/src/main/java/com')
-rw-r--r--app/src/main/java/com/wireguard/android/ConfigActivity.java15
1 files changed, 12 insertions, 3 deletions
diff --git a/app/src/main/java/com/wireguard/android/ConfigActivity.java b/app/src/main/java/com/wireguard/android/ConfigActivity.java
index f672c594..fe957374 100644
--- a/app/src/main/java/com/wireguard/android/ConfigActivity.java
+++ b/app/src/main/java/com/wireguard/android/ConfigActivity.java
@@ -15,11 +15,12 @@ import com.wireguard.config.Config;
*/
public class ConfigActivity extends BaseConfigActivity {
- private boolean canAddFragments;
private int containerId;
private final FragmentManager fm = getFragmentManager();
private boolean isEditing;
+ private boolean isServiceAvailable;
private boolean isSplitLayout;
+ private boolean isStateSaved;
@Override
public void onBackPressed() {
@@ -44,7 +45,7 @@ public class ConfigActivity extends BaseConfigActivity {
@Override
protected void onCurrentConfigChanged(final Config config) {
- if (!canAddFragments)
+ if (!isServiceAvailable || isStateSaved)
return;
final Fragment currentFragment = fm.findFragmentById(containerId);
Log.d(getClass().getSimpleName(), "onCurrentConfigChanged config=" +
@@ -135,6 +136,13 @@ public class ConfigActivity extends BaseConfigActivity {
}
@Override
+ public void onPostResume() {
+ super.onPostResume();
+ isStateSaved = false;
+ onCurrentConfigChanged(getCurrentConfig());
+ }
+
+ @Override
public void onSaveInstanceState(final Bundle outState) {
// We cannot save fragments that might switch between containers if the layout changes.
if (fm.getBackStackEntryCount() > 0) {
@@ -146,13 +154,14 @@ public class ConfigActivity extends BaseConfigActivity {
if (oldFragment != null)
fm.beginTransaction().remove(oldFragment).commit();
}
+ isStateSaved = true;
super.onSaveInstanceState(outState);
}
@Override
protected void onServiceAvailable() {
// Create the initial fragment set.
- canAddFragments = true;
+ isServiceAvailable = true;
onCurrentConfigChanged(getCurrentConfig());
}
}