Created
October 4, 2013 21:10
-
-
Save jakemoore/6832828 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NetworkState { | |
private static NetworkState sInstance = null; | |
private boolean mConnected = false; | |
private NetworkStateListener mListener; | |
private NetworkState() { | |
} | |
public static NetworkState getInstance() { | |
if (sInstance == null) { | |
sInstance = new NetworkState(); | |
} | |
return sInstance; | |
} | |
public void setConnected(boolean connected) { | |
mConnected = connected; | |
if (mListener != null) { | |
mListener.onNetworkStateChanged(connected); | |
} | |
} | |
public boolean isConnected() { | |
return mConnected; | |
} | |
public void setListener(NetworkStateListener listener) { | |
mListener = listener; | |
} | |
public interface NetworkStateListener { | |
public void onNetworkStateChanged(boolean connected); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment