I'm too tired for searched this question in two day's , but i got false answer , I implement RecyclerView and it worked well, but my RecycleView have many items like photo's and video's like Instagram . it mean my adapter will invoke onBindViewHolder for all items to start download and loading image's and video's . but RecycleView just invoked onBindViewHolder for each item's when item is visible (scroll show it) . it's impossible ? if not how instagram can do that . pay attention : i don't want to using database for save image's and video's
@Override
public void onBindViewHolder(RecyclerView.ViewHolder h, int position) {
Log.e("position",position+" ");
thread t = new Thread(new Runnable(){
public void run(){
Bitmap bitmap = downloadPhoto();//it mean photo downloaded and converted to Bitmap
runOnUiThread(new Runnable(){
holder.imageView.setImageBitmap(bitmap);
));
}
});
t.start();
}
You can try embedding the recyclerview inside nested scroll view and do not forget to disable nested scrollview of recyclerview. This way all items will be loaded at once even though it violates the purpose of the recyclerview.
Although I wouldn't recommend you to use this "solution", since it destroys the original purpose of using a RecyclerView, it is possible to let the RecyclerView invoke onBindViewHolder for every item at once. For it to work, just set the RecyclerView inside a NestedScrollView.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With