2017-05-03 71 views
0

有人可以幫助我如何檢索使用滑動緩存存儲圖像的文件路徑?我想將加載了滑動的圖像發送到服務器的圖像視圖。我可以知道如何獲取緩存圖像的文件路徑嗎?選擇滑動緩存圖像的原因是其上傳到服務器的尺寸要小得多。獲取加載了滑動的圖像的文件路徑

如果不可能有人可以建議壓縮圖像的方式?

我已經嘗試過不同的圖像壓縮算法,但沒有一個給出最好的滑動。

回答

2

Glide支持SimpleTarget,它在加載完成時給出位圖。

private SimpleTarget target = new SimpleTarget<Bitmap>() { 
    @Override 
    public void onResourceReady(Bitmap bitmap, GlideAnimation glideAnimation) { 

     // upload bitmap here after saving it to your disk 

    } 
    }; 

然後使用目標作爲

Glide 
    .with(context) // could be an issue! 
    .load(eatFoodyImages[0]) 
    .asBitmap() 
    .into(target); 

更多學習的https://futurestud.io/tutorials/glide-callbacks-simpletarget-and-viewtarget-for-custom-view-classes