Refactoring

This commit is contained in:
M66B
2019-12-07 22:06:40 +01:00
parent 30ec86f9da
commit 037af96be0
2 changed files with 49 additions and 51 deletions

View File

@@ -75,6 +75,9 @@ public class ConnectionHelper {
private Boolean suitable = null;
private Boolean unmetered = null;
private Boolean roaming = null;
private actionType action = actionType.NONE;
public enum actionType {NONE, AVAILABLE, CHANGED, LOST}
boolean isConnected() {
return (connected != null && connected);
@@ -163,6 +166,12 @@ public class ConnectionHelper {
return state;
}
static NetworkState getNetworkState(Context context, NetworkState.actionType action) {
NetworkState state = getNetworkState(context);
state.action = action;
return state;
}
private static Boolean isMetered(Context context) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (cm == null)