Glide 是一个 Android 上的图片加载和缓存库,其目的是实现平滑的图片列表滚动效果。
Glide 3.4.0 发布,此版本现已提供下载,包括大量新特性和 bug 修复。此版本最值得关注的是动态 GIFs,可以通过 GifDecoder 来对 GIFs 进行解码,修复了相关的一些小问题,比如渲染和解码通道的问题。
更多内容请看 milestone。
完整改进记录:
新特性Allow RequestBuilders to be re-used for multiple loads by introducing the .from() and.clone() APIs. These APIs allow users to set options on a request builder once, pass the builder to their adapters, and then start multiple loads with the single builder (#182).
1 2 3 4 5 6 7 8 9 10 | Glide.with( this )
.from(String. class )
.placeholder(R.drawable.spinner)
.centerCrop()
.crossFade();
mAdapter = new MyAdapter(requestBuilder);
}
mRequestBuilder.load(myUrls.get(position)).into(convertView);
}
|
1 2 | Glide.setup( new GlideBuilder(context)
.setDecodeFormat(DecodeFormat.ALWAYS_ARGB_8888));
|
1 2 3 | Glide.with(fragment)
.load(url)
.preload(width, height);
|
Add a .signature() API to allow users to easily mix in additional data to cache keys, giving users more control over cache invalidation (#178, #179), see the cache invalidation wiki.
1 2 3 4 | Glide.with(fragment)
.load(url)
.signature( new StringSignature( "Version1" ))
.into(view);
|
1 2 | Glide.get(context)
.preFillBitmapPool( new PreFillType.Builder(mySize));
|
1 2 3 4 5 6 7 8 9 | Glide.with(fragment)
.load(myUrl)
.thumbnail(Glide.with(fragment)
.load(myUrl)
.override( 200 , 200 )
.thumbnail(Glide.with(fragment)
.load(myUrl)
.override( 50 , 50 )))
.into(myView);
|
Build/InfrastructureBugs 修复
性能GIFsAvoid a crash causing race decoding multiple frames with the same GifDecoder (#212). Always use ARGB_8888 to prevent null GIF frames on some versions of Android that don’t support ARGB_4444 (#216). Fix partially decoded GIF frames (appears as grey or transparent noise in frames) (#207,#204). Set a default frame delay for GIFs which do not specify a frame delay, or specify an overly short frame delay (#205). More robust GIF decoding logic, including a fix for decoding only the first few rows of certain GIFs (#203). Allow fade in/cross fade animations by ensuring that the first frame of GIFs is decoded before the GIF is returned (#159). Fix GIFs always appearing transparent pre KitKat (#199).
MemoryTransformationsCachingUris其他Fix concurrency bugs resulting in incorrect assertions being thrown when loads were started on multiple threads (#191, #181). Fix BitmapRequestBuilder not setting the decode format on the cache decoder whenformat() is called (#187). Fix an assertion in ViewTarget related to restarting requests (#167). Fix Glide.with() throwing pre Honeycomb when given non-support Activities (#158). Avoid using Closeable interface when loading ParcelFileDescriptors on 4.1.1 or earlier (#157). Fix an NPE in Bitmap#getAllocationByteCount() due to a framework bug in the initial release of KitKat (#148).
|