android
글라이드 bitmap으로 저장
ian_hodge
2017. 1. 15. 16:28
class Gliding extends AsyncTask<Void,Void,Void>{
String url;
Bitmap theBitmap;
Gliding(String url){
this.url=url;
}
@Override
protected Void doInBackground(Void... params) {
// Looper.prepare();
try {
theBitmap = Glide.
with(Friend_service.this).
load(url).
asBitmap().
into(-1,-1).
get();
} catch (final ExecutionException e) {
Log.d("error",e.toString());
} catch (final InterruptedException e) {
Log.d("error",e.toString());
}
return null;
}
@Override
protected void onPostExecute(Void dummy) {
if (null != theBitmap) {
// The full bitmap should be available here
FileOutputStream fos = null;
try {
fos = openFileOutput(fileName, 0);
// imageView_iv.setImageBitmap(theBitmap);
theBitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos);
fos.flush();
fos.close();
Log.d("result","sucess");
\h (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
};
}
}