Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
沉迷打码的小凳子
glide
提交
96fd2499
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,发现更多精彩内容 >>
提交
96fd2499
编写于
8月 17, 2014
作者:
S
Sam Judd
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Don't cancel new runners from old jobs.
Fixes #91
上级
5bd4f957
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
34 addition
and
12 deletion
+34
-12
library/src/androidTest/java/com/bumptech/glide/load/engine/EngineJobTest.java
...st/java/com/bumptech/glide/load/engine/EngineJobTest.java
+5
-4
library/src/androidTest/java/com/bumptech/glide/load/engine/EngineTest.java
...dTest/java/com/bumptech/glide/load/engine/EngineTest.java
+20
-2
library/src/main/java/com/bumptech/glide/load/engine/Engine.java
.../src/main/java/com/bumptech/glide/load/engine/Engine.java
+6
-3
library/src/main/java/com/bumptech/glide/load/engine/EngineJob.java
...c/main/java/com/bumptech/glide/load/engine/EngineJob.java
+2
-2
library/src/main/java/com/bumptech/glide/load/engine/EngineJobListener.java
...ava/com/bumptech/glide/load/engine/EngineJobListener.java
+1
-1
未找到文件。
library/src/androidTest/java/com/bumptech/glide/load/engine/EngineJobTest.java
浏览文件 @
96fd2499
...
...
@@ -105,9 +105,10 @@ public class EngineJobTest {
@Test
public
void
testListenerNotifiedOfCancelOnCancel
()
{
harness
.
getJob
().
cancel
();
EngineJob
job
=
harness
.
getJob
();
job
.
cancel
();
verify
(
harness
.
listener
).
onEngineJobCancelled
(
eq
(
harness
.
key
));
verify
(
harness
.
listener
).
onEngineJobCancelled
(
eq
(
job
),
eq
(
harness
.
key
));
}
@Test
...
...
@@ -164,7 +165,7 @@ public class EngineJobTest {
job
.
onResourceReady
(
harness
.
resource
);
job
.
cancel
();
verify
(
harness
.
listener
,
never
()).
onEngineJobCancelled
(
eq
(
harness
.
key
));
verify
(
harness
.
listener
,
never
()).
onEngineJobCancelled
(
eq
(
job
),
eq
(
harness
.
key
));
}
@Test
...
...
@@ -173,7 +174,7 @@ public class EngineJobTest {
job
.
cancel
();
job
.
cancel
();
verify
(
harness
.
listener
,
times
(
1
)).
onEngineJobCancelled
(
eq
(
harness
.
key
));
verify
(
harness
.
listener
,
times
(
1
)).
onEngineJobCancelled
(
eq
(
job
),
eq
(
harness
.
key
));
}
@Test
...
...
library/src/androidTest/java/com/bumptech/glide/load/engine/EngineTest.java
浏览文件 @
96fd2499
...
...
@@ -290,7 +290,7 @@ public class EngineTest {
public
void
testRunnerIsRemovedFromRunnersOnEngineNotifiedJobCancel
()
{
harness
.
doLoad
();
harness
.
engine
.
onEngineJobCancelled
(
harness
.
cacheKey
);
harness
.
engine
.
onEngineJobCancelled
(
harness
.
job
,
harness
.
cacheKey
);
assertFalse
(
harness
.
runners
.
containsKey
(
harness
.
cacheKey
));
}
...
...
@@ -299,11 +299,29 @@ public class EngineTest {
public
void
testRunnerIsCancelledOnEngineNotifiedJobCanceled
()
{
harness
.
doLoad
();
harness
.
engine
.
onEngineJobCancelled
(
harness
.
cacheKey
);
harness
.
engine
.
onEngineJobCancelled
(
harness
.
job
,
harness
.
cacheKey
);
verify
(
harness
.
runner
).
cancel
();
}
@Test
public
void
testRunnerIsNotRemovedFromRunnersIfOldJobIsCancelled
()
{
harness
.
doLoad
();
harness
.
engine
.
onEngineJobCancelled
(
mock
(
EngineJob
.
class
),
harness
.
cacheKey
);
assertEquals
(
harness
.
runner
,
harness
.
runners
.
get
(
harness
.
cacheKey
));
}
@Test
public
void
testRunnerIsNotCancelledIfOldJobIsCancelled
()
{
harness
.
doLoad
();
harness
.
engine
.
onEngineJobCancelled
(
mock
(
EngineJob
.
class
),
harness
.
cacheKey
);
verify
(
harness
.
runner
,
never
()).
cancel
();
}
@Test
public
void
testResourceIsAddedToCacheOnReleased
()
{
harness
.
engine
.
onResourceReleased
(
harness
.
cacheKey
,
harness
.
resource
);
...
...
library/src/main/java/com/bumptech/glide/load/engine/Engine.java
浏览文件 @
96fd2499
...
...
@@ -208,10 +208,13 @@ public class Engine implements EngineJobListener, MemoryCache.ResourceRemovedLis
}
@Override
public
void
onEngineJobCancelled
(
Key
key
)
{
ResourceRunner
runner
=
runners
.
remove
(
key
);
public
void
onEngineJobCancelled
(
EngineJob
engineJob
,
Key
key
)
{
ResourceRunner
runner
=
runners
.
get
(
key
);
if
(
runner
.
getJob
()
==
engineJob
)
{
runners
.
remove
(
key
);
runner
.
cancel
();
}
}
@Override
public
void
onResourceRemoved
(
final
Resource
resource
)
{
...
...
library/src/main/java/com/bumptech/glide/load/engine/EngineJob.java
浏览文件 @
96fd2499
...
...
@@ -13,7 +13,7 @@ import java.util.List;
* A class that manages a load by adding and removing callbacks for for the load and notifying callbacks when the
* load completes.
*/
public
class
EngineJob
implements
ResourceCallback
{
class
EngineJob
implements
ResourceCallback
{
private
static
final
String
TAG
=
"EngineJob"
;
private
boolean
isCacheable
;
private
final
EngineJobListener
listener
;
...
...
@@ -61,7 +61,7 @@ public class EngineJob implements ResourceCallback {
return
;
}
isCancelled
=
true
;
listener
.
onEngineJobCancelled
(
key
);
listener
.
onEngineJobCancelled
(
this
,
key
);
}
// Exposed for testing.
...
...
library/src/main/java/com/bumptech/glide/load/engine/EngineJobListener.java
浏览文件 @
96fd2499
...
...
@@ -6,5 +6,5 @@ interface EngineJobListener {
public
void
onEngineJobComplete
(
Key
key
,
Resource
resource
);
public
void
onEngineJobCancelled
(
Key
key
);
public
void
onEngineJobCancelled
(
EngineJob
engineJob
,
Key
key
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录