It seems to me that experienced comrades in their time were faced with the fact that images sparred from the site, for example, are not displayed, because the whole gallery takes a lot of megabytes. Here is my adapter:

public class GalleryAdapter extends RecyclerView.Adapter<GalleryAdapter.MyViewHolder>{ Context context; private List<PhotoCard> photocardList; public class MyViewHolder extends RecyclerView.ViewHolder{ public ImageView photo; public MyViewHolder(View itemView) { super(itemView); photo = (ImageView) itemView.findViewById(R.id.photo); } } public GalleryAdapter(Context context, List<PhotoCard> photocardList) { this.context = context; this.photocardList = photocardList; } @Override public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View itemView = LayoutInflater.from(parent.getContext()) .inflate(R.layout.gallery_thumbs, parent, false); return new MyViewHolder(itemView); } @Override public void onBindViewHolder(MyViewHolder holder, int position) { PhotoCard photocardItem = photocardList.get(position); ImageView imageView = holder.photo; Glide.with(context) .load(photocardItem.getPhoto()) .placeholder(R.drawable.temp_img) .diskCacheStrategy(DiskCacheStrategy.SOURCE) .into(imageView); } @Override public int getItemCount() { return photocardList.size(); } } 

Here are the logs after opening one gallery selected from the list (recyclerview):

 12-07 22:40:17.204 14094-14094/ru.alexandrpokh.cheltanks I/ActivityManager: Timeline: Activity_launch_request id:ru.alexandrpokh.cheltanks time:14744848 12-07 22:40:17.495 14094-14094/ru.alexandrpokh.cheltanks I/ActivityManager: Timeline: Activity_idle id: android.os.BinderProxy@41e705b8 time:14745133 12-07 22:40:17.765 14094-14315/ru.alexandrpokh.cheltanks D/dalvikvm: GC_FOR_ALLOC freed 1702K, 30% free 12532K/17756K, paused 24ms, total 24ms 

Judging by the memory monitor there is no leakage. As I understand it, creating too large an object that the glide cannot digest, the garbage collector is started. So how to be?

There is one moment. Before the glide, I used ImageLoader, taken from some example on the web. Once the gallery was loaded, but everything was very slow. More gallery is not loaded. After the decision was made to move to the glide.

Here is what the log file gave out at ImageLoader:

 MemoryCache will use up to 24.0MB 

Increasing the cache, the amendment in the code of this loader, did not give a result.

ps if you need some more code, then lay out

  • Permish added? It sounds ridiculous, but I remember an hour spent on solving a similar problem. Until I remembered that I forgot permission to register in the manifesto :) - YaPV
  • Yes, of course, everything is added) - Shura Balaganov
  • @YaPV, what problem did you have? - Shura Balaganov
  • The problem was with loading images in ImageView. Shoveled pieces of code and could not understand what was wrong. Well, and then I remembered that I did not register permish in the manifesto)) - YaPV
  • one
    So initialize the context in the adapter when creating it. Judging by the error :) - YaPV

0