android - how to download images with bad quality? -
i have recyclerview imageview , textview , , populate using download in bad quality accelerate download process.
the imageview has onclick method display dialog image downloaded background, so, want download image in bad quality , when user clicked in image , download image in hight quality.
this code download:
try { ruta = "http://192.168.1.67/apptequila/fotos/" + usuariojson + "/" + fotojson; url url = new url(ruta); httpurlconnection connection = (httpurlconnection) url.openconnection(); connection.setconnecttimeout(15000); connection.connect(); inputstream input = connection.getinputstream(); bitmap = bitmapfactory.decodestream(input); }catch (sockettimeoutexception e){ cancelarhilo(3); } catch (exception e) { log.i("sms", "error al obtener foto: " + e.tostring()); bitmap = bitmapfactory.decoderesource(getresources(), r.drawable.sin_perfil); } data.add(new mimodel(nombrejson, categoriajson, likesjson, lemajson, bitmap, idsjson,latitudjson,longitudjson,distanciajson)); code of onclick imageview:
public void pressimage(final int position) { customdiag = new dialog(mainactivity.this); customdiag.requestwindowfeature(window.feature_no_title); customdiag.setcontentview(r.layout.dialog); relativelayout relativelayout = (relativelayout)customdiag.findviewbyid(r.id.root); drawable drawable = new bitmapdrawable(getapplicationcontext().getresources(), data.get(position).getimagen()); if(build.version.sdk_int > 16) { relativelayout.setbackground(drawable); }else{ relativelayout.setbackgrounddrawable(drawable); } customdiag.show(); }
why want that? use picasso or volley allow downloading/caching of images. display images in listviews extremely well. mitigate issue of attempting reduce memory burden making images "bad".
Comments
Post a Comment