Search in sources :

Example 46 with FeedMedia

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

the class CoverFragment method displayMediaInfo.

private void displayMediaInfo(@NonNull Playable media) {
    String pubDateStr = DateFormatter.formatAbbrev(getActivity(), media.getPubDate());
    txtvPodcastTitle.setText(StringUtils.stripToEmpty(media.getFeedTitle()) + "\u00A0" + "・" + "\u00A0" + StringUtils.replace(StringUtils.stripToEmpty(pubDateStr), " ", "\u00A0"));
    if (media instanceof FeedMedia) {
        Intent openFeed = MainActivity.getIntentToOpenFeed(requireContext(), ((FeedMedia) media).getItem().getFeedId());
        txtvPodcastTitle.setOnClickListener(v -> startActivity(openFeed));
    } else {
        txtvPodcastTitle.setOnClickListener(null);
    }
    txtvPodcastTitle.setOnLongClickListener(v -> copyText(media.getFeedTitle()));
    txtvEpisodeTitle.setText(media.getEpisodeTitle());
    txtvEpisodeTitle.setOnLongClickListener(v -> copyText(media.getEpisodeTitle()));
    txtvEpisodeTitle.setOnClickListener(v -> {
        int lines = txtvEpisodeTitle.getLineCount();
        int animUnit = 1500;
        if (lines > txtvEpisodeTitle.getMaxLines()) {
            ObjectAnimator verticalMarquee = ObjectAnimator.ofInt(txtvEpisodeTitle, "scrollY", 0, (lines - txtvEpisodeTitle.getMaxLines()) * ((txtvEpisodeTitle.getHeight() - txtvEpisodeTitle.getPaddingTop() - txtvEpisodeTitle.getPaddingBottom()) / txtvEpisodeTitle.getMaxLines())).setDuration(lines * animUnit);
            ObjectAnimator fadeOut = ObjectAnimator.ofFloat(txtvEpisodeTitle, "alpha", 0);
            fadeOut.setStartDelay(animUnit);
            fadeOut.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    txtvEpisodeTitle.scrollTo(0, 0);
                }
            });
            ObjectAnimator fadeBackIn = ObjectAnimator.ofFloat(txtvEpisodeTitle, "alpha", 1);
            AnimatorSet set = new AnimatorSet();
            set.playSequentially(verticalMarquee, fadeOut, fadeBackIn);
            set.start();
        }
    });
    displayedChapterIndex = -1;
    // calls displayCoverImage
    refreshChapterData(ChapterUtils.getCurrentChapterIndex(media, media.getPosition()));
    updateChapterControlVisibility();
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) Intent(android.content.Intent) AnimatorSet(android.animation.AnimatorSet)

Example 47 with FeedMedia

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

the class DownloadLogFragment method onListItemClick.

