Skip to content

Commit

Permalink
Merge pull request #1410 from nextcloud/noStaticFavIconHandler
Browse files Browse the repository at this point in the history
Use one Glide instance per NewsListRecyclerAdapter
  • Loading branch information
David-Development authored Apr 1, 2024
2 parents 8bad749 + 8d97c0a commit 525da96
Show file tree
Hide file tree
Showing 17 changed files with 1,350 additions and 566 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

Expand All @@ -32,6 +35,7 @@
import de.luhmer.owncloudnewsreader.databinding.SubscriptionDetailListItemWebLayoutBinding;
import de.luhmer.owncloudnewsreader.events.podcast.PodcastCompletedEvent;
import de.luhmer.owncloudnewsreader.helper.AsyncTaskHelper;
import de.luhmer.owncloudnewsreader.helper.FavIconHandler;
import de.luhmer.owncloudnewsreader.helper.PostDelayHandler;
import de.luhmer.owncloudnewsreader.helper.StopWatch;
import de.luhmer.owncloudnewsreader.interfaces.IPlayPausePodcastClicked;
Expand All @@ -43,6 +47,8 @@ public class NewsListRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.V
@SuppressWarnings("FieldCanBeLocal")
private final int VIEW_ITEM = 1; // Item
private final int VIEW_PROG = 0; // Progress
private final FavIconHandler faviconHandler;
private final RequestManager glide;

private long idOfCurrentlyPlayedPodcast = -1;

Expand Down Expand Up @@ -70,6 +76,8 @@ public NewsListRecyclerAdapter(FragmentActivity activity, RecyclerView recyclerV
pDelayHandler = postDelayHandler;

dbConn = new DatabaseConnectionOrm(activity);
faviconHandler = new FavIconHandler(activity);
glide = Glide.with(activity);
setHasStableIds(true);

EventBus.getDefault().register(this);
Expand Down Expand Up @@ -170,25 +178,60 @@ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int
RssItemViewHolder viewHolder = null;
switch (Integer.parseInt(mPrefs.getString(SettingsActivity.SP_FEED_LIST_LAYOUT, "0"))) {
case 0:
viewHolder = new RssItemThumbnailViewHolder(SubscriptionDetailListItemThumbnailBinding.inflate(LayoutInflater.from(context), parent, false), mPrefs);
viewHolder = new RssItemThumbnailViewHolder(
SubscriptionDetailListItemThumbnailBinding.inflate(LayoutInflater.from(context), parent, false),
faviconHandler,
glide,
mPrefs
);
break;
case 1:
viewHolder = new RssItemTextViewHolder(SubscriptionDetailListItemTextBinding.inflate(LayoutInflater.from(context), parent, false), mPrefs);
viewHolder = new RssItemTextViewHolder(
SubscriptionDetailListItemTextBinding.inflate(LayoutInflater.from(context), parent, false),
faviconHandler,
glide,
mPrefs
);
break;
case 3:
viewHolder = new RssItemFullTextViewHolder(SubscriptionDetailListItemTextBinding.inflate(LayoutInflater.from(context), parent, false), mPrefs);
viewHolder = new RssItemFullTextViewHolder(
SubscriptionDetailListItemTextBinding.inflate(LayoutInflater.from(context), parent, false),
faviconHandler,
glide,
mPrefs
);
break;
case 2:
viewHolder = new RssItemWebViewHolder(SubscriptionDetailListItemWebLayoutBinding.inflate(LayoutInflater.from(context), parent, false), mPrefs);
viewHolder = new RssItemWebViewHolder(
SubscriptionDetailListItemWebLayoutBinding.inflate(LayoutInflater.from(context), parent, false),
faviconHandler,
glide,
mPrefs
);
break;
case 4:
viewHolder = new RssItemCardViewHolder(SubscriptionDetailListItemCardViewBinding.inflate(LayoutInflater.from(context), parent, false), mPrefs);
viewHolder = new RssItemCardViewHolder(
SubscriptionDetailListItemCardViewBinding.inflate(LayoutInflater.from(context), parent, false),
faviconHandler,
glide,
mPrefs
);
break;
case 5:
viewHolder = new RssItemHeadlineViewHolder(SubscriptionDetailListItemHeadlineBinding.inflate(LayoutInflater.from(context), parent, false), mPrefs);
viewHolder = new RssItemHeadlineViewHolder(
SubscriptionDetailListItemHeadlineBinding.inflate(LayoutInflater.from(context), parent, false),
faviconHandler,
glide,
mPrefs
);
break;
case 6:
viewHolder = new RssItemHeadlineThumbnailViewHolder(SubscriptionDetailListItemHeadlineThumbnailBinding.inflate(LayoutInflater.from(context), parent, false), mPrefs);
viewHolder = new RssItemHeadlineThumbnailViewHolder(
SubscriptionDetailListItemHeadlineThumbnailBinding.inflate(LayoutInflater.from(context), parent, false),
faviconHandler,
glide,
mPrefs
);
break;
default:
Log.e(TAG, "Unknown layout..");
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package de.luhmer.owncloudnewsreader.adapter

import android.content.SharedPreferences
import android.view.View
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.ProgressBar
import android.widget.TextView
import androidx.annotation.CallSuper
import com.bumptech.glide.RequestManager
import de.luhmer.owncloudnewsreader.database.model.RssItem
import de.luhmer.owncloudnewsreader.databinding.SubscriptionDetailListItemCardViewBinding
import de.luhmer.owncloudnewsreader.helper.FavIconHandler

class RssItemCardViewHolder internal constructor(
binding: SubscriptionDetailListItemCardViewBinding,
faviconHandler: FavIconHandler,
glide: RequestManager,
sharedPreferences: SharedPreferences,
) : RssItemViewHolder<SubscriptionDetailListItemCardViewBinding>(
binding,
faviconHandler,
glide,
sharedPreferences,
) {
override fun getImageViewFavIcon(): ImageView {
return binding.imgViewFavIcon
}

override fun getStar(): ImageView {
return binding.starImageview
}

override fun getPlayPausePodcastButton(): ImageView {
return binding.podcastWrapper.btnPlayPausePodcast
}

override fun getColorFeed(): View {
return binding.colorLineFeed
}

override fun getTextViewTitle(): TextView {
return binding.tvSubscription
}

override fun getTextViewSummary(): TextView {
return binding.summary
}

override fun getTextViewBody(): TextView {
return binding.body
}

override fun getTextViewItemDate(): TextView {
return binding.tvItemDate
}

override fun getPlayPausePodcastWrapper(): FrameLayout {
return binding.podcastWrapper.flPlayPausePodcastWrapper
}

override fun getPodcastDownloadProgress(): ProgressBar {
return binding.podcastWrapper.podcastDownloadProgress
}

@CallSuper
override fun bind(rssItem: RssItem) {
super.bind(rssItem)
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package de.luhmer.owncloudnewsreader.adapter

import android.content.SharedPreferences
import com.bumptech.glide.RequestManager
import de.luhmer.owncloudnewsreader.databinding.SubscriptionDetailListItemTextBinding
import de.luhmer.owncloudnewsreader.helper.FavIconHandler

class RssItemFullTextViewHolder internal constructor(
binding: SubscriptionDetailListItemTextBinding,
faviconHandler: FavIconHandler,
glide: RequestManager,
sharedPreferences: SharedPreferences,
) : RssItemTextViewHolder(binding, faviconHandler, glide, sharedPreferences)

This file was deleted.

Loading

0 comments on commit 525da96

Please sign in to comment.