Simplification

This commit is contained in:
M66B
2020-01-02 20:05:10 +01:00
parent 8036319e6f
commit a22fcc9064
3 changed files with 10 additions and 33 deletions

View File

@@ -277,21 +277,12 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
};
private void showConnectionType() {
FragmentActivity activity = getActivity();
if (activity == null)
return;
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
ConnectionHelper.NetworkState networkState = ConnectionHelper.getNetworkState(getContext());
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
ConnectionHelper.NetworkState networkState = ConnectionHelper.getNetworkState(getContext());
tvConnectionType.setText(networkState.isUnmetered() ? R.string.title_legend_unmetered : R.string.title_legend_metered);
tvConnectionType.setVisibility(networkState.isConnected() ? View.VISIBLE : View.GONE);
tvConnectionRoaming.setVisibility(networkState.isRoaming() ? View.VISIBLE : View.GONE);
}
}
});
tvConnectionType.setText(networkState.isUnmetered() ? R.string.title_legend_unmetered : R.string.title_legend_metered);
tvConnectionType.setVisibility(networkState.isConnected() ? View.VISIBLE : View.GONE);
tvConnectionRoaming.setVisibility(networkState.isRoaming() ? View.VISIBLE : View.GONE);
}
}
}