0

I am currently doing the following: I have a RecyclerView to display in a fragment.I load the data along with the images from the server. I am using Ion library to load the server data and the images.I have googled and found out that Volley excutes asynchronously. I refered here. I have a doubt:

  1. Ion/Volley runs asynchronously. So does that mean they don't run on the main UI thread? Or do they run asyncronously on seperate thread?
  2. Someone told me that my recyclerview was jerky because I was loading data on the main thread using Ion.I have read that using Picasso to load images will prevent the jerky effect. So can any one clear me on this too?
Community
  • 1
  • 1
Tiny
  • 109
  • 12
  • 1
    Your both questions in the first point mean the same thing. If something runs asynchronously it means it does not run on the main UI thread, which means it runs on seperate thread. Volley is perfectly fine to load data, Ion probably too (but I never heard of it). – Wukash Apr 02 '16 at 08:01

3 Answers3

1

running [something] asynchronously means that [something] will not running in the same thread you started it from.

Pictures or data loading, a network call or a long processing call all should be run asynchronously in order not to block main execution.

Volley and Picasso by default run asynchronously. For example when you add a Volley request to the queue it processing it using cache and network dispatchers on different threads. However the callback you get back is received on the main thread so you can work with the UI as you wish without any extra line of code. Volley can be used also to load remote pictures.

To load local and remote pictures in a list or RecyclerView you can try also glide it works very good for me.

For network data in general other good option is jus. its like volley but with more options and more flexible.

kalin
  • 3,546
  • 2
  • 25
  • 31
0

Ion/Volley runs asynchronously. So does that mean they don't run on the main UI thread? Or do they run asyncronously on seperate thread?

yup exactly if something your executing asynchronously it will be independent from the main tread. There will be parallel execution.

Someone told me that my recyclerview was jerky because I was loading data on the main thread using Ion.I have read that using Picasso to load images will prevent the jerky effect. So can any one clear me on this too?

For that you need to use Image loader library for loading images. You can use :

  1. Universal Image loader
  2. Picasso
  3. Glide
Janki Gadhiya
  • 4,492
  • 2
  • 29
  • 59
0

I haven't used Ion but if your app is not throwing NetworkOnMainThreadException, then Ion too fetches the network image off the UI thread. So to that respect it should be the same as Volley, Picasso or Glide.

Now if you UI janks, and assuming it is because of Ion, it might be because once the image is fetched from the network Ion will perform some decoding, scaling etc. And that might done in the UI thread. That may be causing the issue. Picasso, Volley, Glide and (I guess) Ion, use different approaches, techniques when it comes to decoding, fitting, etc. images in order to be as fast and efficient as possible. Maybe Ion is not shining at it.

My advise, if you have problems with Ion, change to Picasso or Glide.

Aitor Viana
  • 933
  • 6
  • 15