Search in sources :

Example 31 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project AntennaPod by AntennaPod.

the class OnlineFeedViewActivity method showFeedInformation.

/**
 * Called when feed parsed successfully.
 * This method is executed on the GUI thread.
 */
private void showFeedInformation(final Feed feed, Map<String, String> alternateFeedUrls) {
    viewBinding.progressBar.setVisibility(View.GONE);
    viewBinding.feedDisplayContainer.setVisibility(View.VISIBLE);
    if (isFeedFoundBySearch) {
        int resId = R.string.no_feed_url_podcast_found_by_search;
        Snackbar.make(findViewById(android.R.id.content), resId, Snackbar.LENGTH_LONG).show();
    }
    this.feed = feed;
    this.selectedDownloadUrl = feed.getDownload_url();
    viewBinding.backgroundImage.setColorFilter(new LightingColorFilter(0xff828282, 0x000000));
    View header = View.inflate(this, R.layout.onlinefeedview_header, null);
    viewBinding.listView.addHeaderView(header);
    viewBinding.listView.setSelector(android.R.color.transparent);
    viewBinding.listView.setAdapter(new FeedItemlistDescriptionAdapter(this, 0, feed.getItems()));
    TextView description = header.findViewById(R.id.txtvDescription);
    if (StringUtils.isNotBlank(feed.getImageUrl())) {
        Glide.with(this).load(feed.getImageUrl()).apply(new RequestOptions().placeholder(R.color.light_gray).error(R.color.light_gray).diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY).fitCenter().dontAnimate()).into(viewBinding.coverImage);
        Glide.with(this).load(feed.getImageUrl()).apply(new RequestOptions().placeholder(R.color.image_readability_tint).error(R.color.image_readability_tint).diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY).transform(new FastBlurTransformation()).dontAnimate()).into(viewBinding.backgroundImage);
    }
    viewBinding.titleLabel.setText(feed.getTitle());
    viewBinding.authorLabel.setText(feed.getAuthor());
    description.setText(HtmlToPlainText.getPlainText(feed.getDescription()));
    viewBinding.subscribeButton.setOnClickListener(v -> {
        if (feedInFeedlist(feed)) {
            openFeed();
        } else {
            Feed f = new Feed(selectedDownloadUrl, null, feed.getTitle());
            f.setPreferences(feed.getPreferences());
            this.feed = f;
            DownloadService.download(this, false, DownloadRequestCreator.create(f).build());
            didPressSubscribe = true;
            handleUpdatedFeedStatus(feed);
        }
    });
    viewBinding.stopPreviewButton.setOnClickListener(v -> {
        PlaybackPreferences.writeNoMediaPlaying();
        IntentUtils.sendLocalBroadcast(this, PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE);
    });
    if (UserPreferences.isEnableAutodownload()) {
        SharedPreferences preferences = getSharedPreferences(PREFS, MODE_PRIVATE);
        viewBinding.autoDownloadCheckBox.setChecked(preferences.getBoolean(PREF_LAST_AUTO_DOWNLOAD, true));
    }
    final int MAX_LINES_COLLAPSED = 10;
    description.setMaxLines(MAX_LINES_COLLAPSED);
    description.setOnClickListener(v -> {
        if (description.getMaxLines() > MAX_LINES_COLLAPSED) {
            description.setMaxLines(MAX_LINES_COLLAPSED);
        } else {
            description.setMaxLines(2000);
        }
    });
    if (alternateFeedUrls.isEmpty()) {
        viewBinding.alternateUrlsSpinner.setVisibility(View.GONE);
    } else {
        viewBinding.alternateUrlsSpinner.setVisibility(View.VISIBLE);
        final List<String> alternateUrlsList = new ArrayList<>();
        final List<String> alternateUrlsTitleList = new ArrayList<>();
        alternateUrlsList.add(feed.getDownload_url());
        alternateUrlsTitleList.add(feed.getTitle());
        alternateUrlsList.addAll(alternateFeedUrls.keySet());
        for (String url : alternateFeedUrls.keySet()) {
            alternateUrlsTitleList.add(alternateFeedUrls.get(url));
        }
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.alternate_urls_item, alternateUrlsTitleList) {

            @Override
            public View getDropDownView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
                // reusing the old view causes a visual bug on Android <= 10
                return super.getDropDownView(position, null, parent);
            }
        };
        adapter.setDropDownViewResource(R.layout.alternate_urls_dropdown_item);
        viewBinding.alternateUrlsSpinner.setAdapter(adapter);
        viewBinding.alternateUrlsSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                selectedDownloadUrl = alternateUrlsList.get(position);
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {
            }
        });
    }
    handleUpdatedFeedStatus(feed);
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) SharedPreferences(android.content.SharedPreferences) ViewGroup(android.view.ViewGroup) ArrayList(java.util.ArrayList) SpannableString(android.text.SpannableString) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) FastBlurTransformation(de.danoeh.antennapod.core.glide.FastBlurTransformation) FeedItemlistDescriptionAdapter(de.danoeh.antennapod.adapter.FeedItemlistDescriptionAdapter) NonNull(androidx.annotation.NonNull) LightingColorFilter(android.graphics.LightingColorFilter) TextView(android.widget.TextView) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter) Nullable(androidx.annotation.Nullable) Feed(de.danoeh.antennapod.model.feed.Feed)

