Merge branch 'toggles-update_alarm' into develop
Conflicts: src/de/danoeh/antennapod/PodcastApp.java
This commit is contained in:
commit
fbb4772132
|
@ -52,5 +52,4 @@ public class PodcastApp extends Application {
|
|||
|| (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -198,22 +198,11 @@ public class UserPreferences implements
|
|||
followQueue = sp.getBoolean(PREF_FOLLOW_QUEUE, false);
|
||||
|
||||
} else if (key.equals(PREF_UPDATE_INTERVAL)) {
|
||||
AlarmManager alarmManager = (AlarmManager) context
|
||||
.getSystemService(Context.ALARM_SERVICE);
|
||||
updateInterval = readUpdateInterval(sp.getString(
|
||||
PREF_UPDATE_INTERVAL, "0"));
|
||||
PendingIntent updateIntent = PendingIntent.getBroadcast(context, 0,
|
||||
new Intent(FeedUpdateReceiver.ACTION_REFRESH_FEEDS), 0);
|
||||
alarmManager.cancel(updateIntent);
|
||||
if (updateInterval != 0) {
|
||||
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,
|
||||
updateInterval, updateInterval, updateIntent);
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Changed alarm to new intervall");
|
||||
} else {
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Automatic update was deactivated");
|
||||
}
|
||||
int hours = Integer.parseInt(sp
|
||||
.getString(PREF_UPDATE_INTERVAL, "0"));
|
||||
updateInterval = readUpdateInterval(sp
|
||||
.getString(PREF_UPDATE_INTERVAL, "0"));
|
||||
restartUpdateAlarm(hours);
|
||||
|
||||
} else if (key.equals(PREF_AUTO_DELETE)) {
|
||||
autoDelete = sp.getBoolean(PREF_AUTO_DELETE, false);
|
||||
|
@ -355,4 +344,29 @@ public class UserPreferences implements
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates alarm registered with the AlarmManager service or deactivates it.
|
||||
*
|
||||
* @param hours
|
||||
* new value to register with AlarmManager. If hours is 0, the
|
||||
* alarm is deactivated.
|
||||
* */
|
||||
public void restartUpdateAlarm(int hours) {
|
||||
AlarmManager alarmManager = (AlarmManager) context
|
||||
.getSystemService(Context.ALARM_SERVICE);
|
||||
PendingIntent updateIntent = PendingIntent.getBroadcast(context, 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");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue