Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
沉迷打码的小凳子
glide
提交
29438d5d
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,发现更多精彩内容 >>
提交
29438d5d
编写于
10月 03, 2014
作者:
S
Sam Judd
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add an empty constructor for SimpleTarget.
Fixes #170.
上级
f08ab536
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
47 addition
and
28 deletion
+47
-28
library/src/androidTest/java/com/bumptech/glide/request/target/SimpleTargetTest.java
...a/com/bumptech/glide/request/target/SimpleTargetTest.java
+29
-24
library/src/main/java/com/bumptech/glide/request/target/SimpleTarget.java
.../java/com/bumptech/glide/request/target/SimpleTarget.java
+18
-4
未找到文件。
library/src/androidTest/java/com/bumptech/glide/request/target/SimpleTargetTest.java
浏览文件 @
29438d5d
package
com.bumptech.glide.request.target
;
package
com.bumptech.glide.request.target
;
import
com.bumptech.glide.request.animation.GlideAnimation
;
import
com.bumptech.glide.request.animation.GlideAnimation
;
import
org.junit.Test
;
import
org.junit.Test
;
import
static
org
.
mockito
.
Mockito
.
mock
;
public
class
SimpleTargetTest
{
public
class
SimpleTargetTest
{
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
testThrowsIfGivenWidthIsLessThanZero
()
{
public
void
testThrowsOnGetSizeIfGivenWidthIsLessThanZero
()
{
new
SimpleTarget
<
Object
>(-
1
,
1
)
{
getTarget
(-
1
,
1
).
getSize
(
mock
(
SizeReadyCallback
.
class
));
}
@Override
public
void
onResourceReady
(
Object
resource
,
GlideAnimation
<
Object
>
glideAnimation
)
{
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
};
public
void
testThrowsOnGetSizeIfGivenWidthIsEqualToZero
()
{
getTarget
(
0
,
1
).
getSize
(
mock
(
SizeReadyCallback
.
class
));
}
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
testThrowsIfGivenWidthIsEqualToZero
()
{
public
void
testThrowsOnGetSizeIfGivenHeightIsLessThanZero
()
{
new
SimpleTarget
<
Object
>(
0
,
1
)
{
getTarget
(
1
,
-
1
).
getSize
(
mock
(
SizeReadyCallback
.
class
));
}
@Override
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
onResourceReady
(
Object
resource
,
GlideAnimation
<
Object
>
glideAnimation
)
{
public
void
testThrowsOnGetSizeIfGivenHeightIsEqualToZero
()
{
getTarget
(
1
,
0
).
getSize
(
mock
(
SizeReadyCallback
.
class
));
}
}
@Test
};
public
void
testCanBeConstructedWithoutDimensions
()
{
getTarget
();
}
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
testThrowsIfGivenHeightIsLessThanZero
()
{
public
void
testThrowsOnGetSizeIfConstructedWithoutDimensions
()
{
new
SimpleTarget
<
Object
>(
1
,
-
1
)
{
getTarget
().
getSize
(
mock
(
SizeReadyCallback
.
class
));
}
private
SimpleTarget
<
Object
>
getTarget
()
{
return
new
SimpleTarget
<
Object
>()
{
@Override
@Override
public
void
onResourceReady
(
Object
resource
,
GlideAnimation
<
Object
>
glideAnimation
)
{
public
void
onResourceReady
(
Object
resource
,
GlideAnimation
<
?
super
Object
>
glideAnimation
)
{
// Do nothing.
}
}
};
};
}
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
private
SimpleTarget
<
Object
>
getTarget
(
int
width
,
int
height
)
{
public
void
testThrowsIfGivenHeightIsEqualToZero
()
{
return
new
SimpleTarget
<
Object
>(
width
,
height
)
{
new
SimpleTarget
<
Object
>(
1
,
0
)
{
@Override
@Override
public
void
onResourceReady
(
Object
resource
,
GlideAnimation
<
Object
>
glideAnimation
)
{
public
void
onResourceReady
(
Object
resource
,
GlideAnimation
<
?
super
Object
>
glideAnimation
)
{
// Do nothing.
}
}
};
};
}
}
...
...
library/src/main/java/com/bumptech/glide/request/target/SimpleTarget.java
浏览文件 @
29438d5d
...
@@ -27,6 +27,20 @@ public abstract class SimpleTarget<Z> extends BaseTarget<Z> {
...
@@ -27,6 +27,20 @@ public abstract class SimpleTarget<Z> extends BaseTarget<Z> {
private
final
int
width
;
private
final
int
width
;
private
final
int
height
;
private
final
int
height
;
/**
* Constructor for the target that assumes you will have called
* {@link com.bumptech.glide.GenericRequestBuilder#override(int, int)} on the request builder this target is given
* to.
*
* <p>
* Requests that load into this target will throw an {@link java.lang.IllegalArgumentException} if
* {@link com.bumptech.glide.GenericRequestBuilder#override(int, int)} was not called on the request builder.
* </p>
*/
public
SimpleTarget
()
{
this
(-
1
,
-
1
);
}
/**
/**
* Constructor for the target that takes the desired dimensions of the decoded and/or transformed resource.
* Constructor for the target that takes the desired dimensions of the decoded and/or transformed resource.
*
*
...
@@ -34,10 +48,6 @@ public abstract class SimpleTarget<Z> extends BaseTarget<Z> {
...
@@ -34,10 +48,6 @@ public abstract class SimpleTarget<Z> extends BaseTarget<Z> {
* @param height The desired height of the resource.
* @param height The desired height of the resource.
*/
*/
public
SimpleTarget
(
int
width
,
int
height
)
{
public
SimpleTarget
(
int
width
,
int
height
)
{
if
(
width
<=
0
||
height
<=
0
)
{
throw
new
IllegalArgumentException
(
"Width and height must both be > 0, but given width: "
+
width
+
" and"
+
" height: "
+
height
);
}
this
.
width
=
width
;
this
.
width
=
width
;
this
.
height
=
height
;
this
.
height
=
height
;
}
}
...
@@ -49,6 +59,10 @@ public abstract class SimpleTarget<Z> extends BaseTarget<Z> {
...
@@ -49,6 +59,10 @@ public abstract class SimpleTarget<Z> extends BaseTarget<Z> {
*/
*/
@Override
@Override
public
final
void
getSize
(
SizeReadyCallback
cb
)
{
public
final
void
getSize
(
SizeReadyCallback
cb
)
{
if
(
width
<=
0
||
height
<=
0
)
{
throw
new
IllegalArgumentException
(
"Width and height must both be > 0, but given width: "
+
width
+
" and"
+
" height: "
+
height
+
", either provide dimensions in the constructor or call override()"
);
}
cb
.
onSizeReady
(
width
,
height
);
cb
.
onSizeReady
(
width
,
height
);
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录