android得到所有用户的朋友的个人资料图片quicly [英] android getting all user's friend profile pictures quicly

查看:117
本文介绍了android得到所有用户的朋友的个人资料图片quicly的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种快速获取我所有朋友的个人资料图片的方式。
我正在使用Facebook SDK for Android。

i'm looking for a quick way of getting all my friends's profile pictures. i'm using the Facebook SDK for Android.

现在我得到我的朋友的列表JSON对象,并在此对象中使用for循环。
在循环中,我将每个图像放在一个Drawable对象中: http://图.facebook.com / uid / picture

right now i'm getting my friend's list JSON object and running with a for loop inside this object. in the loop i'm putting each image in a Drawable object from the : http://graph.facebook.com/uid/picture.

我看到每张图片的重量只有4K,而且几个朋友的速度都快了。
但是如果我有1000个朋友,而且我每个人都连接到Facebook?
它需要很多时间。

i've seen that each picture weight only 4K and it goes fast for few friends. but what if i have 1000 friends and i'm connecting to facebook for each one of them ? it will take lots of time.

我在其他应用程序中看到,其中有些显示所有的朋友真正快速。

i've seen in other application that some of them show all your friend real quick.

最好的做法是什么?使用跑步者?

what is the best way of doing it ? using the runner ?

推荐答案

如果每张图片是4K,你有1000个朋友,大约是4MB的数据。下载它需要时间。如果你需要所有的照片,就没有办法了。

If each picture is 4K and you have 1000 friends, that's approximately 4MB of data. It'll take time to download it. There's no way around it if you need all of their pictures.

那就是说,你应该考虑你是否真的需要他们所有的照片。大多数应用程序将使用朋友的个人资料图片向用户显示。合理地说,界面不会一次显示1000个朋友。在这种情况下,一个很好的解决方案可能是延迟加载图像,即在为每个朋友解析JSON时存储图像的URL,但是在您需要之前不要下载实际的图像。如果说你的界面一次显示10个朋友,那么这只是40K的图像,这是一个更加合理的一个。

That said, you should think about whether you really need all of their pictures or not. The vast majority of apps will use the profile pictures of friends to display to the user. Reasonably speaking, the interface is not going to display 1000 friends all at once. A good solution in this case might be to lazy load the images, i.e. store the URL of the image when you parse the JSON for each friend, but don't download the actual images until you need them. If say your interface shows 10 friends at once, then that's only 40K of images which is a whole lot more reasonable.

你可以搜索StackOverflow的Android延迟加载列表图像,这里有一个特别的线程可能会有用: ListView中图片的懒惰加载

You can search StackOverflow for android lazy load list images but here's one particular thread that may come useful: Lazy load of images in ListView.

这篇关于android得到所有用户的朋友的个人资料图片quicly的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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