Prevent crash

pull/147/head
M66B 6 years ago
parent 1562a33836
commit 6f7a310438

@ -48,6 +48,7 @@ import androidx.annotation.Nullable;
import androidx.appcompat.widget.SwitchCompat; import androidx.appcompat.widget.SwitchCompat;
import androidx.constraintlayout.widget.Group; import androidx.constraintlayout.widget.Group;
import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.Lifecycle;
import static android.app.Activity.RESULT_OK; import static android.app.Activity.RESULT_OK;
@ -454,12 +455,14 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
activity.runOnUiThread(new Runnable() { activity.runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) {
Boolean metered = Helper.isMetered(getContext(), false); Boolean metered = Helper.isMetered(getContext(), false);
tvConnectionType.setVisibility(metered == null ? View.GONE : View.VISIBLE); tvConnectionType.setVisibility(metered == null ? View.GONE : View.VISIBLE);
if (metered != null) if (metered != null)
tvConnectionType.setText(metered ? R.string.title_legend_metered : R.string.title_legend_unmetered); tvConnectionType.setText(metered ? R.string.title_legend_metered : R.string.title_legend_unmetered);
} }
}
}); });
} }

Loading…
Cancel
Save