ダウンロード前にサムネイルをウェブ上の画像からプレビューしようとしています。これは、RecyclerView
にもっと多くのアイテムがあり、画像から単純なぼかしプレビューを表示しようとしていますが、 whatsソリューション、私はこのコードを使用していますが、私はこのコードは、whatsAppや電報などのソーシャルアプリケーションのように完全な画像をダウンロードすると思うどのように私はWeb上でプレビュー画像を作成し、ユーザーにそれを示すことができますか?Androidでウェブ上の画像からプレビューを作成する
new Thread(new Runnable() {
@Override
public void run() {
//First create a new URL object
URL url = null;
try {
if (checkNetWorkConnection()) {
url = new URL("http://wallpaperwarrior.com/wp-content/uploads/2016/09/Wallpaper-2.jpeg");
//Next create a file, the example below will save to the SDCARD using JPEG format
File file = new File(APP.DIR_APP + APP.IMAGE + "/" + "Wallpaper-2.jpg");
//Next create a Bitmap object and download the image to bitmap
Bitmap bitmap = BitmapFactory.decodeStream(url.openStream());
//Finally compress the bitmap, saving to the file previously created
bitmap.compress(Bitmap.CompressFormat.JPEG, 50, new FileOutputStream(file));
}
} catch (MalformedURLException e) {
e.printStackTrace();
Log.e("Error ", e.getMessage());
} catch (FileNotFoundException e) {
e.printStackTrace();
Log.e("Error ", e.getMessage());
} catch (IOException e) {
e.printStackTrace();
Log.e("Error ", e.getMessage());
}
}
}).start();