Search in sources :

Example 1 with DeleteActionButton

use of de.danoeh.antennapod.adapter.actionbutton.DeleteActionButton 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

CancelDownloadActionButton (de.danoeh.antennapod.adapter.actionbutton.CancelDownloadActionButton)1 DeleteActionButton (de.danoeh.antennapod.adapter.actionbutton.DeleteActionButton)1 DownloadActionButton (de.danoeh.antennapod.adapter.actionbutton.DownloadActionButton)1 MarkAsPlayedActionButton (de.danoeh.antennapod.adapter.actionbutton.MarkAsPlayedActionButton)1 PauseActionButton (de.danoeh.antennapod.adapter.actionbutton.PauseActionButton)1 PlayActionButton (de.danoeh.antennapod.adapter.actionbutton.PlayActionButton)1 PlayLocalActionButton (de.danoeh.antennapod.adapter.actionbutton.PlayLocalActionButton)1 StreamActionButton (de.danoeh.antennapod.adapter.actionbutton.StreamActionButton)1 VisitWebsiteActionButton (de.danoeh.antennapod.adapter.actionbutton.VisitWebsiteActionButton)1 Downloader (de.danoeh.antennapod.core.service.download.Downloader)1 FeedMedia (de.danoeh.antennapod.model.feed.FeedMedia)1