diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2013-03-25 11:32:52 +0100 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2013-03-25 11:32:52 +0100 |
commit | 862ee405391409372dc07addd0377ac5fbbf37f2 (patch) | |
tree | e88207778769dce7601388a479cf4e370277cc49 /src/de | |
parent | f6794d170c820dffbc653c269bb031abc020ab45 (diff) | |
download | AntennaPod-862ee405391409372dc07addd0377ac5fbbf37f2.zip |
Formatted code
Diffstat (limited to 'src/de')
-rw-r--r-- | src/de/danoeh/antennapod/feed/FeedManager.java | 60 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/receiver/FeedUpdateReceiver.java | 14 |
2 files changed, 36 insertions, 38 deletions
diff --git a/src/de/danoeh/antennapod/feed/FeedManager.java b/src/de/danoeh/antennapod/feed/FeedManager.java index 8e2a157bd..c7f317b62 100644 --- a/src/de/danoeh/antennapod/feed/FeedManager.java +++ b/src/de/danoeh/antennapod/feed/FeedManager.java @@ -10,7 +10,6 @@ import java.util.List; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; -import java.util.concurrent.TimeUnit; import android.annotation.SuppressLint; import android.content.Context; @@ -456,51 +455,46 @@ public class FeedManager { public void refreshAllFeeds(final Context context) { if (AppConfig.DEBUG) Log.d(TAG, "Refreshing all feeds."); - refreshFeeds(context,feeds); + refreshFeeds(context, feeds); } - + /** Updates all feeds in the feed list. */ public void refreshExpiredFeeds(final Context context) { - long millis=UserPreferences.getUpdateInterval(); - + long millis = UserPreferences.getUpdateInterval(); + if (AppConfig.DEBUG) - Log.d(TAG, "Refreshing expired feeds, "+millis+" ms"); - - if(millis>0) { - List<Feed> feedList=new ArrayList<Feed>(); - long now=Calendar.getInstance().getTime().getTime(); - - // Allow a 10 minute window.. - millis-=10*60*1000; - for(Feed feed:feeds) { - Date date=feed.getLastUpdate(); - if(date!=null) { - if(date.getTime()+millis<=now) { - if(AppConfig.DEBUG) { - Log.d(TAG, - "Adding expired feed "+feed.getTitle()); + Log.d(TAG, "Refreshing expired feeds, " + millis + " ms"); + + if (millis > 0) { + List<Feed> feedList = new ArrayList<Feed>(); + long now = Calendar.getInstance().getTime().getTime(); + + // Allow a 10 minute window + millis -= 10 * 60 * 1000; + for (Feed feed : feeds) { + Date date = feed.getLastUpdate(); + if (date != null) { + if (date.getTime() + millis <= now) { + if (AppConfig.DEBUG) { + Log.d(TAG, "Adding expired feed " + feed.getTitle()); } feedList.add(feed); - } - else { - if(AppConfig.DEBUG) { - Log.d(TAG, - "Skipping feed "+feed.getTitle()); + } else { + if (AppConfig.DEBUG) { + Log.d(TAG, "Skipping feed " + feed.getTitle()); } } } } - if(feedList.size()>0) { - refreshFeeds(context,feedList); + if (feedList.size() > 0) { + refreshFeeds(context, feedList); } } } - + @SuppressLint("NewApi") - private void refreshFeeds(Context context,List<Feed> feeds) { + private void refreshFeeds(final Context context, final List<Feed> feedList) { if (!isStartingFeedRefresh) { - final Context ctx=context; - final List<Feed> feedList=feeds; isStartingFeedRefresh = true; AsyncTask<Void, Void, Void> updateWorker = new AsyncTask<Void, Void, Void>() { @@ -516,11 +510,11 @@ public class FeedManager { protected Void doInBackground(Void... params) { for (Feed feed : feedList) { try { - refreshFeed(ctx, feed); + refreshFeed(context, feed); } catch (DownloadRequestException e) { e.printStackTrace(); addDownloadStatus( - ctx, + context, new DownloadStatus(feed, feed .getHumanReadableIdentifier(), DownloadError.ERROR_REQUEST_ERROR, diff --git a/src/de/danoeh/antennapod/receiver/FeedUpdateReceiver.java b/src/de/danoeh/antennapod/receiver/FeedUpdateReceiver.java index b2cdda9b2..821ade4b0 100644 --- a/src/de/danoeh/antennapod/receiver/FeedUpdateReceiver.java +++ b/src/de/danoeh/antennapod/receiver/FeedUpdateReceiver.java @@ -18,20 +18,24 @@ public class FeedUpdateReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(ACTION_REFRESH_FEEDS)) { - if (AppConfig.DEBUG) Log.d(TAG, "Received intent"); + if (AppConfig.DEBUG) + Log.d(TAG, "Received intent"); boolean mobileUpdate = UserPreferences.isAllowMobileUpdate(); if (mobileUpdate || connectedToWifi(context)) { FeedManager.getInstance().refreshExpiredFeeds(context); } else { - if (AppConfig.DEBUG) Log.d(TAG, - "Blocking automatic update: no wifi available / no mobile updates allowed"); + if (AppConfig.DEBUG) + 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); + ConnectivityManager connManager = (ConnectivityManager) context + .getSystemService(Context.CONNECTIVITY_SERVICE); + NetworkInfo mWifi = connManager + .getNetworkInfo(ConnectivityManager.TYPE_WIFI); return mWifi.isConnected(); } |