i have a recyclerview with a imageview and textview , and i would like populate using a download in bad quality to accelerate the download process.
the imageview has a onclick method which display a dialog with image downloaded like background, so, i want download image in bad quality and only when user clicked in image , then download the image in hight quality.
this is my code for 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();
}