mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-18 21:28:54 +00:00
Fixed warnings
This commit is contained in:
parent
b490e49ee7
commit
d44d0d6230
1 changed files with 11 additions and 5 deletions
|
@ -141,6 +141,9 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
if (cm == null)
|
||||||
|
return;
|
||||||
|
|
||||||
NetworkRequest.Builder builder = new NetworkRequest.Builder();
|
NetworkRequest.Builder builder = new NetworkRequest.Builder();
|
||||||
builder.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);
|
builder.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);
|
||||||
cm.registerNetworkCallback(builder.build(), networkCallback);
|
cm.registerNetworkCallback(builder.build(), networkCallback);
|
||||||
|
@ -149,19 +152,22 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
if (cm == null)
|
||||||
|
return;
|
||||||
|
|
||||||
cm.unregisterNetworkCallback(networkCallback);
|
cm.unregisterNetworkCallback(networkCallback);
|
||||||
|
|
||||||
super.onPause();
|
super.onPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||||
inflater.inflate(R.menu.menu_options, menu);
|
inflater.inflate(R.menu.menu_options, menu);
|
||||||
super.onCreateOptionsMenu(menu, inflater);
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.menu_default:
|
case R.id.menu_default:
|
||||||
onMenuDefault();
|
onMenuDefault();
|
||||||
|
@ -198,17 +204,17 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
|
||||||
|
|
||||||
private ConnectivityManager.NetworkCallback networkCallback = new ConnectivityManager.NetworkCallback() {
|
private ConnectivityManager.NetworkCallback networkCallback = new ConnectivityManager.NetworkCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onAvailable(Network network) {
|
public void onAvailable(@NonNull Network network) {
|
||||||
showConnectionType();
|
showConnectionType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCapabilitiesChanged(Network network, NetworkCapabilities networkCapabilities) {
|
public void onCapabilitiesChanged(@NonNull Network network, @NonNull NetworkCapabilities networkCapabilities) {
|
||||||
showConnectionType();
|
showConnectionType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLost(Network network) {
|
public void onLost(@NonNull Network network) {
|
||||||
showConnectionType();
|
showConnectionType();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue