Why should I download the images via the Picasso library instead of just using this code:
private Bitmap DownloadImage(String URL) { Bitmap bitmap = null; InputStream in = null; try { in = OpenHttpGETConnection(URL); bitmap = BitmapFactory.decodeStream(in); in.close(); } catch (Exception e) { Log.d("DownloadImage", e.getLocalizedMessage()); } return bitmap; }
Another question:
Does Picasso download the image in the UI or by background thread?
Picasso is open source and one of the widely used image download libraries in Android. It is created and maintained by Square. It is among the powerful image download and caching library for Android. Picasso simplifies the process of loading images from external URLs and displays them on your application.
Picasso is an image library for Android. It's created and maintained by Square, and caters to image loading and processing. It simplifies the process of displaying images from external locations. In many cases only a few lines of code is required to implement this neat library.
Fresco is a powerful image loading library for displaying images in Android applications. Fresco supports Android 2.3 (Gingerbread) and later. This powerful library developed by the good folks at Facebook. It loads images from the internet, local storage, and display a placeholder until the image has appeared.
Glide's loading times are faster and it uses a small amount of memory for cache, but the library size is quite large. It, too, is easy to implement. Glide might be a better alternative to Picasso when memory footprint is less of a concern or more and larger images need to be processed.
Just for the record for anyone new to Android or perhaps moving to Android from iOS ..........
Honestly, it's that simple. The advantages are unbelievable.
It's this easy to use:
Picasso. with(State.mainContext). load(parseImageFile.getUrl()). into(null);
You very simply:
It's that simple. Unless you want to write that from scratch, you simply must use Picasso.
Note that ParseImageFile essentially doesn't work - it is utterly useless about caching and so on. There are admirable alternatives to Picasso (such as Universal Image Loader, check it out), but none work as well as Picasso, for now 2014.
Note if you move to super-advanced-stuffs... The only thing better than Picasso, is to make the move to Volley. but that is a huge leap.
Note that ListView scrolling on android is much, much more problematic than table handling scrolling on iOS. You could say, Android + Picasso is MORE LIKE the situation on iOS, where all the work is already done for scrolling large table views with images.
For today, Picasso is - simply - a central part of any Android app whatsoever. Thank goodness, it is one line of code - no setup, nothing.
Again, the only thing "better than" Picasso is if you move to Volley.
BTW here's an excellent long article on Volley v. Picasso, if you need that...
http://www.bignerdranch.com/blog/solving-the-android-image-loading-problem-volley-vs-picasso/
Picasso download the image in another thread and it manages for you:
It's extremely simple, here is an example:
Picasso.with(context) .load(url) .placeholder(R.drawable.placeholder) .resize(imgWidth, imgHeight) .centerCrop() .into(image);
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