Search in sources :

Example 81 with FeedItem

use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.

the class VideoplayerActivity method checkFavorite.

private void checkFavorite() {
    FeedItem feedItem = getFeedItem(controller.getMedia());
    if (feedItem == null) {
        return;
    }
    if (disposable != null) {
        disposable.dispose();
    }
    disposable = Observable.fromCallable(() -> DBReader.getFeedItem(feedItem.getId())).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(item -> {
        boolean isFav = item.isTagged(FeedItem.TAG_FAVORITE);
        if (isFavorite != isFav) {
            isFavorite = isFav;
            invalidateOptionsMenu();
        }
    }, error -> Log.e(TAG, Log.getStackTraceString(error)));
}
Also used : ScaleAnimation(android.view.animation.ScaleAnimation) Bundle(android.os.Bundle) SleepTimerDialog(de.danoeh.antennapod.dialog.SleepTimerDialog) WindowManager(android.view.WindowManager) FrameLayout(android.widget.FrameLayout) BufferUpdateEvent(de.danoeh.antennapod.event.playback.BufferUpdateEvent) ColorDrawable(android.graphics.drawable.ColorDrawable) FeedItemUtil(de.danoeh.antennapod.core.util.FeedItemUtil) ShareDialog(de.danoeh.antennapod.dialog.ShareDialog) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) StringUtils(org.apache.commons.lang3.StringUtils) UserPreferences(de.danoeh.antennapod.core.preferences.UserPreferences) TimeSpeedConverter(de.danoeh.antennapod.core.util.TimeSpeedConverter) AnimationSet(android.view.animation.AnimationSet) Handler(android.os.Handler) Looper(android.os.Looper) PlaybackPositionEvent(de.danoeh.antennapod.event.playback.PlaybackPositionEvent) View(android.view.View) Schedulers(io.reactivex.schedulers.Schedulers) Animation(android.view.animation.Animation) PlaybackServiceEvent(de.danoeh.antennapod.event.playback.PlaybackServiceEvent) SurfaceHolder(android.view.SurfaceHolder) TargetApi(android.annotation.TargetApi) Log(android.util.Log) PlaybackService(de.danoeh.antennapod.core.service.playback.PlaybackService) IntentUtils(de.danoeh.antennapod.core.util.IntentUtils) ThreadMode(org.greenrobot.eventbus.ThreadMode) PlayerStatus(de.danoeh.antennapod.playback.base.PlayerStatus) Disposable(io.reactivex.disposables.Disposable) Nullable(androidx.annotation.Nullable) AlphaAnimation(android.view.animation.AlphaAnimation) SleepTimerUpdatedEvent(de.danoeh.antennapod.event.playback.SleepTimerUpdatedEvent) MainActivityStarter(de.danoeh.antennapod.ui.appstartintent.MainActivityStarter) Converter(de.danoeh.antennapod.core.util.Converter) PlaybackController(de.danoeh.antennapod.core.util.playback.PlaybackController) PlayerErrorEvent(de.danoeh.antennapod.event.PlayerErrorEvent) KeyEvent(android.view.KeyEvent) AlertDialog(androidx.appcompat.app.AlertDialog) Pair(android.util.Pair) FastOutSlowInInterpolator(androidx.interpolator.view.animation.FastOutSlowInInterpolator) Intent(android.content.Intent) PixelFormat(android.graphics.PixelFormat) AudioManager(android.media.AudioManager) MenuItem(android.view.MenuItem) AnimationUtils(android.view.animation.AnimationUtils) SeekBar(android.widget.SeekBar) SuppressLint(android.annotation.SuppressLint) MenuInflater(android.view.MenuInflater) MotionEvent(android.view.MotionEvent) ShareUtils(de.danoeh.antennapod.core.util.ShareUtils) EventBus(org.greenrobot.eventbus.EventBus) Menu(android.view.Menu) StorageUtils(de.danoeh.antennapod.core.util.StorageUtils) SkipPreferenceDialog(de.danoeh.antennapod.dialog.SkipPreferenceDialog) Observable(io.reactivex.Observable) Build(android.os.Build) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) PlaybackControlsDialog(de.danoeh.antennapod.dialog.PlaybackControlsDialog) LayoutInflater(android.view.LayoutInflater) R(de.danoeh.antennapod.R) FeedItem(de.danoeh.antennapod.model.feed.FeedItem) Playable(de.danoeh.antennapod.model.playback.Playable) CastEnabledActivity(de.danoeh.antennapod.playback.cast.CastEnabledActivity) PictureInPictureUtil(de.danoeh.antennapod.core.util.gui.PictureInPictureUtil) VideoplayerActivityBinding(de.danoeh.antennapod.databinding.VideoplayerActivityBinding) WindowCompat(androidx.core.view.WindowCompat) Gravity(android.view.Gravity) Glide(com.bumptech.glide.Glide) Subscribe(org.greenrobot.eventbus.Subscribe) DBWriter(de.danoeh.antennapod.core.storage.DBWriter) DBReader(de.danoeh.antennapod.core.storage.DBReader) EditText(android.widget.EditText) FeedItem(de.danoeh.antennapod.model.feed.FeedItem)

Example 82 with FeedItem

use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.

the class AutoDownloadTest method downloadsEnqueuedToAfterCurrent_CurrentAdvancedToNextOnPlaybackComplete.

/**
 * A cross-functional test, ensuring playback's behavior works with Auto Download in boundary condition.
 *
 * Scenario:
 * - For setting enqueue location AFTER_CURRENTLY_PLAYING
 * - when playback of an episode is complete and the app advances to the next episode (continuous playback on)
 * - when automatic download kicks in,
 * - ensure the next episode is the current playing one, needed for AFTER_CURRENTLY_PLAYING enqueue location.
 */
