summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2013-03-14 10:42:44 +0100
committerdaniel oeh <daniel.oeh@gmail.com>2013-03-14 10:42:44 +0100
commitedaca292dc88ff18f109a1b8f94d718c582a4489 (patch)
tree5096477314b6a077465c33f22d4718134463d2a4 /src
parentec1992f36c5bf1916ebaed8196705b2324486388 (diff)
parent93a65ba49e92c202b70ee165aea723bacffb178f (diff)
downloadAntennaPod-edaca292dc88ff18f109a1b8f94d718c582a4489.zip
Merge branch 'update_alarm' of git://github.com/toggles/AntennaPod into
toggles-update_alarm Conflicts: src/de/danoeh/antennapod/PodcastApp.java
Diffstat (limited to 'src')
-rw-r--r--src/de/danoeh/antennapod/PodcastApp.java40
1 files changed, 25 insertions, 15 deletions
diff --git a/src/de/danoeh/antennapod/PodcastApp.java b/src/de/danoeh/antennapod/PodcastApp.java
index 0e3fab80d..365d5736e 100644
--- a/src/de/danoeh/antennapod/PodcastApp.java
+++ b/src/de/danoeh/antennapod/PodcastApp.java
@@ -65,6 +65,10 @@ public class PodcastApp extends Application implements
currentlyPlayingMediaId = prefs.getLong(
PlaybackService.PREF_CURRENTLY_PLAYING_MEDIA,
PlaybackService.NO_MEDIA_PLAYING);
+ // start the update alarm
+ int hours = Integer.parseInt(prefs.getString(
+ PREF_UPDATE_INTERVALL, "0"));
+ restartUpdateAlarm(hours);
readThemeValue();
createImportDirectory();
createNoMediaFile();
@@ -126,22 +130,9 @@ public class PodcastApp extends Application implements
if (AppConfig.DEBUG)
Log.d(TAG, "Registered change of application preferences");
if (key.equals(PREF_UPDATE_INTERVALL)) {
- AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
int hours = Integer.parseInt(sharedPreferences.getString(
- PREF_UPDATE_INTERVALL, "0"));
- PendingIntent updateIntent = PendingIntent.getBroadcast(this, 0,
- new Intent(FeedUpdateReceiver.ACTION_REFRESH_FEEDS), 0);
- alarmManager.cancel(updateIntent);
- if (hours != 0) {
- long newIntervall = TimeUnit.HOURS.toMillis(hours);
- alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,
- newIntervall, newIntervall, updateIntent);
- if (AppConfig.DEBUG)
- Log.d(TAG, "Changed alarm to new intervall");
- } else {
- if (AppConfig.DEBUG)
- Log.d(TAG, "Automatic update was deactivated");
- }
+ PREF_UPDATE_INTERVALL, "0"));
+ restartUpdateAlarm(hours);
} else if (key.equals(PREF_DISPLAY_ONLY_EPISODES)) {
if (AppConfig.DEBUG)
Log.d(TAG, "PREF_DISPLAY_ONLY_EPISODES changed");
@@ -210,6 +201,7 @@ public class PodcastApp extends Application implements
}
}
+
/**
* Return the folder where the app stores all of its data. This method will
* return the standard data folder if none has been set by the user.
@@ -279,4 +271,22 @@ public class PodcastApp extends Application implements
editor.commit();
createImportDirectory();
}
+
+ private void restartUpdateAlarm(int hours) {
+ AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
+ PendingIntent updateIntent = PendingIntent.getBroadcast(this, 0,
+ new Intent(FeedUpdateReceiver.ACTION_REFRESH_FEEDS), 0);
+ alarmManager.cancel(updateIntent);
+ if (hours != 0) {
+ long newIntervall = TimeUnit.HOURS.toMillis(hours);
+ alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,
+ newIntervall, newIntervall, updateIntent);
+ if (AppConfig.DEBUG)
+ Log.d(TAG, "Changed alarm to new intervall");
+ } else {
+ if (AppConfig.DEBUG)
+ Log.d(TAG, "Automatic update was deactivated");
+ }
+ }
+
}