Picasso loads 6 images only from cache
up vote
0
down vote
favorite
For some reason, Picasso is displaying only 6 images out of 20. It shows the first 6 images and then repeats them. I am getting the images from the web.
Any idea?
Picasso.get().load(response.body().getMediaDetails()
.getSizes().getFull().getSourceUrl())
.fetch(new com.squareup.picasso.Callback() {
@Override
public void onSuccess() {}
@Override
public void onError(Exception e) {
// Try again online if cache failed
Picasso.get()
.load(response.body().getMediaDetails().getSizes().getFull().getSourceUrl())
.placeholder(R.drawable.test_img_size)
.error(R.drawable.test_img_size)
.into(imageView);
}
});
ViewAdapter.java
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.support.v7.widget.CardView;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class RecyclerViewAdapter extends
RecyclerView.Adapter<RecyclerView.ViewHolder> {
private ArrayList<Model> dataset;
private Context mContext;
private ArrayList<Model> list;
private RecyclerViewAdapter adapter;
private RecyclerView recyclerView;
private LinearLayoutManager mLayoutManager;
public static List<WPPost> mListPost;
ArrayList<String> imagepath = new ArrayList<>();
private String baseURL = "https://www.myfitbytes.com/";
public RecyclerViewAdapter(ArrayList<Model> mlist, Context context) {
this.dataset = mlist;
this.mContext = context;
}
public static class ImageTypeViewHolder extends RecyclerView.ViewHolder{
TextView title, subtitle, date;
ImageView imageView;
CardView cardview;
public ImageTypeViewHolder(View itemView) {
super(itemView);
this.title = (TextView) itemView.findViewById(R.id.title);
//this.subtitle = (TextView) itemView.findViewById(R.id.subtitle);
this.date = (TextView) itemView.findViewById(R.id.date);
this.imageView = (ImageView) itemView.findViewById(R.id.Icon);
this.cardview = (CardView) itemView.findViewById(R.id.cardview);
}
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from( parent.getContext()).inflate(R.layout.postdetails, parent, false);
return new ImageTypeViewHolder(view) ;
}
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) {
final Model object = dataset.get(position);
// Log.d("RecyclerViewAdapter", "IMAGE="+object.Image);
imagepath.add(position, "");
if (Build.VERSION.SDK_INT >= 24)
{
//( (ImageTypeViewHolder) holder).subtitle.setText(Html.fromHtml(object.subtitle , Html.FROM_HTML_MODE_LEGACY));
( (ImageTypeViewHolder) holder).title.setText( Html.fromHtml(object.title , Html.FROM_HTML_MODE_LEGACY) );
( (ImageTypeViewHolder) holder).date.setText( Html.fromHtml(object.date , Html.FROM_HTML_MODE_LEGACY) );
}
else
{
//( (ImageTypeViewHolder) holder).subtitle.setText(Html.fromHtml(object.subtitle ));
( (ImageTypeViewHolder) holder).title.setText( Html.fromHtml(object.title ));
( (ImageTypeViewHolder) holder).date.setText( Html.fromHtml(object.date ));
}
( (ImageTypeViewHolder) holder).imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, WPPostDetails.class);
intent.putExtra("itemPosition", position);
mContext.startActivity(intent);
}
});
try {
getthumbnail(object.Image, ( (ImageTypeViewHolder) holder).imageView, position);
}catch (Exception e){
// Log.e("adapter ","failed to get image "+e.toString() );
}
/// dataset.get(position)
}
public void getthumbnail(String imageurl, final ImageView imageView, final int position){
ServiceWrapper serviceWrapper = new ServiceWrapper(null);
Call<GetThumbnail> call = serviceWrapper.getThumbnailCall(imageurl);
call.enqueue(new Callback<GetThumbnail>() {
@Override
public void onResponse(Call<GetThumbnail> call, final Response<GetThumbnail> response) {
if (response.body() != null && response.isSuccessful()) {
try {
if (response.body().getMediaDetails()!=null){
// Log.e("recycler adapter", " image is here-- " + response.body().getMediaDetails().getSizes().getThumbnail().getSourceUrl());
// Log.e("Full IMG SIZE - ", " THIS IS FULL IMAGE URL-- " + response.body().getMediaDetails().getSizes().getFull().getSourceUrl());
imagepath.add(position, response.body().getMediaDetails().getSizes().getFull().getSourceUrl());
Picasso.get()
.load(response.body().getMediaDetails().getSizes().getFull().getSourceUrl())
.fetch(new com.squareup.picasso.Callback() {
@Override
public void onSuccess() {
}
@Override
public void onError(Exception e) {
// Try again online if cache failed
Picasso.get()
.load(response.body().getMediaDetails().getSizes().getFull().getSourceUrl())
.placeholder(R.drawable.test_img_size)
.error(R.drawable.test_img_size)
.into(imageView);
}
});
//Glide.with(mContext)
//.load(response.body().getMediaDetails().getSizes().getFull().getSourceUrl())
//.downloadOnly(new SimpleTarget<File>() {
//@Override
//public void onResourceReady(File resource, GlideAnimation<? super File>
//glideAnimation) {
//Glide.with(mContext)
//.load(response.body().getMediaDetails().getSizes().getFull().getSourceUrl())
//.diskCacheStrategy(DiskCacheStrategy.SOURCE)
//.into(imageView);
//}
//});
}else {
}
}catch (Exception e){
// Log.e("adapter", "fail not media tag "+ e.toString());
}
}
}
@Override
public void onFailure(Call<GetThumbnail> call, Throwable t) {
// Log.e("adapter", " faile image "+t.toString());
}
});
}
@Override
public int getItemCount() {
return dataset.size() ;
}
}
So, as some suggest and as you may see, I tried to use glade but it didn't work.
The problem is the same, when the user scrolls up and down the images re-load over and over again. And, some time it only cache 6 images out of 20 (it should cache every image in this way the app will show the image that are in the cache and not fetching in from the web)
add a comment |
up vote
0
down vote
favorite
For some reason, Picasso is displaying only 6 images out of 20. It shows the first 6 images and then repeats them. I am getting the images from the web.
Any idea?
Picasso.get().load(response.body().getMediaDetails()
.getSizes().getFull().getSourceUrl())
.fetch(new com.squareup.picasso.Callback() {
@Override
public void onSuccess() {}
@Override
public void onError(Exception e) {
// Try again online if cache failed
Picasso.get()
.load(response.body().getMediaDetails().getSizes().getFull().getSourceUrl())
.placeholder(R.drawable.test_img_size)
.error(R.drawable.test_img_size)
.into(imageView);
}
});
ViewAdapter.java
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.support.v7.widget.CardView;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class RecyclerViewAdapter extends
RecyclerView.Adapter<RecyclerView.ViewHolder> {
private ArrayList<Model> dataset;
private Context mContext;
private ArrayList<Model> list;
private RecyclerViewAdapter adapter;
private RecyclerView recyclerView;
private LinearLayoutManager mLayoutManager;
public static List<WPPost> mListPost;
ArrayList<String> imagepath = new ArrayList<>();
private String baseURL = "https://www.myfitbytes.com/";
public RecyclerViewAdapter(ArrayList<Model> mlist, Context context) {
this.dataset = mlist;
this.mContext = context;
}
public static class ImageTypeViewHolder extends RecyclerView.ViewHolder{
TextView title, subtitle, date;
ImageView imageView;
CardView cardview;
public ImageTypeViewHolder(View itemView) {
super(itemView);
this.title = (TextView) itemView.findViewById(R.id.title);
//this.subtitle = (TextView) itemView.findViewById(R.id.subtitle);
this.date = (TextView) itemView.findViewById(R.id.date);
this.imageView = (ImageView) itemView.findViewById(R.id.Icon);
this.cardview = (CardView) itemView.findViewById(R.id.cardview);
}
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from( parent.getContext()).inflate(R.layout.postdetails, parent, false);
return new ImageTypeViewHolder(view) ;
}
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) {
final Model object = dataset.get(position);
// Log.d("RecyclerViewAdapter", "IMAGE="+object.Image);
imagepath.add(position, "");
if (Build.VERSION.SDK_INT >= 24)
{
//( (ImageTypeViewHolder) holder).subtitle.setText(Html.fromHtml(object.subtitle , Html.FROM_HTML_MODE_LEGACY));
( (ImageTypeViewHolder) holder).title.setText( Html.fromHtml(object.title , Html.FROM_HTML_MODE_LEGACY) );
( (ImageTypeViewHolder) holder).date.setText( Html.fromHtml(object.date , Html.FROM_HTML_MODE_LEGACY) );
}
else
{
//( (ImageTypeViewHolder) holder).subtitle.setText(Html.fromHtml(object.subtitle ));
( (ImageTypeViewHolder) holder).title.setText( Html.fromHtml(object.title ));
( (ImageTypeViewHolder) holder).date.setText( Html.fromHtml(object.date ));
}
( (ImageTypeViewHolder) holder).imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, WPPostDetails.class);
intent.putExtra("itemPosition", position);
mContext.startActivity(intent);
}
});
try {
getthumbnail(object.Image, ( (ImageTypeViewHolder) holder).imageView, position);
}catch (Exception e){
// Log.e("adapter ","failed to get image "+e.toString() );
}
/// dataset.get(position)
}
public void getthumbnail(String imageurl, final ImageView imageView, final int position){
ServiceWrapper serviceWrapper = new ServiceWrapper(null);
Call<GetThumbnail> call = serviceWrapper.getThumbnailCall(imageurl);
call.enqueue(new Callback<GetThumbnail>() {
@Override
public void onResponse(Call<GetThumbnail> call, final Response<GetThumbnail> response) {
if (response.body() != null && response.isSuccessful()) {
try {
if (response.body().getMediaDetails()!=null){
// Log.e("recycler adapter", " image is here-- " + response.body().getMediaDetails().getSizes().getThumbnail().getSourceUrl());
// Log.e("Full IMG SIZE - ", " THIS IS FULL IMAGE URL-- " + response.body().getMediaDetails().getSizes().getFull().getSourceUrl());
imagepath.add(position, response.body().getMediaDetails().getSizes().getFull().getSourceUrl());
Picasso.get()
.load(response.body().getMediaDetails().getSizes().getFull().getSourceUrl())
.fetch(new com.squareup.picasso.Callback() {
@Override
public void onSuccess() {
}
@Override
public void onError(Exception e) {
// Try again online if cache failed
Picasso.get()
.load(response.body().getMediaDetails().getSizes().getFull().getSourceUrl())
.placeholder(R.drawable.test_img_size)
.error(R.drawable.test_img_size)
.into(imageView);
}
});
//Glide.with(mContext)
//.load(response.body().getMediaDetails().getSizes().getFull().getSourceUrl())
//.downloadOnly(new SimpleTarget<File>() {
//@Override
//public void onResourceReady(File resource, GlideAnimation<? super File>
//glideAnimation) {
//Glide.with(mContext)
//.load(response.body().getMediaDetails().getSizes().getFull().getSourceUrl())
//.diskCacheStrategy(DiskCacheStrategy.SOURCE)
//.into(imageView);
//}
//});
}else {
}
}catch (Exception e){
// Log.e("adapter", "fail not media tag "+ e.toString());
}
}
}
@Override
public void onFailure(Call<GetThumbnail> call, Throwable t) {
// Log.e("adapter", " faile image "+t.toString());
}
});
}
@Override
public int getItemCount() {
return dataset.size() ;
}
}
So, as some suggest and as you may see, I tried to use glade but it didn't work.
The problem is the same, when the user scrolls up and down the images re-load over and over again. And, some time it only cache 6 images out of 20 (it should cache every image in this way the app will show the image that are in the cache and not fetching in from the web)
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
For some reason, Picasso is displaying only 6 images out of 20. It shows the first 6 images and then repeats them. I am getting the images from the web.
Any idea?
Picasso.get().load(response.body().getMediaDetails()
.getSizes().getFull().getSourceUrl())
.fetch(new com.squareup.picasso.Callback() {
@Override
public void onSuccess() {}
@Override
public void onError(Exception e) {
// Try again online if cache failed
Picasso.get()
.load(response.body().getMediaDetails().getSizes().getFull().getSourceUrl())
.placeholder(R.drawable.test_img_size)
.error(R.drawable.test_img_size)
.into(imageView);
}
});
ViewAdapter.java
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.support.v7.widget.CardView;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class RecyclerViewAdapter extends
RecyclerView.Adapter<RecyclerView.ViewHolder> {
private ArrayList<Model> dataset;
private Context mContext;
private ArrayList<Model> list;
private RecyclerViewAdapter adapter;
private RecyclerView recyclerView;
private LinearLayoutManager mLayoutManager;
public static List<WPPost> mListPost;
ArrayList<String> imagepath = new ArrayList<>();
private String baseURL = "https://www.myfitbytes.com/";
public RecyclerViewAdapter(ArrayList<Model> mlist, Context context) {
this.dataset = mlist;
this.mContext = context;
}
public static class ImageTypeViewHolder extends RecyclerView.ViewHolder{
TextView title, subtitle, date;
ImageView imageView;
CardView cardview;
public ImageTypeViewHolder(View itemView) {
super(itemView);
this.title = (TextView) itemView.findViewById(R.id.title);
//this.subtitle = (TextView) itemView.findViewById(R.id.subtitle);
this.date = (TextView) itemView.findViewById(R.id.date);
this.imageView = (ImageView) itemView.findViewById(R.id.Icon);
this.cardview = (CardView) itemView.findViewById(R.id.cardview);
}
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from( parent.getContext()).inflate(R.layout.postdetails, parent, false);
return new ImageTypeViewHolder(view) ;
}
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) {
final Model object = dataset.get(position);
// Log.d("RecyclerViewAdapter", "IMAGE="+object.Image);
imagepath.add(position, "");
if (Build.VERSION.SDK_INT >= 24)
{
//( (ImageTypeViewHolder) holder).subtitle.setText(Html.fromHtml(object.subtitle , Html.FROM_HTML_MODE_LEGACY));
( (ImageTypeViewHolder) holder).title.setText( Html.fromHtml(object.title , Html.FROM_HTML_MODE_LEGACY) );
( (ImageTypeViewHolder) holder).date.setText( Html.fromHtml(object.date , Html.FROM_HTML_MODE_LEGACY) );
}
else
{
//( (ImageTypeViewHolder) holder).subtitle.setText(Html.fromHtml(object.subtitle ));
( (ImageTypeViewHolder) holder).title.setText( Html.fromHtml(object.title ));
( (ImageTypeViewHolder) holder).date.setText( Html.fromHtml(object.date ));
}
( (ImageTypeViewHolder) holder).imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, WPPostDetails.class);
intent.putExtra("itemPosition", position);
mContext.startActivity(intent);
}
});
try {
getthumbnail(object.Image, ( (ImageTypeViewHolder) holder).imageView, position);
}catch (Exception e){
// Log.e("adapter ","failed to get image "+e.toString() );
}
/// dataset.get(position)
}
public void getthumbnail(String imageurl, final ImageView imageView, final int position){
ServiceWrapper serviceWrapper = new ServiceWrapper(null);
Call<GetThumbnail> call = serviceWrapper.getThumbnailCall(imageurl);
call.enqueue(new Callback<GetThumbnail>() {
@Override
public void onResponse(Call<GetThumbnail> call, final Response<GetThumbnail> response) {
if (response.body() != null && response.isSuccessful()) {
try {
if (response.body().getMediaDetails()!=null){
// Log.e("recycler adapter", " image is here-- " + response.body().getMediaDetails().getSizes().getThumbnail().getSourceUrl());
// Log.e("Full IMG SIZE - ", " THIS IS FULL IMAGE URL-- " + response.body().getMediaDetails().getSizes().getFull().getSourceUrl());
imagepath.add(position, response.body().getMediaDetails().getSizes().getFull().getSourceUrl());
Picasso.get()
.load(response.body().getMediaDetails().getSizes().getFull().getSourceUrl())
.fetch(new com.squareup.picasso.Callback() {
@Override
public void onSuccess() {
}
@Override
public void onError(Exception e) {
// Try again online if cache failed
Picasso.get()
.load(response.body().getMediaDetails().getSizes().getFull().getSourceUrl())
.placeholder(R.drawable.test_img_size)
.error(R.drawable.test_img_size)
.into(imageView);
}
});
//Glide.with(mContext)
//.load(response.body().getMediaDetails().getSizes().getFull().getSourceUrl())
//.downloadOnly(new SimpleTarget<File>() {
//@Override
//public void onResourceReady(File resource, GlideAnimation<? super File>
//glideAnimation) {
//Glide.with(mContext)
//.load(response.body().getMediaDetails().getSizes().getFull().getSourceUrl())
//.diskCacheStrategy(DiskCacheStrategy.SOURCE)
//.into(imageView);
//}
//});
}else {
}
}catch (Exception e){
// Log.e("adapter", "fail not media tag "+ e.toString());
}
}
}
@Override
public void onFailure(Call<GetThumbnail> call, Throwable t) {
// Log.e("adapter", " faile image "+t.toString());
}
});
}
@Override
public int getItemCount() {
return dataset.size() ;
}
}
So, as some suggest and as you may see, I tried to use glade but it didn't work.
The problem is the same, when the user scrolls up and down the images re-load over and over again. And, some time it only cache 6 images out of 20 (it should cache every image in this way the app will show the image that are in the cache and not fetching in from the web)
For some reason, Picasso is displaying only 6 images out of 20. It shows the first 6 images and then repeats them. I am getting the images from the web.
Any idea?
Picasso.get().load(response.body().getMediaDetails()
.getSizes().getFull().getSourceUrl())
.fetch(new com.squareup.picasso.Callback() {
@Override
public void onSuccess() {}
@Override
public void onError(Exception e) {
// Try again online if cache failed
Picasso.get()
.load(response.body().getMediaDetails().getSizes().getFull().getSourceUrl())
.placeholder(R.drawable.test_img_size)
.error(R.drawable.test_img_size)
.into(imageView);
}
});
ViewAdapter.java
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.support.v7.widget.CardView;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class RecyclerViewAdapter extends
RecyclerView.Adapter<RecyclerView.ViewHolder> {
private ArrayList<Model> dataset;
private Context mContext;
private ArrayList<Model> list;
private RecyclerViewAdapter adapter;
private RecyclerView recyclerView;
private LinearLayoutManager mLayoutManager;
public static List<WPPost> mListPost;
ArrayList<String> imagepath = new ArrayList<>();
private String baseURL = "https://www.myfitbytes.com/";
public RecyclerViewAdapter(ArrayList<Model> mlist, Context context) {
this.dataset = mlist;
this.mContext = context;
}
public static class ImageTypeViewHolder extends RecyclerView.ViewHolder{
TextView title, subtitle, date;
ImageView imageView;
CardView cardview;
public ImageTypeViewHolder(View itemView) {
super(itemView);
this.title = (TextView) itemView.findViewById(R.id.title);
//this.subtitle = (TextView) itemView.findViewById(R.id.subtitle);
this.date = (TextView) itemView.findViewById(R.id.date);
this.imageView = (ImageView) itemView.findViewById(R.id.Icon);
this.cardview = (CardView) itemView.findViewById(R.id.cardview);
}
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from( parent.getContext()).inflate(R.layout.postdetails, parent, false);
return new ImageTypeViewHolder(view) ;
}
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) {
final Model object = dataset.get(position);
// Log.d("RecyclerViewAdapter", "IMAGE="+object.Image);
imagepath.add(position, "");
if (Build.VERSION.SDK_INT >= 24)
{
//( (ImageTypeViewHolder) holder).subtitle.setText(Html.fromHtml(object.subtitle , Html.FROM_HTML_MODE_LEGACY));
( (ImageTypeViewHolder) holder).title.setText( Html.fromHtml(object.title , Html.FROM_HTML_MODE_LEGACY) );
( (ImageTypeViewHolder) holder).date.setText( Html.fromHtml(object.date , Html.FROM_HTML_MODE_LEGACY) );
}
else
{
//( (ImageTypeViewHolder) holder).subtitle.setText(Html.fromHtml(object.subtitle ));
( (ImageTypeViewHolder) holder).title.setText( Html.fromHtml(object.title ));
( (ImageTypeViewHolder) holder).date.setText( Html.fromHtml(object.date ));
}
( (ImageTypeViewHolder) holder).imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, WPPostDetails.class);
intent.putExtra("itemPosition", position);
mContext.startActivity(intent);
}
});
try {
getthumbnail(object.Image, ( (ImageTypeViewHolder) holder).imageView, position);
}catch (Exception e){
// Log.e("adapter ","failed to get image "+e.toString() );
}
/// dataset.get(position)
}
public void getthumbnail(String imageurl, final ImageView imageView, final int position){
ServiceWrapper serviceWrapper = new ServiceWrapper(null);
Call<GetThumbnail> call = serviceWrapper.getThumbnailCall(imageurl);
call.enqueue(new Callback<GetThumbnail>() {
@Override
public void onResponse(Call<GetThumbnail> call, final Response<GetThumbnail> response) {
if (response.body() != null && response.isSuccessful()) {
try {
if (response.body().getMediaDetails()!=null){
// Log.e("recycler adapter", " image is here-- " + response.body().getMediaDetails().getSizes().getThumbnail().getSourceUrl());
// Log.e("Full IMG SIZE - ", " THIS IS FULL IMAGE URL-- " + response.body().getMediaDetails().getSizes().getFull().getSourceUrl());
imagepath.add(position, response.body().getMediaDetails().getSizes().getFull().getSourceUrl());
Picasso.get()
.load(response.body().getMediaDetails().getSizes().getFull().getSourceUrl())
.fetch(new com.squareup.picasso.Callback() {
@Override
public void onSuccess() {
}
@Override
public void onError(Exception e) {
// Try again online if cache failed
Picasso.get()
.load(response.body().getMediaDetails().getSizes().getFull().getSourceUrl())
.placeholder(R.drawable.test_img_size)
.error(R.drawable.test_img_size)
.into(imageView);
}
});
//Glide.with(mContext)
//.load(response.body().getMediaDetails().getSizes().getFull().getSourceUrl())
//.downloadOnly(new SimpleTarget<File>() {
//@Override
//public void onResourceReady(File resource, GlideAnimation<? super File>
//glideAnimation) {
//Glide.with(mContext)
//.load(response.body().getMediaDetails().getSizes().getFull().getSourceUrl())
//.diskCacheStrategy(DiskCacheStrategy.SOURCE)
//.into(imageView);
//}
//});
}else {
}
}catch (Exception e){
// Log.e("adapter", "fail not media tag "+ e.toString());
}
}
}
@Override
public void onFailure(Call<GetThumbnail> call, Throwable t) {
// Log.e("adapter", " faile image "+t.toString());
}
});
}
@Override
public int getItemCount() {
return dataset.size() ;
}
}
So, as some suggest and as you may see, I tried to use glade but it didn't work.
The problem is the same, when the user scrolls up and down the images re-load over and over again. And, some time it only cache 6 images out of 20 (it should cache every image in this way the app will show the image that are in the cache and not fetching in from the web)
edited Nov 7 at 18:52
asked Nov 7 at 16:03
JMASTER B
25331133
25331133
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
If your problem is cache try use the methods skipMemoryCache() and memoryPolicy(MemoryPolicy.NO_CACHE).
well..need them to cache tho, because if they don't cache then it will be slow next time the user open the app
– JMASTER B
Nov 7 at 16:47
The problem also is that if I dont cache the image, every time the user scrolls up and down the app try to fetch the image again and again..and make the app slow...any solution? even if I have to use Glide
– JMASTER B
Nov 7 at 16:49
Please, post your code of the RecyclerView or Listview for a better view of the problem...
– Anderson Ricardo
Nov 7 at 17:06
Yes I will in one hour...thanks for your help
– JMASTER B
Nov 7 at 17:07
Glide is a good solution too, i use both in my project.
– Anderson Ricardo
Nov 7 at 17:09
|
show 3 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
If your problem is cache try use the methods skipMemoryCache() and memoryPolicy(MemoryPolicy.NO_CACHE).
well..need them to cache tho, because if they don't cache then it will be slow next time the user open the app
– JMASTER B
Nov 7 at 16:47
The problem also is that if I dont cache the image, every time the user scrolls up and down the app try to fetch the image again and again..and make the app slow...any solution? even if I have to use Glide
– JMASTER B
Nov 7 at 16:49
Please, post your code of the RecyclerView or Listview for a better view of the problem...
– Anderson Ricardo
Nov 7 at 17:06
Yes I will in one hour...thanks for your help
– JMASTER B
Nov 7 at 17:07
Glide is a good solution too, i use both in my project.
– Anderson Ricardo
Nov 7 at 17:09
|
show 3 more comments
up vote
0
down vote
If your problem is cache try use the methods skipMemoryCache() and memoryPolicy(MemoryPolicy.NO_CACHE).
well..need them to cache tho, because if they don't cache then it will be slow next time the user open the app
– JMASTER B
Nov 7 at 16:47
The problem also is that if I dont cache the image, every time the user scrolls up and down the app try to fetch the image again and again..and make the app slow...any solution? even if I have to use Glide
– JMASTER B
Nov 7 at 16:49
Please, post your code of the RecyclerView or Listview for a better view of the problem...
– Anderson Ricardo
Nov 7 at 17:06
Yes I will in one hour...thanks for your help
– JMASTER B
Nov 7 at 17:07
Glide is a good solution too, i use both in my project.
– Anderson Ricardo
Nov 7 at 17:09
|
show 3 more comments
up vote
0
down vote
up vote
0
down vote
If your problem is cache try use the methods skipMemoryCache() and memoryPolicy(MemoryPolicy.NO_CACHE).
If your problem is cache try use the methods skipMemoryCache() and memoryPolicy(MemoryPolicy.NO_CACHE).
answered Nov 7 at 16:45
Anderson Ricardo
11
11
well..need them to cache tho, because if they don't cache then it will be slow next time the user open the app
– JMASTER B
Nov 7 at 16:47
The problem also is that if I dont cache the image, every time the user scrolls up and down the app try to fetch the image again and again..and make the app slow...any solution? even if I have to use Glide
– JMASTER B
Nov 7 at 16:49
Please, post your code of the RecyclerView or Listview for a better view of the problem...
– Anderson Ricardo
Nov 7 at 17:06
Yes I will in one hour...thanks for your help
– JMASTER B
Nov 7 at 17:07
Glide is a good solution too, i use both in my project.
– Anderson Ricardo
Nov 7 at 17:09
|
show 3 more comments
well..need them to cache tho, because if they don't cache then it will be slow next time the user open the app
– JMASTER B
Nov 7 at 16:47
The problem also is that if I dont cache the image, every time the user scrolls up and down the app try to fetch the image again and again..and make the app slow...any solution? even if I have to use Glide
– JMASTER B
Nov 7 at 16:49
Please, post your code of the RecyclerView or Listview for a better view of the problem...
– Anderson Ricardo
Nov 7 at 17:06
Yes I will in one hour...thanks for your help
– JMASTER B
Nov 7 at 17:07
Glide is a good solution too, i use both in my project.
– Anderson Ricardo
Nov 7 at 17:09
well..need them to cache tho, because if they don't cache then it will be slow next time the user open the app
– JMASTER B
Nov 7 at 16:47
well..need them to cache tho, because if they don't cache then it will be slow next time the user open the app
– JMASTER B
Nov 7 at 16:47
The problem also is that if I dont cache the image, every time the user scrolls up and down the app try to fetch the image again and again..and make the app slow...any solution? even if I have to use Glide
– JMASTER B
Nov 7 at 16:49
The problem also is that if I dont cache the image, every time the user scrolls up and down the app try to fetch the image again and again..and make the app slow...any solution? even if I have to use Glide
– JMASTER B
Nov 7 at 16:49
Please, post your code of the RecyclerView or Listview for a better view of the problem...
– Anderson Ricardo
Nov 7 at 17:06
Please, post your code of the RecyclerView or Listview for a better view of the problem...
– Anderson Ricardo
Nov 7 at 17:06
Yes I will in one hour...thanks for your help
– JMASTER B
Nov 7 at 17:07
Yes I will in one hour...thanks for your help
– JMASTER B
Nov 7 at 17:07
Glide is a good solution too, i use both in my project.
– Anderson Ricardo
Nov 7 at 17:09
Glide is a good solution too, i use both in my project.
– Anderson Ricardo
Nov 7 at 17:09
|
show 3 more comments
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53193253%2fpicasso-loads-6-images-only-from-cache%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown