use of de.danoeh.antennapod.model.feed.FeedPreferences in project AntennaPod by AntennaPod.
the class PlaybackServiceMediaPlayerTest method writeTestPlayable.
private Playable writeTestPlayable(String downloadUrl, String fileUrl) {
Feed f = new Feed(0, null, "f", "l", "d", null, null, null, null, "i", null, null, "l", false);
FeedPreferences prefs = new FeedPreferences(f.getId(), false, FeedPreferences.AutoDeleteAction.NO, VolumeAdaptionSetting.OFF, null, null);
f.setPreferences(prefs);
f.setItems(new ArrayList<>());
FeedItem i = new FeedItem(0, "t", "i", "l", new Date(), FeedItem.UNPLAYED, f);
f.getItems().add(i);
FeedMedia media = new FeedMedia(0, i, 0, 0, 0, "audio/wav", fileUrl, downloadUrl, fileUrl != null, null, 0, 0);
i.setMedia(media);
PodDBAdapter adapter = PodDBAdapter.getInstance();
adapter.open();
adapter.setCompleteFeed(f);
assertTrue(media.getId() != 0);
adapter.close();
return media;
}
use of de.danoeh.antennapod.model.feed.FeedPreferences in project AntennaPod by AntennaPod.
the class DBReader method extractFeedFromCursorRow.
private static Feed extractFeedFromCursorRow(Cursor cursor) {
Feed feed = FeedCursorMapper.convert(cursor);
FeedPreferences preferences = FeedPreferencesCursorMapper.convert(cursor);
feed.setPreferences(preferences);
return feed;
}
use of de.danoeh.antennapod.model.feed.FeedPreferences in project AntennaPod by AntennaPod.
the class FeedCursorMapper method convert.
/**
* Create a {@link Feed} instance from a database row (cursor).
*/
@NonNull
public static Feed convert(@NonNull Cursor cursor) {
int indexId = cursor.getColumnIndex(PodDBAdapter.KEY_ID);
int indexLastUpdate = cursor.getColumnIndex(PodDBAdapter.KEY_LASTUPDATE);
int indexTitle = cursor.getColumnIndex(PodDBAdapter.KEY_TITLE);
int indexCustomTitle = cursor.getColumnIndex(PodDBAdapter.KEY_CUSTOM_TITLE);
int indexLink = cursor.getColumnIndex(PodDBAdapter.KEY_LINK);
int indexDescription = cursor.getColumnIndex(PodDBAdapter.KEY_DESCRIPTION);
int indexPaymentLink = cursor.getColumnIndex(PodDBAdapter.KEY_PAYMENT_LINK);
int indexAuthor = cursor.getColumnIndex(PodDBAdapter.KEY_AUTHOR);
int indexLanguage = cursor.getColumnIndex(PodDBAdapter.KEY_LANGUAGE);
int indexType = cursor.getColumnIndex(PodDBAdapter.KEY_TYPE);
int indexFeedIdentifier = cursor.getColumnIndex(PodDBAdapter.KEY_FEED_IDENTIFIER);
int indexFileUrl = cursor.getColumnIndex(PodDBAdapter.KEY_FILE_URL);
int indexDownloadUrl = cursor.getColumnIndex(PodDBAdapter.KEY_DOWNLOAD_URL);
int indexDownloaded = cursor.getColumnIndex(PodDBAdapter.KEY_DOWNLOADED);
int indexIsPaged = cursor.getColumnIndex(PodDBAdapter.KEY_IS_PAGED);
int indexNextPageLink = cursor.getColumnIndex(PodDBAdapter.KEY_NEXT_PAGE_LINK);
int indexHide = cursor.getColumnIndex(PodDBAdapter.KEY_HIDE);
int indexSortOrder = cursor.getColumnIndex(PodDBAdapter.KEY_SORT_ORDER);
int indexLastUpdateFailed = cursor.getColumnIndex(PodDBAdapter.KEY_LAST_UPDATE_FAILED);
int indexImageUrl = cursor.getColumnIndex(PodDBAdapter.KEY_IMAGE_URL);
Feed feed = new Feed(cursor.getLong(indexId), cursor.getString(indexLastUpdate), cursor.getString(indexTitle), cursor.getString(indexCustomTitle), cursor.getString(indexLink), cursor.getString(indexDescription), cursor.getString(indexPaymentLink), cursor.getString(indexAuthor), cursor.getString(indexLanguage), cursor.getString(indexType), cursor.getString(indexFeedIdentifier), cursor.getString(indexImageUrl), cursor.getString(indexFileUrl), cursor.getString(indexDownloadUrl), cursor.getInt(indexDownloaded) > 0, cursor.getInt(indexIsPaged) > 0, cursor.getString(indexNextPageLink), cursor.getString(indexHide), SortOrder.fromCodeString(cursor.getString(indexSortOrder)), cursor.getInt(indexLastUpdateFailed) > 0);
FeedPreferences preferences = FeedPreferencesCursorMapper.convert(cursor);
feed.setPreferences(preferences);
return feed;
}
use of de.danoeh.antennapod.model.feed.FeedPreferences in project AntennaPod by AntennaPod.
the class FeedPreferencesCursorMapper method convert.
/**
* Create a {@link FeedPreferences} instance from a database row (cursor).
*/
@NonNull
public static FeedPreferences convert(@NonNull Cursor cursor) {
int indexId = cursor.getColumnIndex(PodDBAdapter.KEY_ID);
int indexAutoDownload = cursor.getColumnIndex(PodDBAdapter.KEY_AUTO_DOWNLOAD_ENABLED);
int indexAutoRefresh = cursor.getColumnIndex(PodDBAdapter.KEY_KEEP_UPDATED);
int indexAutoDeleteAction = cursor.getColumnIndex(PodDBAdapter.KEY_AUTO_DELETE_ACTION);
int indexVolumeAdaption = cursor.getColumnIndex(PodDBAdapter.KEY_FEED_VOLUME_ADAPTION);
int indexUsername = cursor.getColumnIndex(PodDBAdapter.KEY_USERNAME);
int indexPassword = cursor.getColumnIndex(PodDBAdapter.KEY_PASSWORD);
int indexIncludeFilter = cursor.getColumnIndex(PodDBAdapter.KEY_INCLUDE_FILTER);
int indexExcludeFilter = cursor.getColumnIndex(PodDBAdapter.KEY_EXCLUDE_FILTER);
int indexMinimalDurationFilter = cursor.getColumnIndex(PodDBAdapter.KEY_MINIMAL_DURATION_FILTER);
int indexFeedPlaybackSpeed = cursor.getColumnIndex(PodDBAdapter.KEY_FEED_PLAYBACK_SPEED);
int indexAutoSkipIntro = cursor.getColumnIndex(PodDBAdapter.KEY_FEED_SKIP_INTRO);
int indexAutoSkipEnding = cursor.getColumnIndex(PodDBAdapter.KEY_FEED_SKIP_ENDING);
int indexEpisodeNotification = cursor.getColumnIndex(PodDBAdapter.KEY_EPISODE_NOTIFICATION);
int indexTags = cursor.getColumnIndex(PodDBAdapter.KEY_FEED_TAGS);
long feedId = cursor.getLong(indexId);
boolean autoDownload = cursor.getInt(indexAutoDownload) > 0;
boolean autoRefresh = cursor.getInt(indexAutoRefresh) > 0;
int autoDeleteActionIndex = cursor.getInt(indexAutoDeleteAction);
FeedPreferences.AutoDeleteAction autoDeleteAction = FeedPreferences.AutoDeleteAction.values()[autoDeleteActionIndex];
int volumeAdaptionValue = cursor.getInt(indexVolumeAdaption);
VolumeAdaptionSetting volumeAdaptionSetting = VolumeAdaptionSetting.fromInteger(volumeAdaptionValue);
String username = cursor.getString(indexUsername);
String password = cursor.getString(indexPassword);
String includeFilter = cursor.getString(indexIncludeFilter);
String excludeFilter = cursor.getString(indexExcludeFilter);
int minimalDurationFilter = cursor.getInt(indexMinimalDurationFilter);
float feedPlaybackSpeed = cursor.getFloat(indexFeedPlaybackSpeed);
int feedAutoSkipIntro = cursor.getInt(indexAutoSkipIntro);
int feedAutoSkipEnding = cursor.getInt(indexAutoSkipEnding);
boolean showNotification = cursor.getInt(indexEpisodeNotification) > 0;
String tagsString = cursor.getString(indexTags);
if (TextUtils.isEmpty(tagsString)) {
tagsString = FeedPreferences.TAG_ROOT;
}
return new FeedPreferences(feedId, autoDownload, autoRefresh, autoDeleteAction, volumeAdaptionSetting, username, password, new FeedFilter(includeFilter, excludeFilter, minimalDurationFilter), feedPlaybackSpeed, feedAutoSkipIntro, feedAutoSkipEnding, showNotification, new HashSet<>(Arrays.asList(tagsString.split(FeedPreferences.TAG_SEPARATOR))));
}
use of de.danoeh.antennapod.model.feed.FeedPreferences in project AntennaPod by AntennaPod.
the class PlaybackService method skipIntro.
private void skipIntro(Playable playable) {
if (!(playable instanceof FeedMedia)) {
return;
}
FeedMedia feedMedia = (FeedMedia) playable;
FeedPreferences preferences = feedMedia.getItem().getFeed().getPreferences();
int skipIntro = preferences.getFeedSkipIntro();
Context context = getApplicationContext();
if (skipIntro > 0 && playable.getPosition() < skipIntro * 1000) {
int duration = getDuration();
if (skipIntro * 1000 < duration || duration <= 0) {
Log.d(TAG, "skipIntro " + playable.getEpisodeTitle());
mediaPlayer.seekTo(skipIntro * 1000);
String skipIntroMesg = context.getString(R.string.pref_feed_skip_intro_toast, skipIntro);
Toast toast = Toast.makeText(context, skipIntroMesg, Toast.LENGTH_LONG);
toast.show();
}
}
}
Aggregations