How to load all the images in the background of a RecyclerView in Android -
hi working on recycler view 1000 records, need display remote images. iam loading 20 records @ time. 6 records can shown @ time on screen (based on screen size of android device). recycler view making req backend image when row shown on screen, resulting in taking time display on screen (i using picasso library lazy loading). can please suggest me how cache 20 images in ground @ time, way can show image user when scrolls down. (this our requirement)
i think link has need not 20 records
first need implement linearlayoutmanager :
public class precachinglayoutmanager extends linearlayoutmanager { private static final int default_extra_layout_space = 600; private int extralayoutspace = -1; private context context; public precachinglayoutmanager(context context) { super(context); this.context = context; } public precachinglayoutmanager(context context, int extralayoutspace) { super(context); this.context = context; this.extralayoutspace = extralayoutspace; } public precachinglayoutmanager(context context, int orientation, boolean reverselayout) { super(context, orientation, reverselayout); this.context = context; } public void setextralayoutspace(int extralayoutspace) { this.extralayoutspace = extralayoutspace; } @override protected int getextralayoutspace(recyclerview.state state) { if (extralayoutspace > 0) { return extralayoutspace; } return default_extra_layout_space; } }
and set layout manager recycle view.
precachinglayoutmanager layoutmanager = new precachinglayoutmanager(getactivity()); layoutmanager.setorientation(linearlayoutmanager.vertical); layoutmanager.setextralayoutspace(deviceutils.getscreenheight(getactivity())); recyclerview.setlayoutmanager(layoutmanager);
Comments
Post a Comment