0

I want to create below design, because of this I have created dynamic image Views and fetch image urls using Glide lib. But loading the images are very slow

holder.linearLayout.removeAllViews();

for(int k = 0; k < getPicList().size(); k++) {
    ImageView imageView = new ImageView(holder.linearLayout.getContext());
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(90, 90);
    params.setMargins(0,0,10,0);
    imageView.setLayoutParams(params);
    getpic(holder.linearLayout, imageView, requestData.getPicList().get(k).getPic());
} 

private void getpic(final LinearLayout linearLayout, final ImageView imageView, String imageUrl){
    // Log.d(TAG,imageUrl);
    if (imageUrl != null) {
        // Loading profile image
        Glide.with(context).load(imageUrl)
            //  .crossFade()
            .dontAnimate()
            .priority(Priority.IMMEDIATE)
            .signature(new StringSignature(String.valueOf(System.currentTimeMillis())))
            //   .placeholder()
            .error(R.drawable.ic_error_image_load)
            .thumbnail(0.5f)//size multiplier must be 0 and 1
            .bitmapTransform(new CircleTransform(context))
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .into(new SimpleTarget<GlideDrawable>() {
                @Override
                public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
                    imageView.setImageDrawable(resource);
                    linearLayout.addView(imageView);   
                }
            });
    } else {
        // make sure Glide doesn't load anything into this view until told otherwise
        Glide.clear(employee_img);
        // remove the placeholder (optional); read comments below
        employee_img.setImageDrawable(null);
    }
}

Is this the right way to choose the dynamic image views for this kind of UI, or is there any other alternative?

cardview_design

Massimiliano Kraus
  • 3,638
  • 5
  • 27
  • 47
Rgv
  • 504
  • 5
  • 23
  • try keeping horizontal recyclerview inside vertical recyclerview items , it works – Manohar Aug 20 '17 at 06:34
  • then ever cardview contain individual recyclerview right... is it rightway:) – Rgv Aug 21 '17 at 04:57
  • 1
    yes ,check out https://irpdevelop.wordpress.com/2016/02/10/horizontal-recyclerview-inside-a-vertical-recyclerview/ and https://stackoverflow.com/questions/32011995/how-to-have-a-listview-recyclerview-inside-a-parent-recyclerview/32086918#32086918 .might be useful – Manohar Aug 21 '17 at 05:13
  • thank u very mush bro u saved my time ... any performance issues – Rgv Aug 21 '17 at 05:25
  • I used once for small lists about 10-20 items , no issue for me – Manohar Aug 21 '17 at 05:28
  • thank u :) :) ...... – Rgv Aug 21 '17 at 05:32
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/152411/discussion-between-rgv-and-redman). – Rgv Aug 21 '17 at 05:43

0 Answers0