@Test
public void downloadsEnqueuedToAfterCurrent_CurrentAdvancedToNextOnPlaybackComplete() throws Exception {
    // continuous playback
    UserPreferences.setFollowQueue(true);
    // Setup: feeds and queue
    // downloads 3 of them, leave some in new state (auto-downloadable)
    stubFeedsServer.addLocalFeedData(false);
    List<FeedItem> queue = DBReader.getQueue();
    assertTrue(queue.size() > 1);
    FeedItem item0 = queue.get(0);
    FeedItem item1 = queue.get(1);
    // Actual test
    // Play the first one in the queue
    playEpisode(item0);
    try {
        // when playback is complete, advances to the next one, and auto download kicks in,
        // ensure that currently playing has been advanced to the next one by this point.
        Awaitility.await("advanced to the next episode").atMost(6000, // the test mp3 media is 3-second long. twice should be enough
        MILLISECONDS).until(() -> item1.getMedia().getId() == stubDownloadAlgorithm.getCurrentlyPlayingAtDownload());
    } catch (ConditionTimeoutException cte) {
        long actual = stubDownloadAlgorithm.getCurrentlyPlayingAtDownload();
        fail("when auto download is triggered, the next episode should be playing: (" + item1.getId() + ", " + item1.getTitle() + ") . " + "Actual playing: (" + actual + ")");
    }
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) ConditionTimeoutException(org.awaitility.core.ConditionTimeoutException) Test(org.junit.Test)

Example 83 with FeedItem

use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.

the class UITestUtilsTest method addLocalFeedDataCheck.

private void addLocalFeedDataCheck(boolean downloadEpisodes) throws Exception {
    uiTestUtils.addLocalFeedData(downloadEpisodes);
    assertNotNull(uiTestUtils.hostedFeeds);
    assertFalse(uiTestUtils.hostedFeeds.isEmpty());
    for (Feed feed : uiTestUtils.hostedFeeds) {
        assertTrue(feed.getId() != 0);
        for (FeedItem item : feed.getItems()) {
            assertTrue(item.getId() != 0);
            if (item.hasMedia()) {
                assertTrue(item.getMedia().getId() != 0);
                if (downloadEpisodes) {
                    assertTrue(item.getMedia().isDownloaded());
                    assertNotNull(item.getMedia().getFile_url());
                    File file = new File(item.getMedia().getFile_url());
                    assertTrue(file.exists());
                }
            }
        }
    }
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) File(java.io.File) Feed(de.danoeh.antennapod.model.feed.Feed)

Example 84 with FeedItem

use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.

the class UITestUtilsTest method testAddHostedFeeds.

@Test
public void testAddHostedFeeds() throws Exception {
    uiTestUtils.addHostedFeedData();
    final List<Feed> feeds = uiTestUtils.hostedFeeds;
    assertNotNull(feeds);
    assertFalse(feeds.isEmpty());
    for (Feed feed : feeds) {
        testUrlReachable(feed.getDownload_url());
        for (FeedItem item : feed.getItems()) {
            if (item.hasMedia()) {
                testUrlReachable(item.getMedia().getDownload_url());
            }
        }
    }
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) Feed(de.danoeh.antennapod.model.feed.Feed) MediumTest(androidx.test.filters.MediumTest) Test(org.junit.Test)

Example 85 with FeedItem

use of de.danoeh.antennapod.model.feed.FeedItem in project AntennaPod by AntennaPod.

the class UITestUtils method addLocalFeedData.

/**
 * Adds feeds, images and episodes to the local database. This method will also call addHostedFeedData if it has not
 * been called yet.
 *
 * Adds one item of each feed to the queue and to the playback history.
 *
 * This method should NOT be called if the testing class wants to download the hosted feed data.
 *
 * @param downloadEpisodes true if episodes should also be marked as downloaded.
 */
public void addLocalFeedData(boolean downloadEpisodes) throws Exception {
    if (localFeedDataAdded) {
        Log.w(TAG, "addLocalFeedData was called twice on the same instance");
        // might be a flaky test, this is actually not that severe
        return;
    }
    if (!feedDataHosted) {
        addHostedFeedData();
    }
    List<FeedItem> queue = new ArrayList<>();
    for (Feed feed : hostedFeeds) {
        feed.setDownloaded(true);
        if (downloadEpisodes) {
            for (FeedItem item : feed.getItems()) {
                if (item.hasMedia()) {
                    FeedMedia media = item.getMedia();
                    int fileId = Integer.parseInt(StringUtils.substringAfter(media.getDownload_url(), "files/"));
                    media.setFile_url(server.accessFile(fileId).getAbsolutePath());
                    media.setDownloaded(true);
                }
            }
        }
        queue.add(feed.getItems().get(0));
        if (feed.getItems().get(1).hasMedia()) {
            feed.getItems().get(1).getMedia().setPlaybackCompletionDate(new Date());
        }
    }
    localFeedDataAdded = true;
    PodDBAdapter adapter = PodDBAdapter.getInstance();
    adapter.open();
    adapter.setCompleteFeed(hostedFeeds.toArray(new Feed[0]));
    adapter.setQueue(queue);
    adapter.close();
    EventBus.getDefault().post(new FeedListUpdateEvent(hostedFeeds));
    EventBus.getDefault().post(QueueEvent.setQueue(queue));
}
Also used : PodDBAdapter(de.danoeh.antennapod.core.storage.PodDBAdapter) FeedItem(de.danoeh.antennapod.model.feed.FeedItem) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) ArrayList(java.util.ArrayList) FeedListUpdateEvent(de.danoeh.antennapod.event.FeedListUpdateEvent) Date(java.util.Date) Feed(de.danoeh.antennapod.model.feed.Feed)

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