use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.
the class FeedItemPermutorsTest method getTestList.
/**
* Generates a list with test data.
*/
private List<FeedItem> getTestList() {
List<FeedItem> itemList = new ArrayList<>();
Calendar calendar = Calendar.getInstance();
// January 1st
calendar.set(2019, 0, 1);
Feed feed1 = new Feed(null, null, "Feed title 1");
FeedItem feedItem1 = new FeedItem(1, "Title 1", null, null, calendar.getTime(), 0, feed1);
FeedMedia feedMedia1 = new FeedMedia(0, feedItem1, 1000, 0, 0, null, null, null, true, null, 0, 0);
feedItem1.setMedia(feedMedia1);
itemList.add(feedItem1);
// March 1st
calendar.set(2019, 2, 1);
Feed feed2 = new Feed(null, null, "Feed title 3");
FeedItem feedItem2 = new FeedItem(3, "Title 3", null, null, calendar.getTime(), 0, feed2);
FeedMedia feedMedia2 = new FeedMedia(0, feedItem2, 3000, 0, 0, null, null, null, true, null, 0, 0);
feedItem2.setMedia(feedMedia2);
itemList.add(feedItem2);
// February 1st
calendar.set(2019, 1, 1);
Feed feed3 = new Feed(null, null, "Feed title 2");
FeedItem feedItem3 = new FeedItem(2, "Title 2", null, null, calendar.getTime(), 0, feed3);
FeedMedia feedMedia3 = new FeedMedia(0, feedItem3, 2000, 0, 0, null, null, null, true, null, 0, 0);
feedItem3.setMedia(feedMedia3);
itemList.add(feedItem3);
return itemList;
}
use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.
the class ShareDialog method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
if (getArguments() != null) {
ctx = getActivity();
item = (FeedItem) getArguments().getSerializable(ARGUMENT_FEED_ITEM);
prefs = getActivity().getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
}
View content = View.inflate(ctx, R.layout.share_episode_dialog, null);
AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
builder.setTitle(R.string.share_label);
builder.setView(content);
RadioGroup radioGroup = content.findViewById(R.id.share_dialog_radio_group);
radioGroup.setOnCheckedChangeListener((group, checkedId) -> checkBoxStartAt.setEnabled(checkedId != R.id.share_media_file_radio));
radioLinkToEpisode = content.findViewById(R.id.share_link_to_episode_radio);
radioMediaFile = content.findViewById(R.id.share_media_file_radio);
checkBoxStartAt = content.findViewById(R.id.share_start_at_timer_dialog);
setupOptions();
builder.setPositiveButton(R.string.share_label, (dialog, id) -> {
boolean includePlaybackPosition = checkBoxStartAt.isChecked();
if (radioLinkToEpisode.isChecked()) {
ShareUtils.shareFeedItemLinkWithDownloadLink(ctx, item, includePlaybackPosition);
} else if (radioMediaFile.isChecked()) {
ShareUtils.shareFeedItemFile(ctx, item.getMedia());
} else {
throw new IllegalStateException("Unknown share method");
}
prefs.edit().putBoolean(PREF_SHARE_EPISODE_START_AT, includePlaybackPosition).apply();
}).setNegativeButton(R.string.cancel_label, (dialog, id) -> dialog.dismiss());
return builder.create();
}
use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.
the class EpisodesListFragment method onEventMainThread.
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(FeedItemEvent event) {
Log.d(TAG, "onEventMainThread() called with: " + "event = [" + event + "]");
for (FeedItem item : event.items) {
int pos = FeedItemUtil.indexOfItemWithId(episodes, item.getId());
if (pos >= 0) {
episodes.remove(pos);
if (shouldUpdatedItemRemainInList(item)) {
episodes.add(pos, item);
listAdapter.notifyItemChangedCompat(pos);
} else {
listAdapter.notifyItemRemoved(pos);
}
}
}
}
use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.
the class FeedItemlistFragment method loadData.
@Nullable
private Feed loadData() {
Feed feed = DBReader.getFeed(feedID, true);
if (feed == null) {
return null;
}
DBReader.loadAdditionalFeedItemListData(feed.getItems());
if (feed.getSortOrder() != null) {
List<FeedItem> feedItems = feed.getItems();
FeedItemPermutors.getPermutor(feed.getSortOrder()).reorder(feedItems);
feed.setItems(feedItems);
}
return feed;
}
use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.
the class PlaybackTest method playFromQueue.
/**
* @param itemIdx The 0-based index of the episode to be played in the queue.
*/
protected void playFromQueue(int itemIdx) {
final List<FeedItem> queue = DBReader.getQueue();
Matcher<View> queueMatcher = allOf(withId(R.id.recyclerView), isDisplayed(), hasMinimumChildCount(2));
onView(isRoot()).perform(waitForView(queueMatcher, 1000));
onView(queueMatcher).perform(actionOnItemAtPosition(itemIdx, clickChildViewWithId(R.id.secondaryActionButton)));
FeedMedia media = queue.get(itemIdx).getMedia();
Awaitility.await().atMost(1, TimeUnit.SECONDS).until(() -> media.getId() == PlaybackPreferences.getCurrentlyPlayingFeedMediaId());
}
Aggregations