이미지 주소 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 이미지 처리를 어떻게 하시나요?