Glide 4(URL 변환 파일,URL 변환 Drawable)

링크
File/Bitmap/File/Gif 직접 가 져 오기
public void downloadImage() {
    new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                String url = "http://www.guolin.tech/book.png";
                final Context context = getApplicationContext();
                FutureTarget target = Glide.with(context)
                        .asFile()
                        .load(url)
                        .submit();
                final File imageFile = target.get();
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Toast.makeText(context, imageFile.getPath(), Toast.LENGTH_LONG).show();
                    }
                });
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }).start();
}

URL 변환 Drawable
SimpleTarget simpleTarget = new SimpleTarget() {
    @Override
    public void onResourceReady(Drawable resource, Transition super Drawable> transition) {
        imageView.setImageDrawable(resource);
    }
};

public void loadImage(View view) {
    Glide.with(this)
         .load("http://guolin.tech/book.png")
         .into(simpleTarget);
}

4.0 이하 의 bitmap 는 어떻게 얻 습 니까?
Bitmap myBitmap = Glide.with(applicationContext)  
        .load(yourUrl)  
        .asBitmap()  
        .centerCrop()  
        .into(Target.SIZE_ORIGINAL,Target.SIZE_ORIGINAL)  
        .get()  ;

좋은 웹페이지 즐겨찾기