'How to fetch files from Firebase in Android using multiple threads?
So I have an intent where I display several images in RecycleView. But the loading is slow so I thought I could display them using multiple threads. When I create threads in the onBindViewHolder method, an exception from firebase says that uri fetching should only be performed using the main thread. Is it possible loading the images on multiple thread?
Heres my onBindViewHolder code:
@Override
public void onBindViewHolder(@NonNull ImageViewHolder holder, @SuppressLint("RecyclerView") int position) {
new Thread(new Runnable() {
@Override
public void run() {
Upload uploadCurrent = mUploads.get(position);
holder.textViewName.setText(uploadCurrent.getmName());
Picasso.get().load(uploadCurrent.getmImageURI()).centerCrop().fit().into(holder.imageView);
}
}).start();
}
Thanks!
Solution 1:[1]
Firebase already performs all network and disk I/O off the main thread. Are you sure that the threading model is the issue, and not say your available bandwidth?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Frank van Puffelen |
