我有一个带有imageview和textview的recyclerview,我想使用质量差的下载来加速下载过程。
imageview有一个onclick方法,显示一个对话框,下载的图像像背景一样,所以,我想要质量不好的下载图像,只有当用户点击图像时,才能以高质量下载图像。
这是我的下载代码:
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));
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();
}