Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
沉迷打码的小凳子
glide
提交
876b9f6a
G
glide
项目概览
沉迷打码的小凳子
/
glide
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
glide
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
876b9f6a
编写于
7月 11, 2014
作者:
S
Sam Judd
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow transformations to be replaced.
上级
186211e3
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
72 addition
and
37 deletion
+72
-37
library/src/main/java/com/bumptech/glide/BitmapRequestBuilder.java
...rc/main/java/com/bumptech/glide/BitmapRequestBuilder.java
+11
-2
library/src/main/java/com/bumptech/glide/DrawableRequestBuilder.java
.../main/java/com/bumptech/glide/DrawableRequestBuilder.java
+26
-4
library/src/main/java/com/bumptech/glide/GenericRequestBuilder.java
...c/main/java/com/bumptech/glide/GenericRequestBuilder.java
+9
-23
library/src/main/java/com/bumptech/glide/GifRequestBuilder.java
...y/src/main/java/com/bumptech/glide/GifRequestBuilder.java
+25
-7
library/src/test/java/com/bumptech/glide/GenericRequestBuilderTest.java
...st/java/com/bumptech/glide/GenericRequestBuilderTest.java
+1
-1
未找到文件。
library/src/main/java/com/bumptech/glide/BitmapRequestBuilder.java
浏览文件 @
876b9f6a
...
...
@@ -247,6 +247,9 @@ public class BitmapRequestBuilder<ModelType, TranscodeType>
/**
* Transform images using {@link com.bumptech.glide.load.resource.bitmap.CenterCrop}.
*
* @see #fitCenter()
* @see #transform(com.bumptech.glide.load.Transformation[])
*
* @return This request builder.
*/
public
BitmapRequestBuilder
<
ModelType
,
TranscodeType
>
centerCrop
()
{
...
...
@@ -256,6 +259,9 @@ public class BitmapRequestBuilder<ModelType, TranscodeType>
/**
* Transform images using {@link com.bumptech.glide.load.resource.bitmap.FitCenter}.
*
* @see #centerCrop()
* @see #transform(com.bumptech.glide.load.Transformation[])
*
* @return This request builder.
*/
public
BitmapRequestBuilder
<
ModelType
,
TranscodeType
>
fitCenter
()
{
...
...
@@ -264,10 +270,13 @@ public class BitmapRequestBuilder<ModelType, TranscodeType>
/**
* {@inheritDoc}
*
* @see #fitCenter()
* @see #centerCrop()
*/
@Override
public
BitmapRequestBuilder
<
ModelType
,
TranscodeType
>
transform
(
Transformation
<
Bitmap
>
transformation
)
{
super
.
transform
(
transformation
);
public
BitmapRequestBuilder
<
ModelType
,
TranscodeType
>
transform
(
Transformation
<
Bitmap
>
...
transformations
)
{
super
.
transform
(
transformation
s
);
return
this
;
}
...
...
library/src/main/java/com/bumptech/glide/DrawableRequestBuilder.java
浏览文件 @
876b9f6a
...
...
@@ -144,6 +144,10 @@ public class DrawableRequestBuilder<ModelType>
/**
* Transform {@link Drawable}s using {@link com.bumptech.glide.load.resource.bitmap.CenterCrop}.
*
* @see #fitCenter()
* @see #bitmapTransform(com.bumptech.glide.load.Transformation[])
* @see #transform(com.bumptech.glide.load.Transformation[])
*
* @return This request builder.
*/
public
DrawableRequestBuilder
<
ModelType
>
centerCrop
()
{
...
...
@@ -154,6 +158,10 @@ public class DrawableRequestBuilder<ModelType>
* Transform {@link android.graphics.drawable.Drawable}s using
* {@link com.bumptech.glide.load.resource.bitmap.FitCenter}.
*
* @see #centerCrop()
* @see #bitmapTransform(com.bumptech.glide.load.Transformation[])
* @see #transform(com.bumptech.glide.load.Transformation[])
*
* @return This request builder.
*/
public
DrawableRequestBuilder
<
ModelType
>
fitCenter
()
{
...
...
@@ -161,19 +169,33 @@ public class DrawableRequestBuilder<ModelType>
}
/**
* Transform {@link android.graphics.drawable.Drawable}s using the given bitmap transformation.
* Transform {@link android.graphics.drawable.Drawable}s using the given {@link android.graphics.Bitmap}
* transformations. Replaces any previous transformations.
*
* @see #fitCenter()
* @see #centerCrop()
* @see #transform(com.bumptech.glide.load.Transformation[])
*
* @return This request builder.
*/
public
DrawableRequestBuilder
<
ModelType
>
bitmapTransform
(
Transformation
<
Bitmap
>
bitmapTransformation
)
{
return
transform
(
new
GifBitmapWrapperTransformation
(
bitmapTransformation
));
public
DrawableRequestBuilder
<
ModelType
>
bitmapTransform
(
Transformation
<
Bitmap
>...
bitmapTransformations
)
{
GifBitmapWrapperTransformation
[]
transformations
=
new
GifBitmapWrapperTransformation
[
bitmapTransformations
.
length
];
for
(
int
i
=
0
;
i
<
bitmapTransformations
.
length
;
i
++)
{
transformations
[
i
]
=
new
GifBitmapWrapperTransformation
(
bitmapTransformations
[
i
]);
}
return
transform
(
transformations
);
}
/**
* {@inheritDoc}
*
* @see #bitmapTransform(com.bumptech.glide.load.Transformation[])
* @see #centerCrop()
* @see #fitCenter()
*/
@Override
public
DrawableRequestBuilder
<
ModelType
>
transform
(
Transformation
<
GifBitmapWrapper
>
transformation
)
{
public
DrawableRequestBuilder
<
ModelType
>
transform
(
Transformation
<
GifBitmapWrapper
>
...
transformation
)
{
super
.
transform
(
transformation
);
return
this
;
}
...
...
library/src/main/java/com/bumptech/glide/GenericRequestBuilder.java
浏览文件 @
876b9f6a
...
...
@@ -31,8 +31,6 @@ import com.bumptech.glide.request.target.Target;
import
com.bumptech.glide.util.Util
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* A generic class that can handle loading a bitmap either from an image or as a thumbnail from a video given
...
...
@@ -52,8 +50,6 @@ public class GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeT
private
final
Class
<
TranscodeType
>
transcodeClass
;
private
final
Glide
glide
;
private
final
RequestTracker
requestTracker
;
private
List
<
Transformation
<
ResourceType
>>
transformations
=
null
;
private
Transformation
<
ResourceType
>
singleTransformation
=
UnitTransformation
.
get
();
private
int
placeholderId
;
private
int
errorId
;
private
RequestListener
<
ModelType
,
TranscodeType
>
requestListener
;
...
...
@@ -69,6 +65,7 @@ public class GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeT
private
int
overrideHeight
=
-
1
;
private
int
overrideWidth
=
-
1
;
private
DiskCacheStrategy
diskCacheStrategy
=
DiskCacheStrategy
.
RESULT
;
private
Transformation
<
ResourceType
>
transformation
=
UnitTransformation
.
get
();
GenericRequestBuilder
(
Context
context
,
ModelType
model
,
LoadProvider
<
ModelType
,
DataType
,
ResourceType
,
TranscodeType
>
loadProvider
,
...
...
@@ -292,20 +289,18 @@ public class GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeT
}
/**
* Transform
images with the given {@link Transformation}. Appends this transformation onto any existing
* transformations
* Transform
resources with the given {@link Transformation}s. Replaces any existing transformation or
* transformations
.
*
* @param transformation
the transformation to apply
.
* @param transformation
s the transformations to apply in order
.
* @return This RequestBuilder
*/
public
GenericRequestBuilder
<
ModelType
,
DataType
,
ResourceType
,
TranscodeType
>
transform
(
Transformation
<
ResourceType
>
transformation
)
{
if
(
singleTransformation
==
UnitTransformation
.
get
()
)
{
singleTransformation
=
transformation
;
Transformation
<
ResourceType
>
...
transformations
)
{
if
(
transformations
.
length
==
1
)
{
transformation
=
transformations
[
0
]
;
}
else
{
transformations
=
new
ArrayList
<
Transformation
<
ResourceType
>>();
transformations
.
add
(
singleTransformation
);
transformations
.
add
(
transformation
);
transformation
=
new
MultiTransformation
<
ResourceType
>(
transformations
);
}
return
this
;
...
...
@@ -651,7 +646,7 @@ public class GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeT
requestListener
,
requestCoordinator
,
glide
.
getEngine
(),
getFinalTransformation
()
,
transformation
,
transcodeClass
,
isCacheable
,
animationFactory
,
...
...
@@ -659,13 +654,4 @@ public class GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeT
overrideHeight
,
diskCacheStrategy
);
}
@SuppressWarnings
(
"unchecked"
)
private
Transformation
<
ResourceType
>
getFinalTransformation
()
{
if
(
transformations
==
null
)
{
return
singleTransformation
;
}
else
{
return
new
MultiTransformation
<
ResourceType
>(
transformations
);
}
}
}
library/src/main/java/com/bumptech/glide/GifRequestBuilder.java
浏览文件 @
876b9f6a
...
...
@@ -141,7 +141,9 @@ public class GifRequestBuilder<ModelType> extends GenericRequestBuilder<ModelTyp
/**
* Transforms each frame of the GIF using {@link com.bumptech.glide.load.resource.bitmap.CenterCrop}.
*
* @see #transformFrame(com.bumptech.glide.load.Transformation)
* @see #transformFrame(com.bumptech.glide.load.Transformation[])
* @see #fitCenter()
* @see #transform(com.bumptech.glide.load.Transformation[])
*
* @return This request builder.
*/
...
...
@@ -152,7 +154,9 @@ public class GifRequestBuilder<ModelType> extends GenericRequestBuilder<ModelTyp
/**
* Transforms each frame of the GIF using {@link com.bumptech.glide.load.resource.bitmap.FitCenter}.
*
* @see #transformFrame(com.bumptech.glide.load.Transformation)
* @see #transformFrame(com.bumptech.glide.load.Transformation[])
* @see #centerCrop()
* @see #transform(com.bumptech.glide.load.Transformation[])
*
* @return This request builder..
*/
...
...
@@ -163,19 +167,33 @@ public class GifRequestBuilder<ModelType> extends GenericRequestBuilder<ModelTyp
/**
* Transforms each frame of the GIF using the given transformation.
*
* @param bitmapTransformation The transformation to use.
* @see #fitCenter()
* @see #centerCrop()
* @see #transform(com.bumptech.glide.load.Transformation[])
*
* @param bitmapTransformations The transformation to use.
* @return This request builder.
*/
public
GifRequestBuilder
<
ModelType
>
transformFrame
(
Transformation
<
Bitmap
>
bitmapTransformation
)
{
return
transform
(
new
GifDataTransformation
(
bitmapTransformation
));
public
GifRequestBuilder
<
ModelType
>
transformFrame
(
Transformation
<
Bitmap
>...
bitmapTransformations
)
{
GifDataTransformation
[]
transformations
=
new
GifDataTransformation
[
bitmapTransformations
.
length
];
for
(
int
i
=
0
;
i
<
bitmapTransformations
.
length
;
i
++)
{
transformations
[
i
]
=
new
GifDataTransformation
(
bitmapTransformations
[
i
]);
}
return
transform
(
transformations
);
}
/**
* {@inheritDoc}
*
* @see #fitCenter()
* @see #centerCrop()
* @see #transformFrame(com.bumptech.glide.load.Transformation[])
*
*/
@Override
public
GifRequestBuilder
<
ModelType
>
transform
(
Transformation
<
GifData
>
transformation
)
{
super
.
transform
(
transformation
);
public
GifRequestBuilder
<
ModelType
>
transform
(
Transformation
<
GifData
>
...
transformations
)
{
super
.
transform
(
transformation
s
);
return
this
;
}
...
...
library/src/test/java/com/bumptech/glide/GenericRequestBuilderTest.java
浏览文件 @
876b9f6a
...
...
@@ -7,8 +7,8 @@ import com.bumptech.glide.load.ResourceEncoder;
import
com.bumptech.glide.load.engine.DiskCacheStrategy
;
import
com.bumptech.glide.manager.RequestTracker
;
import
com.bumptech.glide.provider.LoadProvider
;
import
com.bumptech.glide.request.animation.GlideAnimationFactory
;
import
com.bumptech.glide.request.Request
;
import
com.bumptech.glide.request.animation.GlideAnimationFactory
;
import
com.bumptech.glide.request.target.Target
;
import
com.bumptech.glide.tests.BackgroundUtil
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录