Search in sources :

Example 56 with FeedItem

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;
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) Feed(de.danoeh.antennapod.model.feed.Feed)

Example 57 with FeedItem

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();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Context(android.content.Context) Bundle(android.os.Bundle) AlertDialog(androidx.appcompat.app.AlertDialog) NonNull(androidx.annotation.NonNull) R(de.danoeh.antennapod.R) RadioButton(android.widget.RadioButton) FeedItem(de.danoeh.antennapod.model.feed.FeedItem) Dialog(android.app.Dialog) RadioGroup(android.widget.RadioGroup) Nullable(androidx.annotation.Nullable) SharedPreferences(android.content.SharedPreferences) CheckBox(android.widget.CheckBox) ShareUtils(de.danoeh.antennapod.core.util.ShareUtils) View(android.view.View) DialogFragment(androidx.fragment.app.DialogFragment) RadioGroup(android.widget.RadioGroup) View(android.view.View) NonNull(androidx.annotation.NonNull)

Example 58 with FeedItem

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);
            }
        }
    }
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 59 with FeedItem

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;
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) Feed(de.danoeh.antennapod.model.feed.Feed) Nullable(androidx.annotation.Nullable)

Example 60 with FeedItem

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());
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) View(android.view.View) Espresso.onView(androidx.test.espresso.Espresso.onView) EspressoTestUtils.waitForView(de.test.antennapod.EspressoTestUtils.waitForView)

Aggregations

FeedItem (de.danoeh.antennapod.model.feed.FeedItem)178 Feed (de.danoeh.antennapod.model.feed.Feed)74 Test (org.junit.Test)64 ArrayList (java.util.ArrayList)48 Date (java.util.Date)47 FeedMedia (de.danoeh.antennapod.model.feed.FeedMedia)46 File (java.io.File)26 Cursor (android.database.Cursor)20 NonNull (androidx.annotation.NonNull)15 Nullable (androidx.annotation.Nullable)11 Subscribe (org.greenrobot.eventbus.Subscribe)9 Intent (android.content.Intent)7 FeedFilter (de.danoeh.antennapod.model.feed.FeedFilter)7 View (android.view.View)6 LongList (de.danoeh.antennapod.core.util.LongList)6 SQLException (android.database.SQLException)5 Playable (de.danoeh.antennapod.model.playback.Playable)5 EpisodeAction (de.danoeh.antennapod.net.sync.model.EpisodeAction)5 ExecutionException (java.util.concurrent.ExecutionException)5 FeedItemPubdateComparator (de.danoeh.antennapod.core.util.comparator.FeedItemPubdateComparator)4