@Override
public void onListItemClick(@NonNull ListView l, @NonNull View v, int position, long id) {
    super.onListItemClick(l, v, position, id);
    Object item = adapter.getItem(position);
    if (item instanceof Downloader) {
        DownloadRequest downloadRequest = ((Downloader) item).getDownloadRequest();
        DownloadService.cancel(getContext(), downloadRequest.getSource());
        if (downloadRequest.getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA) {
            FeedMedia media = DBReader.getFeedMedia(downloadRequest.getFeedfileId());
            FeedItem feedItem = media.getItem();
            feedItem.disableAutoDownload();
            DBWriter.setFeedItem(feedItem);
        }
    } else if (item instanceof DownloadStatus) {
        DownloadStatus status = (DownloadStatus) item;
        String url = "unknown";
        String message = getString(R.string.download_successful);
        if (status.getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA) {
            FeedMedia media = DBReader.getFeedMedia(status.getFeedfileId());
            if (media != null) {
                url = media.getDownload_url();
            }
        } else if (status.getFeedfileType() == Feed.FEEDFILETYPE_FEED) {
            Feed feed = DBReader.getFeed(status.getFeedfileId());
            if (feed != null) {
                url = feed.getDownload_url();
            }
        }
        if (!status.isSuccessful()) {
            message = status.getReasonDetailed();
        }
        String messageFull = getString(R.string.download_error_details_message, message, url);
        AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
        builder.setTitle(R.string.download_error_details);
        builder.setMessage(messageFull);
        builder.setPositiveButton(android.R.string.ok, null);
        builder.setNeutralButton(R.string.copy_to_clipboard, (dialog, which) -> {
            ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText(getString(R.string.download_error_details), messageFull);
            clipboard.setPrimaryClip(clip);
            ((MainActivity) getActivity()).showSnackbarAbovePlayer(R.string.copied_to_clipboard, Snackbar.LENGTH_SHORT);
        });
        Dialog dialog = builder.show();
        ((TextView) dialog.findViewById(android.R.id.message)).setTextIsSelectable(true);
    }
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Context(android.content.Context) Bundle(android.os.Bundle) AlertDialog(androidx.appcompat.app.AlertDialog) AutoUpdateManager(de.danoeh.antennapod.core.util.download.AutoUpdateManager) NonNull(androidx.annotation.NonNull) Dialog(android.app.Dialog) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) ClipData(android.content.ClipData) DownloadRequest(de.danoeh.antennapod.core.service.download.DownloadRequest) DownloadLogEvent(de.danoeh.antennapod.core.event.DownloadLogEvent) EventBus(org.greenrobot.eventbus.EventBus) Menu(android.view.Menu) ClipboardManager(android.content.ClipboardManager) View(android.view.View) DownloaderUpdate(de.danoeh.antennapod.core.event.DownloaderUpdate) Observable(io.reactivex.Observable) Schedulers(io.reactivex.schedulers.Schedulers) DownloadStatus(de.danoeh.antennapod.core.service.download.DownloadStatus) Log(android.util.Log) Feed(de.danoeh.antennapod.model.feed.Feed) Downloader(de.danoeh.antennapod.core.service.download.Downloader) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) R(de.danoeh.antennapod.R) EmptyViewHandler(de.danoeh.antennapod.view.EmptyViewHandler) FeedItem(de.danoeh.antennapod.model.feed.FeedItem) ThreadMode(org.greenrobot.eventbus.ThreadMode) MenuItemUtils(de.danoeh.antennapod.core.menuhandler.MenuItemUtils) MainActivity(de.danoeh.antennapod.activity.MainActivity) Disposable(io.reactivex.disposables.Disposable) List(java.util.List) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) Subscribe(org.greenrobot.eventbus.Subscribe) DownloadLogAdapter(de.danoeh.antennapod.adapter.DownloadLogAdapter) DownloadEvent(de.danoeh.antennapod.core.event.DownloadEvent) DBWriter(de.danoeh.antennapod.core.storage.DBWriter) DBReader(de.danoeh.antennapod.core.storage.DBReader) ListFragment(androidx.fragment.app.ListFragment) ListView(android.widget.ListView) Snackbar(com.google.android.material.snackbar.Snackbar) DownloadService(de.danoeh.antennapod.core.service.download.DownloadService) ClipboardManager(android.content.ClipboardManager) Downloader(de.danoeh.antennapod.core.service.download.Downloader) DownloadRequest(de.danoeh.antennapod.core.service.download.DownloadRequest) FeedItem(de.danoeh.antennapod.model.feed.FeedItem) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) AlertDialog(androidx.appcompat.app.AlertDialog) Dialog(android.app.Dialog) DownloadStatus(de.danoeh.antennapod.core.service.download.DownloadStatus) ClipData(android.content.ClipData) Feed(de.danoeh.antennapod.model.feed.Feed)

Example 48 with FeedMedia

use of de.danoeh.antennapod.model.feed.FeedMedia 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 49 with FeedMedia

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

the class ItemDescriptionFragment method load.

private void load() {
    Log.d(TAG, "load()");
    if (webViewLoader != null) {
        webViewLoader.dispose();
    }
    webViewLoader = Maybe.<String>create(emitter -> {
        Playable media = controller.getMedia();
        if (media == null) {
            emitter.onComplete();
            return;
        }
        if (media instanceof FeedMedia) {
            FeedMedia feedMedia = ((FeedMedia) media);
            if (feedMedia.getItem() == null) {
                feedMedia.setItem(DBReader.getFeedItem(feedMedia.getItemId()));
            }
            DBReader.loadDescriptionOfFeedItem(feedMedia.getItem());
        }
        Timeline timeline = new Timeline(getActivity(), media.getDescription(), media.getDuration());
        emitter.onSuccess(timeline.processShownotes());
    }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(data -> {
        webvDescription.loadDataWithBaseURL("https://127.0.0.1", data, "text/html", "utf-8", "about:blank");
        Log.d(TAG, "Webview loaded");
    }, error -> Log.e(TAG, Log.getStackTraceString(error)));
}
Also used : PlaybackController(de.danoeh.antennapod.core.util.playback.PlaybackController) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) Bundle(android.os.Bundle) LayoutInflater(android.view.LayoutInflater) R(de.danoeh.antennapod.R) Maybe(io.reactivex.Maybe) Playable(de.danoeh.antennapod.model.playback.Playable) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) ViewGroup(android.view.ViewGroup) MenuItem(android.view.MenuItem) Timeline(de.danoeh.antennapod.core.util.playback.Timeline) Disposable(io.reactivex.disposables.Disposable) SharedPreferences(android.content.SharedPreferences) ShownotesWebView(de.danoeh.antennapod.view.ShownotesWebView) Fragment(androidx.fragment.app.Fragment) DBReader(de.danoeh.antennapod.core.storage.DBReader) View(android.view.View) Schedulers(io.reactivex.schedulers.Schedulers) Activity(android.app.Activity) Log(android.util.Log) Timeline(de.danoeh.antennapod.core.util.playback.Timeline) Playable(de.danoeh.antennapod.model.playback.Playable) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia)

