마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

리스트뷰에서 웹 URL 이미지를 받아서 뿌릴때 속도관련

0 추천
이미지 주소 URL을 받아 drawable 전환한후 리스트 뷰에 뿌려주는 작업을 하고 잇습니다.

이미지 하나일땐 속도에 상관이 없다가 다수이미지가 필요한 리스트뷰에 뿌리니 지연현상이 나더군요 ㅠㅠ..

혹시 코드에서 수정하여 속도개선이 가능한지 여쭙고자 글 올립니다.

 

URL을 받아서 drawable 전환 하는 해당 코드입니다.

public static Drawable drawableFromUrl(String url) throws IOException {
    Bitmap x = null;
    try {
        HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
        connection.connect();
        InputStream input = connection.getInputStream();

        x = BitmapFactory.decodeStream(input);
    } catch (IOException e) {

    }
    return new BitmapDrawable(x);
}

 

-------------------------------------------------
 

어싱크테스크를 이용해 전환 해봤지만 역시나 리스트에 들어가면 비슷하더군요 ㅠ...

public class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
    ImageView imageViewURLProfile;

    public DownloadImageTask(ImageView imageViewURLProfile) {
        this.imageViewURLProfile = imageViewURLProfile;
    }

    public Bitmap doInBackground(String... urls) {
        String urldisplay = urls[0];
        Bitmap mIcon11 = null;
        try {
            InputStream in = new java.net.URL(urldisplay).openStream();
            mIcon11 = BitmapFactory.decodeStream(in);
        } catch (Exception e) {
//            Log.e("Error", e.getMessage());
//            e.printStackTrace();
        }
        return mIcon11;
    }

    public void onPostExecute(Bitmap result) {
        imageViewURLProfile.setImageBitmap(result);
    }
}

 

고수분들은 리스트에 url 이미지 처리를 어떻게 하시나요?
R0R0 (2,610 포인트) 님이 2017년 2월 23일 질문
자답입니다~ 앱 시작할때 공용변수만들어서 넣어두고 사용할때 뿌리니까 지연현상이 없어졌네요

1개의 답변

+1 추천
 
채택된 답변
http://d2.naver.com/helloworld/429368

https://github.com/bumptech/glide

저는  이미지 로딩 라이브러리로 보통 glide를 씁니다.
페어리 (12,270 포인트) 님이 2017년 2월 23일 답변
R0R0님이 2017년 2월 24일 채택됨
...