use of de.danoeh.antennapod.model.feed.FeedPreferences in project AntennaPod by AntennaPod.
the class FeedMultiSelectActionHandler method autoDeleteEpisodesPrefHandler.
private void autoDeleteEpisodesPrefHandler() {
PreferenceListDialog preferenceListDialog = new PreferenceListDialog(activity, "Auto delete episodes");
String[] items = activity.getResources().getStringArray(R.array.spnAutoDeleteItems);
String[] values = activity.getResources().getStringArray(R.array.spnAutoDeleteValues);
preferenceListDialog.openDialog(items);
preferenceListDialog.setOnPreferenceChangedListener(which -> {
FeedPreferences.AutoDeleteAction autoDeleteAction = null;
switch(values[which]) {
case "global":
autoDeleteAction = FeedPreferences.AutoDeleteAction.GLOBAL;
break;
case "always":
autoDeleteAction = FeedPreferences.AutoDeleteAction.YES;
break;
case "never":
autoDeleteAction = FeedPreferences.AutoDeleteAction.NO;
break;
default:
}
FeedPreferences.AutoDeleteAction finalAutoDeleteAction = autoDeleteAction;
saveFeedPreferences(feedPreferences -> {
feedPreferences.setAutoDeleteAction(finalAutoDeleteAction);
});
});
}
use of de.danoeh.antennapod.model.feed.FeedPreferences in project AntennaPod by AntennaPod.
the class NewEpisodesNotification method showIfNeeded.
public void showIfNeeded(Context context, Feed feed) {
FeedPreferences prefs = feed.getPreferences();
if (!prefs.getKeepUpdated() || !prefs.getShowEpisodeNotification()) {
return;
}
int newEpisodesBefore = countersBefore.get(feed.getId());
int newEpisodesAfter = getNewEpisodeCount(feed.getId());
Log.d(TAG, "New episodes before: " + newEpisodesBefore + ", after: " + newEpisodesAfter);
if (newEpisodesAfter > newEpisodesBefore) {
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
showNotification(newEpisodesAfter, feed, context, notificationManager);
}
}
use of de.danoeh.antennapod.model.feed.FeedPreferences in project AntennaPod by AntennaPod.
the class LocalPSMP method setVolumeSync.
/**
* Sets the playback volume.
* This method is executed on the caller's thread.
*/
private void setVolumeSync(float volumeLeft, float volumeRight) {
playerLock.lock();
Playable playable = getPlayable();
if (playable instanceof FeedMedia) {
FeedMedia feedMedia = (FeedMedia) playable;
FeedPreferences preferences = feedMedia.getItem().getFeed().getPreferences();
VolumeAdaptionSetting volumeAdaptionSetting = preferences.getVolumeAdaptionSetting();
float adaptionFactor = volumeAdaptionSetting.getAdaptionFactor();
volumeLeft *= adaptionFactor;
volumeRight *= adaptionFactor;
}
mediaPlayer.setVolume(volumeLeft, volumeRight);
Log.d(TAG, "Media player volume was set to " + volumeLeft + " " + volumeRight);
playerLock.unlock();
}
use of de.danoeh.antennapod.model.feed.FeedPreferences in project AntennaPod by AntennaPod.
the class FeedParserTask method call.
@Override
public FeedHandlerResult call() {
Feed feed = new Feed(request.getSource(), request.getLastModified());
feed.setFile_url(request.getDestination());
feed.setId(request.getFeedfileId());
feed.setDownloaded(true);
feed.setPreferences(new FeedPreferences(0, true, FeedPreferences.AutoDeleteAction.GLOBAL, VolumeAdaptionSetting.OFF, request.getUsername(), request.getPassword()));
feed.setPageNr(request.getArguments().getInt(DownloadRequest.REQUEST_ARG_PAGE_NR, 0));
DownloadError reason = null;
String reasonDetailed = null;
FeedHandler feedHandler = new FeedHandler();
FeedHandlerResult result = null;
try {
result = feedHandler.parseFeed(feed);
Log.d(TAG, feed.getTitle() + " parsed");
checkFeedData(feed);
} catch (SAXException | IOException | ParserConfigurationException e) {
successful = false;
e.printStackTrace();
reason = DownloadError.ERROR_PARSER_EXCEPTION;
reasonDetailed = e.getMessage();
} catch (UnsupportedFeedtypeException e) {
e.printStackTrace();
successful = false;
reason = DownloadError.ERROR_UNSUPPORTED_TYPE;
if ("html".equalsIgnoreCase(e.getRootElement())) {
reason = DownloadError.ERROR_UNSUPPORTED_TYPE_HTML;
}
reasonDetailed = e.getMessage();
} catch (InvalidFeedException e) {
e.printStackTrace();
successful = false;
reason = DownloadError.ERROR_PARSER_EXCEPTION;
reasonDetailed = e.getMessage();
} finally {
File feedFile = new File(request.getDestination());
if (feedFile.exists()) {
boolean deleted = feedFile.delete();
Log.d(TAG, "Deletion of file '" + feedFile.getAbsolutePath() + "' " + (deleted ? "successful" : "FAILED"));
}
}
if (successful) {
downloadStatus = new DownloadStatus(feed, feed.getHumanReadableIdentifier(), DownloadError.SUCCESS, successful, reasonDetailed, request.isInitiatedByUser());
return result;
} else {
downloadStatus = new DownloadStatus(feed, feed.getTitle(), reason, successful, reasonDetailed, request.isInitiatedByUser());
return null;
}
}
use of de.danoeh.antennapod.model.feed.FeedPreferences in project AntennaPod by AntennaPod.
the class PlaybackService method skipIntroEndingPresetChanged.
@Subscribe(threadMode = ThreadMode.MAIN)
@SuppressWarnings("unused")
public void skipIntroEndingPresetChanged(SkipIntroEndingChangedEvent event) {
if (getPlayable() instanceof FeedMedia) {
if (((FeedMedia) getPlayable()).getItem().getFeed().getId() == event.getFeedId()) {
if (event.getSkipEnding() != 0) {
FeedPreferences feedPreferences = ((FeedMedia) getPlayable()).getItem().getFeed().getPreferences();
feedPreferences.setFeedSkipIntro(event.getSkipIntro());
feedPreferences.setFeedSkipEnding(event.getSkipEnding());
}
}
}
}
Aggregations