diff options
author | Martin Fietz <marf@hadiko-99-4.hadiko.uni-karlsruhe.de> | 2015-05-03 18:57:19 +0200 |
---|---|---|
committer | Martin Fietz <marf@hadiko-99-4.hadiko.uni-karlsruhe.de> | 2015-05-03 18:57:19 +0200 |
commit | f8bb78d43630eb7762074279c5b1db032071e072 (patch) | |
tree | e4b1ba5b619fb52aca06210a061f365e0d60e633 /core | |
parent | 1bd6bf76f6d9ce2709364d4cf396d5f3cc0f32d1 (diff) | |
download | AntennaPod-f8bb78d43630eb7762074279c5b1db032071e072.zip |
Refactoring
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/receiver/FeedUpdateReceiver.java | 23 | ||||
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/util/NetworkUtils.java | 15 |
2 files changed, 18 insertions, 20 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/receiver/FeedUpdateReceiver.java b/core/src/main/java/de/danoeh/antennapod/core/receiver/FeedUpdateReceiver.java index 95dc4fb07..d1ff5d232 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/receiver/FeedUpdateReceiver.java +++ b/core/src/main/java/de/danoeh/antennapod/core/receiver/FeedUpdateReceiver.java @@ -3,41 +3,28 @@ package de.danoeh.antennapod.core.receiver; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; -import android.net.ConnectivityManager; -import android.net.NetworkInfo; import android.util.Log; -import de.danoeh.antennapod.core.BuildConfig; import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.storage.DBTasks; +import de.danoeh.antennapod.core.util.NetworkUtils; /** * Refreshes all feeds when it receives an intent */ public class FeedUpdateReceiver extends BroadcastReceiver { + private static final String TAG = "FeedUpdateReceiver"; @Override public void onReceive(Context context, Intent intent) { - if (BuildConfig.DEBUG) - Log.d(TAG, "Received intent"); + Log.d(TAG, "Received intent"); boolean mobileUpdate = UserPreferences.isAllowMobileUpdate(); - if (mobileUpdate || connectedToWifi(context)) { + if (mobileUpdate || NetworkUtils.connectedToWifi(context)) { DBTasks.refreshExpiredFeeds(context); } else { - if (BuildConfig.DEBUG) - Log.d(TAG, - "Blocking automatic update: no wifi available / no mobile updates allowed"); + Log.d(TAG, "Blocking automatic update: no wifi available / no mobile updates allowed"); } } - private boolean connectedToWifi(Context context) { - ConnectivityManager connManager = (ConnectivityManager) context - .getSystemService(Context.CONNECTIVITY_SERVICE); - NetworkInfo mWifi = connManager - .getNetworkInfo(ConnectivityManager.TYPE_WIFI); - - return mWifi.isConnected(); - } - } diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/NetworkUtils.java b/core/src/main/java/de/danoeh/antennapod/core/util/NetworkUtils.java index b321536a3..58011827c 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/NetworkUtils.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/NetworkUtils.java @@ -6,12 +6,13 @@ import android.net.NetworkInfo; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.util.Log; -import de.danoeh.antennapod.core.BuildConfig; -import de.danoeh.antennapod.core.preferences.UserPreferences; import java.util.Arrays; import java.util.List; +import de.danoeh.antennapod.core.BuildConfig; +import de.danoeh.antennapod.core.preferences.UserPreferences; + public class NetworkUtils { private static final String TAG = "NetworkUtils"; @@ -66,4 +67,14 @@ public class NetworkUtils { NetworkInfo info = cm.getActiveNetworkInfo(); return info != null && info.isConnected(); } + + public static boolean connectedToWifi(Context context) { + ConnectivityManager connManager = (ConnectivityManager) context + .getSystemService(Context.CONNECTIVITY_SERVICE); + NetworkInfo mWifi = connManager + .getNetworkInfo(ConnectivityManager.TYPE_WIFI); + + return mWifi.isConnected(); + } + } |