Example 50 with FeedMedia

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

the class ItemFragment method updateButtons.

private void updateButtons() {
    progbarDownload.setVisibility(View.GONE);
    if (item.hasMedia() && downloaderList != null) {
        for (Downloader downloader : downloaderList) {
            if (downloader.getDownloadRequest().getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA && downloader.getDownloadRequest().getFeedfileId() == item.getMedia().getId()) {
                progbarDownload.setVisibility(View.VISIBLE);
                progbarDownload.setProgress(downloader.getDownloadRequest().getProgressPercent());
            }
        }
    }
    FeedMedia media = item.getMedia();
    if (media == null) {
        actionButton1 = new MarkAsPlayedActionButton(item);
        actionButton2 = new VisitWebsiteActionButton(item);
        noMediaLabel.setVisibility(View.VISIBLE);
    } else {
        noMediaLabel.setVisibility(View.GONE);
        if (media.getDuration() > 0) {
            txtvDuration.setText(Converter.getDurationStringLong(media.getDuration()));
            txtvDuration.setContentDescription(Converter.getDurationStringLocalized(getContext(), media.getDuration()));
        }
        if (FeedItemUtil.isCurrentlyPlaying(media)) {
            actionButton1 = new PauseActionButton(item);
        } else if (item.getFeed().isLocalFeed()) {
            actionButton1 = new PlayLocalActionButton(item);
        } else if (media.isDownloaded()) {
            actionButton1 = new PlayActionButton(item);
        } else {
            actionButton1 = new StreamActionButton(item);
        }
        if (DownloadService.isDownloadingFile(media.getDownload_url())) {
            actionButton2 = new CancelDownloadActionButton(item);
        } else if (!media.isDownloaded()) {
            actionButton2 = new DownloadActionButton(item);
        } else {
            actionButton2 = new DeleteActionButton(item);
        }
    }
    butAction1Text.setText(actionButton1.getLabel());
    butAction1Text.setTransformationMethod(null);
    butAction1Icon.setImageResource(actionButton1.getDrawable());
    butAction1.setVisibility(actionButton1.getVisibility());
    butAction2Text.setText(actionButton2.getLabel());
    butAction2Text.setTransformationMethod(null);
    butAction2Icon.setImageResource(actionButton2.getDrawable());
    butAction2.setVisibility(actionButton2.getVisibility());
}
Also used : StreamActionButton(de.danoeh.antennapod.adapter.actionbutton.StreamActionButton) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) PlayActionButton(de.danoeh.antennapod.adapter.actionbutton.PlayActionButton) PlayLocalActionButton(de.danoeh.antennapod.adapter.actionbutton.PlayLocalActionButton) CancelDownloadActionButton(de.danoeh.antennapod.adapter.actionbutton.CancelDownloadActionButton) DeleteActionButton(de.danoeh.antennapod.adapter.actionbutton.DeleteActionButton) Downloader(de.danoeh.antennapod.core.service.download.Downloader) VisitWebsiteActionButton(de.danoeh.antennapod.adapter.actionbutton.VisitWebsiteActionButton) CancelDownloadActionButton(de.danoeh.antennapod.adapter.actionbutton.CancelDownloadActionButton) DownloadActionButton(de.danoeh.antennapod.adapter.actionbutton.DownloadActionButton) MarkAsPlayedActionButton(de.danoeh.antennapod.adapter.actionbutton.MarkAsPlayedActionButton) PauseActionButton(de.danoeh.antennapod.adapter.actionbutton.PauseActionButton)

Aggregations

FeedMedia (de.danoeh.antennapod.model.feed.FeedMedia)91 FeedItem (de.danoeh.antennapod.model.feed.FeedItem)46 Test (org.junit.Test)28 Feed (de.danoeh.antennapod.model.feed.Feed)26 Date (java.util.Date)25 ArrayList (java.util.ArrayList)18 FeedPreferences (de.danoeh.antennapod.model.feed.FeedPreferences)15 File (java.io.File)15 Playable (de.danoeh.antennapod.model.playback.Playable)8 View (android.view.View)6 NonNull (androidx.annotation.NonNull)6 Context (android.content.Context)5 Log (android.util.Log)5 PlaybackServiceStarter (de.danoeh.antennapod.core.util.playback.PlaybackServiceStarter)5 Cursor (android.database.Cursor)4 Nullable (androidx.annotation.Nullable)4 R (de.danoeh.antennapod.R)4 DownloadRequest (de.danoeh.antennapod.core.service.download.DownloadRequest)4 DownloadService (de.danoeh.antennapod.core.service.download.DownloadService)4 Intent (android.content.Intent)3