diff options
| author | donEgro <egermajer.martin@gmail.com> | 2013-04-20 22:13:29 +0200 |
|---|---|---|
| committer | donEgro <egermajer.martin@gmail.com> | 2013-04-20 22:13:29 +0200 |
| commit | 705dc21ac799f786e6c7b76f9588ff22aa25a05f (patch) | |
| tree | 0a700d730aad5fbf5f68d5edd233bbe07980b624 | |
| parent | 8c3917655f80ee66ca226adfeba5460a92afecf5 (diff) | |
| download | cgeo-705dc21ac799f786e6c7b76f9588ff22aa25a05f.zip cgeo-705dc21ac799f786e6c7b76f9588ff22aa25a05f.tar.gz cgeo-705dc21ac799f786e6c7b76f9588ff22aa25a05f.tar.bz2 | |
Fixed Issue #708 - Refresh caches + no internet = normal progress.
| -rw-r--r-- | main/src/cgeo/geocaching/cgeocaches.java | 5 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/network/Network.java | 18 |
2 files changed, 23 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/cgeocaches.java b/main/src/cgeo/geocaching/cgeocaches.java index 61a32f1..8fc61d4 100644 --- a/main/src/cgeo/geocaching/cgeocaches.java +++ b/main/src/cgeo/geocaching/cgeocaches.java @@ -1082,6 +1082,11 @@ public class cgeocaches extends AbstractListActivity implements FilteredActivity return; } + if (!Network.isNetworkConnected(getApplicationContext())) { + showToast(getString(R.string.err_server)); + return; + } + if (Settings.getChooseList() && type != CacheListType.OFFLINE) { // let user select list to store cache in new StoredList.UserInterface(this).promptForListSelection(R.string.list_title, diff --git a/main/src/cgeo/geocaching/network/Network.java b/main/src/cgeo/geocaching/network/Network.java index eb6a6ac..5a8cbb2 100644 --- a/main/src/cgeo/geocaching/network/Network.java +++ b/main/src/cgeo/geocaching/network/Network.java @@ -40,6 +40,9 @@ import org.apache.commons.lang3.StringUtils; import org.json.JSONException; import org.json.JSONObject; +import android.content.Context; +import android.net.ConnectivityManager; +import android.net.NetworkInfo; import android.net.Uri; import java.io.File; @@ -471,4 +474,19 @@ public abstract class Network { return null; } + /** + * Checks if the device has network connection. + * + * @param context + * context of the application, cannot be null + * + * @return <code>true</code> if the device is connected to the network. + */ + public static boolean isNetworkConnected(Context context) { + ConnectivityManager conMan = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); + NetworkInfo activeNetwork = conMan.getActiveNetworkInfo(); + + return activeNetwork != null && activeNetwork.isConnected(); + } + } |