Example 32 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project AntennaPod by AntennaPod.

the class ChaptersListAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(@NonNull ChapterHolder holder, int position) {
    Chapter sc = getItem(position);
    if (sc == null) {
        holder.title.setText("Error");
        return;
    }
    holder.title.setText(sc.getTitle());
    holder.start.setText(Converter.getDurationStringLong((int) sc.getStart()));
    long duration;
    if (position + 1 < media.getChapters().size()) {
        duration = media.getChapters().get(position + 1).getStart() - sc.getStart();
    } else {
        duration = media.getDuration() - sc.getStart();
    }
    holder.duration.setText(context.getString(R.string.chapter_duration, Converter.getDurationStringLocalized(context, (int) duration)));
    if (TextUtils.isEmpty(sc.getLink())) {
        holder.link.setVisibility(View.GONE);
    } else {
        holder.link.setVisibility(View.VISIBLE);
        holder.link.setText(sc.getLink());
        holder.link.setOnClickListener(v -> IntentUtils.openInBrowser(context, sc.getLink()));
    }
    holder.secondaryActionIcon.setImageResource(R.drawable.ic_play_48dp);
    holder.secondaryActionButton.setContentDescription(context.getString(R.string.play_chapter));
    holder.secondaryActionButton.setOnClickListener(v -> {
        if (callback != null) {
            callback.onPlayChapterButtonClicked(position);
        }
    });
    if (position == currentChapterIndex) {
        int playingBackGroundColor = ThemeUtils.getColorFromAttr(context, R.attr.currently_playing_background);
        holder.itemView.setBackgroundColor(playingBackGroundColor);
        float progress = ((float) (currentChapterPosition - sc.getStart())) / duration;
        progress = Math.max(progress, CircularProgressBar.MINIMUM_PERCENTAGE);
        progress = Math.min(progress, CircularProgressBar.MAXIMUM_PERCENTAGE);
        holder.progressBar.setPercentage(progress, position);
        holder.secondaryActionIcon.setImageResource(R.drawable.ic_replay);
    } else {
        holder.itemView.setBackgroundColor(ContextCompat.getColor(context, android.R.color.transparent));
        holder.progressBar.setPercentage(0, null);
    }
    if (hasImages) {
        holder.image.setVisibility(View.VISIBLE);
        if (TextUtils.isEmpty(sc.getImageUrl())) {
            Glide.with(context).clear(holder.image);
        } else {
            Glide.with(context).load(EmbeddedChapterImage.getModelFor(media, position)).apply(new RequestOptions().diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY).dontAnimate().transforms(new FitCenter(), new RoundedCorners((int) (4 * context.getResources().getDisplayMetrics().density)))).into(holder.image);
        }
    } else {
        holder.image.setVisibility(View.GONE);
    }
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) Chapter(de.danoeh.antennapod.model.feed.Chapter) FitCenter(com.bumptech.glide.load.resource.bitmap.FitCenter) RoundedCorners(com.bumptech.glide.load.resource.bitmap.RoundedCorners)

