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();
}
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);
}
}
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;
}
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)));
}
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());
}
Aggregations