android快速获取所有用户的朋友个人资料图片 [英] android getting all user's friend profile pictures quickly

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

问题描述

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

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://graph.facebook. com/uid/图片.

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延迟加载列表图像,但这是一个有用的特殊线程:

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快速获取所有用户的朋友个人资料图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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