为什么要采用Android毕加索库下载图像? [英] Why use Android Picasso library to download images?

查看:127
本文介绍了为什么要采用Android毕加索库下载图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为什么要通过毕加索库下载只使用此code的图像,而不是:

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?

推荐答案

刚刚新到Android或者从移动的iOS到Android纪录的人..........

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.

正是这种易于使用:

Picasso.
  with(State.mainContext).
  load(parseImageFile.getUrl()).
  into(null);

您很干脆:

就这么简单。除非你想为编写从零开始,你就必须使用毕加索。

It's that simple. Unless you want to write that from scratch, you simply must use Picasso.

注意 ParseImageFile 基本上不工作 - 这是毫无用处有关缓存等。有令人钦佩的替代品毕加索(如通用图像装载机,检查出来),但没有工作,以及毕加索,现在2014年。

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.

需要注意的是滚动的ListView android上的很多,很多问题不是表处理滚动iOS上。可以说,Android的+毕加索更像是在iOS,在那里所有的工作进行滚动大表的观点与图像已经完成的情况。

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.

有关今天,毕加索是 - 简单 - 任何Android应用程序任何一个核心部分。谢天谢地,这是一条线的code - 无需设置,没有什么

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/

这篇关于为什么要采用Android毕加索库下载图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