Skip to content

Commit

Permalink
Use Glide with Caching instead of Picasso
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp0002 committed Dec 16, 2024
1 parent b882d43 commit f5103b5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dependencies {
implementation 'com.google.android.gms:play-services-nearby:18.0.0'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.9'
implementation 'androidx.leanback:leanback:1.0.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.github.bumptech.glide:glide:4.16.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.material:material:1.7.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.egeniq.androidtvprogramguide.ProgramGuideHolder
import com.egeniq.androidtvprogramguide.ProgramGuideListAdapter
import com.egeniq.androidtvprogramguide.ProgramGuideManager
import com.egeniq.androidtvprogramguide.entity.ProgramGuideChannel
import com.egeniq.androidtvprogramguide.entity.ProgramGuideSchedule
import com.squareup.picasso.Picasso
import de.hahnphilipp.watchwithfritzbox.R
import de.hahnphilipp.watchwithfritzbox.utils.ChannelUtils
import java.util.*
Expand Down Expand Up @@ -152,10 +153,10 @@ internal class ProgramGuideRowAdapter(
if (imageUrl == null) {
channelLogoView.visibility = View.GONE
} else {
Picasso.get()
.load(Uri.parse(imageUrl))
//.centerInside()
.into(channelLogoView)
Glide.with(this.itemView.context)
.load(Uri.parse(imageUrl))
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(channelLogoView)
channelLogoView.visibility = View.VISIBLE
}
channelNameView.text = channel.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.squareup.picasso.Picasso;

import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
Expand Down Expand Up @@ -68,7 +66,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat

recyclerView = view.findViewById(R.id.tvoverlayrecycler);

tvOverlayRecyclerAdapter = new TVChannelListOverlayRecyclerAdapter(this, ChannelUtils.getAllChannels(getContext()), Picasso.get(), recyclerView);
tvOverlayRecyclerAdapter = new TVChannelListOverlayRecyclerAdapter(this, ChannelUtils.getAllChannels(getContext()), recyclerView);
llm = new LinearLayoutManager(context);
recyclerView.setLayoutManager(llm);
recyclerView.setAdapter(tvOverlayRecyclerAdapter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.squareup.picasso.Picasso;

import de.hahnphilipp.watchwithfritzbox.R;
import de.hahnphilipp.watchwithfritzbox.utils.ChannelUtils;
import de.hahnphilipp.watchwithfritzbox.utils.IPUtils;
Expand Down Expand Up @@ -54,7 +52,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat

recyclerView = view.findViewById(R.id.tvoverlayrecycler);

tvOverlayRecyclerAdapter = new TVChannelListOverlayRecyclerAdapter(this, ChannelUtils.getAllChannels(getContext()), Picasso.get(), recyclerView);
tvOverlayRecyclerAdapter = new TVChannelListOverlayRecyclerAdapter(this, ChannelUtils.getAllChannels(getContext()), recyclerView);
llm = new LinearLayoutManager(context);
recyclerView.setLayoutManager(llm);
recyclerView.setAdapter(tvOverlayRecyclerAdapter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.RecyclerView;

import com.squareup.picasso.Picasso;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;

import java.util.ArrayList;

Expand All @@ -30,14 +31,12 @@ public class TVChannelListOverlayRecyclerAdapter extends RecyclerView.Adapter<TV

public ArrayList<ChannelUtils.Channel> objects;
private Fragment context;
public Picasso picasso;
public int selectedChannel = -1;
private RecyclerView recyclerView;

public TVChannelListOverlayRecyclerAdapter(Fragment context, ArrayList<ChannelUtils.Channel> objects, Picasso picasso, RecyclerView recyclerView) {
public TVChannelListOverlayRecyclerAdapter(Fragment context, ArrayList<ChannelUtils.Channel> objects, RecyclerView recyclerView) {
this.objects = objects;
this.context = context;
this.picasso = picasso;
this.recyclerView = recyclerView;
}

Expand All @@ -51,6 +50,7 @@ public ChannelInfoViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
@Override
public void onBindViewHolder(final ChannelInfoViewHolder holder, final int position) {
//holder.setIsRecyclable(false);
Glide.with(context).clear(holder.channelIcon);
CardView card = holder.cardView;

final ChannelUtils.Channel item = objects.get(position);
Expand All @@ -74,8 +74,9 @@ public void onBindViewHolder(final ChannelInfoViewHolder holder, final int posit
holder.channelEvent.setVisibility(View.GONE);
}

Picasso.get()
Glide.with(context)
.load(Uri.parse(ChannelUtils.getIconURL(item)))
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(holder.channelIcon);

holder.cardView.setOnFocusChangeListener((v, hasFocus) -> {
Expand Down

0 comments on commit f5103b5

Please sign in to comment.