Search in sources :

Example 1 with PlaybackControlsDialog

use of de.danoeh.antennapod.dialog.PlaybackControlsDialog in project AntennaPod by AntennaPod.

the class AudioPlayerFragment method onMenuItemClick.

@Override
public boolean onMenuItemClick(MenuItem item) {
    if (controller == null) {
        return false;
    }
    Playable media = controller.getMedia();
    if (media == null) {
        return false;
    }
    @Nullable final FeedItem feedItem = (media instanceof FeedMedia) ? ((FeedMedia) media).getItem() : null;
    if (feedItem != null && FeedItemMenuHandler.onMenuItemClicked(this, item.getItemId(), feedItem)) {
        return true;
    }
    final int itemId = item.getItemId();
    if (itemId == R.id.disable_sleeptimer_item || itemId == R.id.set_sleeptimer_item) {
        new SleepTimerDialog().show(getChildFragmentManager(), "SleepTimerDialog");
        return true;
    } else if (itemId == R.id.audio_controls) {
        PlaybackControlsDialog dialog = PlaybackControlsDialog.newInstance();
        dialog.show(getChildFragmentManager(), "playback_controls");
        return true;
    } else if (itemId == R.id.open_feed_item) {
        if (feedItem != null) {
            Intent intent = MainActivity.getIntentToOpenFeed(getContext(), feedItem.getFeedId());
            startActivity(intent);
        }
        return true;
    }
    return false;
}
Also used : FeedItem(de.danoeh.antennapod.model.feed.FeedItem) Playable(de.danoeh.antennapod.model.playback.Playable) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) PlaybackControlsDialog(de.danoeh.antennapod.dialog.PlaybackControlsDialog) SleepTimerDialog(de.danoeh.antennapod.dialog.SleepTimerDialog) Intent(android.content.Intent) Nullable(androidx.annotation.Nullable)

Example 2 with PlaybackControlsDialog

use of de.danoeh.antennapod.dialog.PlaybackControlsDialog in project AntennaPod by AntennaPod.

the class VideoplayerActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.player_go_to_picture_in_picture) {
        compatEnterPictureInPicture();
        return true;
    }
    if (item.getItemId() == android.R.id.home) {
        Intent intent = new Intent(VideoplayerActivity.this, MainActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
        finish();
        return true;
    }
    if (controller == null) {
        return false;
    }
    Playable media = controller.getMedia();
    if (media == null) {
        return false;
    }
    // some options option requires FeedItem
    @Nullable final FeedItem feedItem = getFeedItem(media);
    if (item.getItemId() == R.id.add_to_favorites_item && feedItem != null) {
        DBWriter.addFavoriteItem(feedItem);
        isFavorite = true;
        invalidateOptionsMenu();
    } else if (item.getItemId() == R.id.remove_from_favorites_item && feedItem != null) {
        DBWriter.removeFavoriteItem(feedItem);
        isFavorite = false;
        invalidateOptionsMenu();
    } else if (item.getItemId() == R.id.disable_sleeptimer_item || item.getItemId() == R.id.set_sleeptimer_item) {
        new SleepTimerDialog().show(getSupportFragmentManager(), "SleepTimerDialog");
    } else if (item.getItemId() == R.id.audio_controls) {
        PlaybackControlsDialog dialog = PlaybackControlsDialog.newInstance();
        dialog.show(getSupportFragmentManager(), "playback_controls");
    } else if (item.getItemId() == R.id.open_feed_item && feedItem != null) {
        Intent intent = MainActivity.getIntentToOpenFeed(this, feedItem.getFeedId());
        startActivity(intent);
    } else if (item.getItemId() == R.id.visit_website_item) {
        IntentUtils.openInBrowser(VideoplayerActivity.this, getWebsiteLinkWithFallback(media));
    } else if (item.getItemId() == R.id.share_item && feedItem != null) {
        ShareDialog shareDialog = ShareDialog.newInstance(feedItem);
        shareDialog.show(getSupportFragmentManager(), "ShareEpisodeDialog");
    } else {
        return false;
    }
    return true;
}
Also used : ShareDialog(de.danoeh.antennapod.dialog.ShareDialog) FeedItem(de.danoeh.antennapod.model.feed.FeedItem) Playable(de.danoeh.antennapod.model.playback.Playable) PlaybackControlsDialog(de.danoeh.antennapod.dialog.PlaybackControlsDialog) SleepTimerDialog(de.danoeh.antennapod.dialog.SleepTimerDialog) Intent(android.content.Intent) Nullable(androidx.annotation.Nullable)

Aggregations

Intent (android.content.Intent)2 Nullable (androidx.annotation.Nullable)2 PlaybackControlsDialog (de.danoeh.antennapod.dialog.PlaybackControlsDialog)2 SleepTimerDialog (de.danoeh.antennapod.dialog.SleepTimerDialog)2 FeedItem (de.danoeh.antennapod.model.feed.FeedItem)2 Playable (de.danoeh.antennapod.model.playback.Playable)2 ShareDialog (de.danoeh.antennapod.dialog.ShareDialog)1 FeedMedia (de.danoeh.antennapod.model.feed.FeedMedia)1