当前位置

网站首页> 程序设计 > 程序资讯 > 软件更新资讯 > 浏览文章

Glide 3.5.0 发布,Android 图片加载和缓存库

作者:小梦 来源: 网络 时间: 2024-05-29 阅读:

阿里百川梦想创业大赛,500万创投寻找最赞的APP

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 和 Notification Target 实现 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).

Glide 是一个 Android 上的图片加载和缓存库,其目的是实现平滑的图片列表滚动效果。

示例代码:

// For a simple view:@Overridepublic 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:@Overridepublic 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;}

热点阅读

网友最爱