Transition
包路径:com.bumptech.glide.request.transition.Transition
Transition接口业务是TransitionFactory的生产对象目标
一个允许跨资源类型将转换应用到目标中的视图的接口。包装视图的目标将能够提供所有必要的参数并开始转换。不这样做的那将无法提供必要的参数,因此将被迫忽视过渡。这个接口是一种折衷,它允许在Glide的任意资源类型和任意目标类型的复杂世界中查看特定的过渡。
类型参数:
R -其入口将被转换的资源的类型。
一个接口包装了一个视图,它公开了必要的方法来运行各种类型的android动画的过渡(ViewTransition, ViewPropertyTransition和animated Drawables)。
返回视图中显示的当前绘制对象,如果不存在该绘制对象(或无法检索),则返回null。
设置当前绘制对象(通常是动画绘制对象)显示在换行视图中。
从当前在给定视图中显示的前一个Drawable动画,如果不为空,到应该在视图中显示的新资源。
参数:
current—将在视图中显示的新资源。
适配器-过渡。ViewAdapter包装的视图至少可以从Transition.ViewAdapter.getView()返回一个视图。
返回:
如果在运行转换的过程中,新资源被放到视图上,则为True,如果调用者需要手动将当前资源放到视图上,则为false。
使用
很显然和设置转换**.transition(withCrossFade(factory))**相关
TransitionFactory
包路径:com.bumptech.glide.request.transition.TransitionFactory
一个工厂类,它可以根据请求的状态生成不同的转换。
类型参数:
R -需要动画到目标中的资源的类型。
返回一个新的过渡。
参数:
数据源-资源被加载的数据源。
isFirstResource -如果这是加载到目标中的第一个资源,则为True。
具体的实现工厂类如下列表
- BitmapContainerTransitionFactory
- BitmapTransitionFactory
- DrawableCrossFadeFactory
- NoTransition.NoAnimationFactory
- ViewAnimationFactory
- ViewPropertyAnimationFactory
BitmapContainerTransitionFactory
包路径:com.bumptech.glide.request.transition.BitmapContainerTransitionFactory
一个内部有位图的复杂类型的TransitionFactory。转换位图被包装在BitmapDrawable中。最常用的是drawablecrosfadefactory。
类型参数:
R -包含要转换的位图的复合对象的类型。
BitmapTransitionFactory
包路径:com.bumptech.glide.request.transition.BitmapTransitionFactory
用于位图的TransitionFactory,它使用一个Drawable转换工厂从一个已经在目标上可见的可绘制对象转换到新的位图。
DrawableCrossFadeFactory
一个工厂类,它生成一个新的Transition,这个Transition取决于绘制对象是否从内存缓存中加载,以及绘制对象是否是第一个放到目标上的图像。
资源通常在用户可以看到视图之前从内存缓存加载,例如当用户更改屏幕或在列表中来回滚动时。在这些情况下,用户通常不希望看到转换。因此,当资源从内存缓存加载时,这个工厂产生一个NoTransition
NoTransition.NoAnimationFactory
总是返回相同NoTransition的工厂。
类型参数:
R -将被转换到Target的资源类型。
ViewAnimationFactory
一个生成视图转换的TransitionFactory。
类型参数:
R -将被转换到视图的资源的类型。
ViewPropertyAnimationFactory
一个生成ViewPropertyAnimations的TransitionFactory。
类型参数:
R -将被转换到视图的资源的类型。
小计
在Glide里比较通用的工厂模式结构使用形式,看完前几篇这篇也很容易理解意图
下面是一段smartApi使用介绍:
下载地址:
https://pan.baidu.com/s/1kFAGbsFIk3dDR64NwM5y2A?pwd=csdn