Prevent crash

This commit is contained in:
M66B 2022-07-14 15:16:55 +02:00
parent f36c141922
commit 27610fbd73
9 changed files with 27 additions and 36 deletions

View File

@ -58,6 +58,7 @@ import java.util.ArrayList;
import java.util.List;
public class FragmentOptionsBehavior extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
private View view;
private ImageButton ibHelp;
private SwitchCompat swRestoreOnLaunch;
private TextView tvRestoreOnLaunchHint;
@ -120,7 +121,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
setSubtitle(R.string.title_setup);
setHasOptionsMenu(true);
View view = inflater.inflate(R.layout.fragment_options_behavior, container, false);
view = inflater.inflate(R.layout.fragment_options_behavior, container, false);
// Get controls
@ -531,9 +532,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
}
private void setOptions() {
if (getContext() == null)
return;
if (getLifecycle().getCurrentState().equals(Lifecycle.State.DESTROYED))
if (view == null || getContext() == null)
return;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());

View File

@ -59,6 +59,7 @@ import androidx.lifecycle.Lifecycle;
import androidx.preference.PreferenceManager;
public class FragmentOptionsConnection extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
private View view;
private ImageButton ibHelp;
private SwitchCompat swMetered;
private Spinner spDownload;
@ -101,7 +102,7 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
setSubtitle(R.string.title_setup);
setHasOptionsMenu(true);
View view = inflater.inflate(R.layout.fragment_options_connection, container, false);
view = inflater.inflate(R.layout.fragment_options_connection, container, false);
// Get controls
@ -403,9 +404,7 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
}
private void setOptions() {
if (getContext() == null)
return;
if (getLifecycle().getCurrentState().equals(Lifecycle.State.DESTROYED))
if (view == null || getContext() == null)
return;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());

View File

@ -64,6 +64,7 @@ import java.util.ArrayList;
import java.util.List;
public class FragmentOptionsDisplay extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
private View view;
private ImageButton ibHelp;
private Button btnTheme;
private Spinner spStartup;
@ -220,7 +221,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
setSubtitle(R.string.title_setup);
setHasOptionsMenu(true);
View view = inflater.inflate(R.layout.fragment_options_display, container, false);
view = inflater.inflate(R.layout.fragment_options_display, container, false);
// Get controls
@ -1331,9 +1332,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
}
private void setOptions() {
if (getContext() == null)
return;
if (getLifecycle().getCurrentState().equals(Lifecycle.State.DESTROYED))
if (view == null || getContext() == null)
return;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());

View File

@ -81,6 +81,7 @@ import java.util.List;
public class FragmentOptionsEncryption extends FragmentBase
implements SharedPreferences.OnSharedPreferenceChangeListener, OpenPgpServiceConnection.OnBound {
private View view;
private ImageButton ibHelp;
private ImageButton ibInfo;
private SwitchCompat swSign;
@ -126,7 +127,7 @@ public class FragmentOptionsEncryption extends FragmentBase
setHasOptionsMenu(true);
PackageManager pm = getContext().getPackageManager();
View view = inflater.inflate(R.layout.fragment_options_encryption, container, false);
view = inflater.inflate(R.layout.fragment_options_encryption, container, false);
// Get controls
@ -597,9 +598,7 @@ public class FragmentOptionsEncryption extends FragmentBase
}
private void setOptions() {
if (getContext() == null)
return;
if (getLifecycle().getCurrentState().equals(Lifecycle.State.DESTROYED))
if (view == null || getContext() == null)
return;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());

View File

@ -96,6 +96,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private boolean resumed = false;
private List<Pair<String, String>> languages = new ArrayList<>();
private View view;
private ImageButton ibHelp;
private SwitchCompat swPowerMenu;
private SwitchCompat swExternalSearch;
@ -277,7 +278,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
setSubtitle(R.string.title_setup);
setHasOptionsMenu(true);
View view = inflater.inflate(R.layout.fragment_options_misc, container, false);
view = inflater.inflate(R.layout.fragment_options_misc, container, false);
// Get controls
@ -1731,9 +1732,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
}
private void setOptions() {
if (getContext() == null)
return;
if (getLifecycle().getCurrentState().equals(Lifecycle.State.DESTROYED))
if (view == null || getContext() == null)
return;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());

View File

@ -64,6 +64,7 @@ import java.util.concurrent.ExecutorService;
import java.util.function.Consumer;
public class FragmentOptionsNotifications extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
private View view;
private ImageButton ibHelp;
private Button btnManage;
private ImageButton ibClear;
@ -149,7 +150,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
setSubtitle(R.string.title_setup);
setHasOptionsMenu(true);
View view = inflater.inflate(R.layout.fragment_options_notifications, container, false);
view = inflater.inflate(R.layout.fragment_options_notifications, container, false);
// Get controls
@ -706,9 +707,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
}
private void setOptions() {
if (getContext() == null)
return;
if (getLifecycle().getCurrentState().equals(Lifecycle.State.DESTROYED))
if (view == null || getContext() == null)
return;
boolean pro = ActivityBilling.isPro(getContext());

View File

@ -63,6 +63,7 @@ import java.text.SimpleDateFormat;
import java.util.Locale;
public class FragmentOptionsPrivacy extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
private View view;
private ImageButton ibHelp;
private SwitchCompat swConfirmLinks;
private SwitchCompat swCheckLinksDbl;
@ -123,7 +124,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
setSubtitle(R.string.title_setup);
setHasOptionsMenu(true);
View view = inflater.inflate(R.layout.fragment_options_privacy, container, false);
view = inflater.inflate(R.layout.fragment_options_privacy, container, false);
// Get controls
@ -529,9 +530,7 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
}
private void setOptions() {
if (getContext() == null)
return;
if (getLifecycle().getCurrentState().equals(Lifecycle.State.DESTROYED))
if (view == null || getContext() == null)
return;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());

View File

@ -55,6 +55,7 @@ import java.util.List;
import java.util.Objects;
public class FragmentOptionsSend extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
private View view;
private ImageButton ibHelp;
private SwitchCompat swKeyboard;
private SwitchCompat swKeyboardNoFullscreen;
@ -129,7 +130,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
setSubtitle(R.string.title_setup);
setHasOptionsMenu(true);
View view = inflater.inflate(R.layout.fragment_options_send, container, false);
view = inflater.inflate(R.layout.fragment_options_send, container, false);
// Get controls
@ -631,9 +632,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
}
private void setOptions() {
if (getContext() == null)
return;
if (getLifecycle().getCurrentState().equals(Lifecycle.State.DESTROYED))
if (view == null || getContext() == null)
return;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());

View File

@ -64,6 +64,7 @@ import java.util.List;
import java.util.Objects;
public class FragmentOptionsSynchronize extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
private View view;
private ImageButton ibHelp;
private SwitchCompat swEnabled;
private SwitchCompat swOptimize;
@ -130,7 +131,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
setSubtitle(R.string.title_setup);
setHasOptionsMenu(true);
View view = inflater.inflate(R.layout.fragment_options_synchronize, container, false);
view = inflater.inflate(R.layout.fragment_options_synchronize, container, false);
// Get controls
@ -556,9 +557,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
}
private void setOptions() {
if (getContext() == null)
return;
if (getLifecycle().getCurrentState().equals(Lifecycle.State.DESTROYED))
if (view == null || getContext() == null)
return;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());