안녕하세요

 

페이스북 연동해서 친구리스트와 이미지를 보여주는 리스트뷰를 만들고 있습니다.

 

그런데 친구 이름만 보여주는건 빠르게 나오는데

 

친구 사진을 같이 보여줄라면 아래 소스와 같이 매번 connect하는거때문에 무지하게 느립니다.

 

빠르게 조회 할수 있는 방법 있을까요??;

 

 

 

final JSONObject json = new JSONObject(response);
   JSONArray d = json.getJSONArray("data");
   int l = (d != null ? d.length() : 0);
   Log.d("Facebook-Example-Friends Request", "d.length(): " + l);
   for (int i=0; i<l; i++) {
    JSONObject o = d.getJSONObject(i);
    String n = o.getString("name");
    String id = o.getString("id");
    Friend f = new Friend();
    f.id = id;
    f.name = n;
    
    //사진 뽑아오기.
    try {
     
     URL url = new URL("https://graph.facebook.com/"+id+"/picture");
     URLConnection conn = url.openConnection();
     conn.connect();
     BufferedInputStream bis = new BufferedInputStream(conn.getInputStream());
     Bitmap bm = BitmapFactory.decodeStream(bis);
     bis.close();
     f.pictureBitmap = bm;
    } catch (MalformedURLException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
    } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
    }
    friends.add(f);
   
   }