mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-03 05:34:51 +00:00
Prevent crash
This commit is contained in:
parent
7b9449dc82
commit
bc37955153
1 changed files with 11 additions and 3 deletions
|
@ -335,14 +335,22 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
|
||||||
};
|
};
|
||||||
|
|
||||||
private void showConnectionType() {
|
private void showConnectionType() {
|
||||||
final ConnectionHelper.NetworkState networkState = ConnectionHelper.getNetworkState(getContext());
|
final Context context = getContext();
|
||||||
|
if (context == null) {
|
||||||
|
tvNetworkMetered.setVisibility(View.GONE);
|
||||||
|
tvNetworkRoaming.setVisibility(View.GONE);
|
||||||
|
tvNetworkInfo.setVisibility(View.GONE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final ConnectionHelper.NetworkState networkState = ConnectionHelper.getNetworkState(context);
|
||||||
|
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
boolean debug = prefs.getBoolean("debug", false);
|
boolean debug = prefs.getBoolean("debug", false);
|
||||||
if ((debug || BuildConfig.DEBUG) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
|
if ((debug || BuildConfig.DEBUG) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
|
||||||
try {
|
try {
|
||||||
ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
Network active = (cm == null ? null : cm.getActiveNetwork());
|
Network active = (cm == null ? null : cm.getActiveNetwork());
|
||||||
if (active != null) {
|
if (active != null) {
|
||||||
NetworkInfo ni = cm.getNetworkInfo(active);
|
NetworkInfo ni = cm.getNetworkInfo(active);
|
||||||
|
|
Loading…
Reference in a new issue