Example 33 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project AntennaPod by AntennaPod.

the class CoverLoader method load.

public void load() {
    CoverTarget coverTarget = new CoverTarget(txtvPlaceholder, imgvCover, textAndImageCombined);
    if (resource != 0) {
        Glide.with(activity).clear(coverTarget);
        imgvCover.setImageResource(resource);
        CoverTarget.setPlaceholderVisibility(txtvPlaceholder, textAndImageCombined, null);
        return;
    }
    RequestOptions options = new RequestOptions().diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY).fitCenter().dontAnimate();
    RequestBuilder<PaletteBitmap> builder = Glide.with(activity).as(PaletteBitmap.class).load(uri).apply(options);
    if (fallbackUri != null && txtvPlaceholder != null && imgvCover != null) {
        builder = builder.error(Glide.with(activity).as(PaletteBitmap.class).load(fallbackUri).apply(options));
    }
    builder.into(coverTarget);
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) PaletteBitmap(de.danoeh.antennapod.core.glide.PaletteBitmap)

Example 34 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project AntennaPod by AntennaPod.

the class FeedDiscoverAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    Holder holder;
    if (convertView == null) {
        convertView = View.inflate(mainActivityRef.get(), R.layout.quick_feed_discovery_item, null);
        holder = new Holder();
        holder.imageView = convertView.findViewById(R.id.discovery_cover);
        convertView.setTag(holder);
    } else {
        holder = (Holder) convertView.getTag();
    }
    final PodcastSearchResult podcast = getItem(position);
    holder.imageView.setContentDescription(podcast.title);
    Glide.with(mainActivityRef.get()).load(podcast.imageUrl).apply(new RequestOptions().placeholder(R.color.light_gray).fitCenter().dontAnimate()).into(holder.imageView);
    return convertView;
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) PodcastSearchResult(de.danoeh.antennapod.discovery.PodcastSearchResult)

Example 35 with RequestOptions

use of com.bumptech.glide.request.RequestOptions in project AntennaPod by AntennaPod.

the class SimpleIconListAdapter method getView.

@Override
public View getView(int position, View view, ViewGroup parent) {
    if (view == null) {
        view = View.inflate(context, R.layout.simple_icon_list_item, null);
    }
    ListItem item = listItems.get(position);
    ((TextView) view.findViewById(R.id.title)).setText(item.title);
    ((TextView) view.findViewById(R.id.subtitle)).setText(item.subtitle);
    Glide.with(context).load(item.imageUrl).apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.NONE).fitCenter().dontAnimate()).into(((ImageView) view.findViewById(R.id.icon)));
    return view;
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) TextView(android.widget.TextView) ImageView(android.widget.ImageView)

Aggregations

RequestOptions (com.bumptech.glide.request.RequestOptions)104 ImageView (android.widget.ImageView)23 Drawable (android.graphics.drawable.Drawable)18 View (android.view.View)18 TextView (android.widget.TextView)13 Bitmap (android.graphics.Bitmap)11 File (java.io.File)10 BitmapDrawable (android.graphics.drawable.BitmapDrawable)9 ColorDrawable (android.graphics.drawable.ColorDrawable)7 Uri (android.net.Uri)7 DataSource (com.bumptech.glide.load.DataSource)6 GlideException (com.bumptech.glide.load.engine.GlideException)6 Context (android.content.Context)5 Intent (android.content.Intent)5 RecyclerView (android.support.v7.widget.RecyclerView)5 FitCenter (com.bumptech.glide.load.resource.bitmap.FitCenter)5 RoundedCorners (com.bumptech.glide.load.resource.bitmap.RoundedCorners)5 Test (org.junit.Test)5 Activity (android.app.Activity)3 LayoutInflater (android.view.LayoutInflater)3