Android 圖片加載和緩存庫,Glide 3.5.0 發布

jopen 10年前發布 | 27K 次閱讀 Glide

Glide是一個囊括了圖片下載、剪裁、內存和磁盤緩存,以及位圖重用功能于一體的快速高效圖像加載庫,同時也方便了接口的使用。默認情況下,Glide庫在Google Vooley項目的基礎上實現了通過http協議的圖像獲取以及Android并行網絡的操作。

項目主頁:http://www.baiduhome.net/lib/view/home/1395149765290

Glide 3.5.0 發布,此版本是增量版本,包括一些新特性和重要的 bug 修復。

新特性

  • 添加 GlideModules,更簡單的延遲配置 (#311).

  • 支持原始大小 (#274):

// You can override a view's size to request the original image:Glide.with(context)
    .load(myUrl)
    .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
    .into(myImageVIew);// SimpleTarget also now defaults to SIZE_ORIGINAL:Glide.with(context)
    .load(myUrl)
    .into(new SimpleTarget<Bitmap>() {        @Override
        public void onResourceReady(Bitmap bitmap, GlideAnimation animation) {            ...
        }
    });
  • 改進 ListPrerloader API, including an interface allowing different sizes per position thanks to @DavidWiesner (#273)

  • [ALPHA] AppWidget 和 NotificationTarget實現 thanks to @pavlospt (#242):

AppWidgetTarget widgetTarget = 
        new AppWidgetTarget(context, remoteViews, R.id.view_id, 300, 400, R.id.widget_id);Glide.with(context)
    .asBitmap()
    .load(myUrl)
    .into(widgetTarget);
  • Override values are passed through to thumbnails (#236).

  • Automatically call trim/clear memory based on ComponentCallbacks (9063f6c).

Build/Infrastructure

  • 更新到 Robolectric 2.4 thanks to @TWiStErRob (#249).

  • 更新到 Android gradle plugin 1.0+ (ba32d32).

  • 添加 Intellij 文件,開發更方便 (e34df44)

Bugs 修復

性能

  • Fixed needlessly copying Bitmaps decoded from data without an EXIF orientation tag (#270).

  • Freed thumbnails eagerly when full loads finish (#237).

  • Fixed a strict mode violation initializing the disk cache on Lollipop (#298).

  • Fixed a NetworkOnMainThread exception in the OkHttp integration library (#257)

  • Calculate sample size correctly thanks to @jisung (#288)

Rendering

  • Worked around a framework issue in KitKat and Lollipop causing certain types of Bitmaps to render old data (#301).

  • Fixed large BMPs failing to render (#283).

  • Fixed decode failure for images with minimal EXIF segments (#286).

  • Fixed a bug causing shared color filters (#276).

其他

  • Fixed a crash when the Glide singleton is instantiated on a background thread (#295).

  • Fixed a crash when completing loads started or cancelled other loads (#303).

  • Fixed skipMemoryCache not always skipping the memory cache (#258).

示例代碼:

// For a simple view:
@Override
public void onCreate(Bundle savedInstanceState) {
    ...
 
    ImageView imageView = (ImageView) findViewById(R.id.my_image_view);
 
    Glide.with(this).load("http://goo.gl/h8qOq7").into(imageView);
}
 
// For a list:
@Override
public View getView(int position, View recycled, ViewGroup container) {
    final ImageView myImageView;
    if (recycled == null) {
        myImageView = (ImageView) inflater.inflate(R.layout.my_image_view,
                container, false);
    } else {
        myImageView = (ImageView) recycled;
    }
 
    String url = myUrls.get(position);
 
    Glide.with(myFragment)
        .load(url)
        .centerCrop()
        .placeholder(R.drawable.loading_spinner)
        .crossFade()
        .into(myImageView);
 
    return myImageView;
}
 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!