Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
沉迷打码的小凳子
glide
提交
feec80e8
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,发现更多精彩内容 >>
提交
feec80e8
编写于
6月 12, 2014
作者:
S
Sam Judd
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add timing logs for runners.
上级
8e936252
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
32 addition
and
4 deletion
+32
-4
library/src/main/java/com/bumptech/glide/load/engine/ResourceRunner.java
...n/java/com/bumptech/glide/load/engine/ResourceRunner.java
+6
-1
library/src/main/java/com/bumptech/glide/load/engine/SourceResourceRunner.java
.../com/bumptech/glide/load/engine/SourceResourceRunner.java
+23
-3
library/src/test/java/com/bumptech/glide/load/engine/SourceResourceRunnerTest.java
.../bumptech/glide/load/engine/SourceResourceRunnerTest.java
+3
-0
未找到文件。
library/src/main/java/com/bumptech/glide/load/engine/ResourceRunner.java
浏览文件 @
feec80e8
package
com.bumptech.glide.load.engine
;
import
android.os.Handler
;
import
android.os.SystemClock
;
import
android.util.Log
;
import
com.bumptech.glide.Resource
;
import
com.bumptech.glide.load.Key
;
...
...
@@ -72,7 +73,11 @@ public class ResourceRunner<Z, R> implements Runnable {
return
;
}
long
start
=
SystemClock
.
currentThreadTimeMillis
();
Resource
<
Z
>
fromCache
=
loadFromDiskCache
();
if
(
Log
.
isLoggable
(
TAG
,
Log
.
VERBOSE
))
{
Log
.
v
(
TAG
,
"loaded from disk cache in "
+
(
SystemClock
.
currentThreadTimeMillis
()
-
start
));
}
if
(
fromCache
!=
null
)
{
Resource
<
R
>
transcoded
=
transcoder
.
transcode
(
fromCache
);
job
.
onResourceReady
(
transcoded
);
...
...
@@ -94,7 +99,7 @@ public class ResourceRunner<Z, R> implements Runnable {
}
if
(
result
==
null
)
{
if
(
Log
.
isLoggable
(
TAG
,
Log
.
DEBUG
))
{
Log
.
d
(
TAG
,
"Failed to decode image from cache"
);
Log
.
d
(
TAG
,
"Failed to decode image from cache
or not present in cache
"
);
}
diskCache
.
delete
(
key
);
}
...
...
library/src/main/java/com/bumptech/glide/load/engine/SourceResourceRunner.java
浏览文件 @
feec80e8
package
com.bumptech.glide.load.engine
;
import
android.os.SystemClock
;
import
android.util.Log
;
import
com.bumptech.glide.Priority
;
import
com.bumptech.glide.Resource
;
import
com.bumptech.glide.load.Key
;
import
com.bumptech.glide.load.ResourceDecoder
;
import
com.bumptech.glide.load.ResourceEncoder
;
import
com.bumptech.glide.load.Transformation
;
import
com.bumptech.glide.load.
resource.transcode.ResourceTranscod
er
;
import
com.bumptech.glide.load.
data.DataFetch
er
;
import
com.bumptech.glide.load.engine.cache.DiskCache
;
import
com.bumptech.glide.load.engine.executor.Prioritized
;
import
com.bumptech.glide.load.
data.DataFetch
er
;
import
com.bumptech.glide.load.
resource.transcode.ResourceTranscod
er
;
import
com.bumptech.glide.request.ResourceCallback
;
import
java.io.OutputStream
;
...
...
@@ -21,6 +23,7 @@ import java.io.OutputStream;
* @param <R> The type of the resource that will be transcoded to from the decoded resource.
*/
public
class
SourceResourceRunner
<
T
,
Z
,
R
>
implements
Runnable
,
DiskCache
.
Writer
,
Prioritized
{
private
static
final
String
TAG
=
"SourceRunner"
;
private
final
Key
key
;
private
final
int
width
;
private
final
int
height
;
...
...
@@ -63,7 +66,12 @@ public class SourceResourceRunner<T, Z, R> implements Runnable, DiskCache.Writer
}
try
{
long
start
=
SystemClock
.
currentThreadTimeMillis
();
final
Resource
<
Z
>
decoded
=
decode
();
if
(
Log
.
isLoggable
(
TAG
,
Log
.
VERBOSE
))
{
Log
.
v
(
TAG
,
"Decoded from source in "
+
(
SystemClock
.
currentThreadTimeMillis
()
-
start
));
start
=
SystemClock
.
currentThreadTimeMillis
();
}
if
(
decoded
!=
null
)
{
Resource
<
Z
>
transformed
=
transformation
.
transform
(
decoded
,
width
,
height
);
if
(
decoded
!=
transformed
)
{
...
...
@@ -71,10 +79,17 @@ public class SourceResourceRunner<T, Z, R> implements Runnable, DiskCache.Writer
}
result
=
transformed
;
}
if
(
Log
.
isLoggable
(
TAG
,
Log
.
VERBOSE
))
{
Log
.
v
(
TAG
,
"transformed in "
+
(
SystemClock
.
currentThreadTimeMillis
()
-
start
));
}
if
(
result
!=
null
)
{
diskCache
.
put
(
key
,
this
);
start
=
SystemClock
.
currentThreadTimeMillis
();
Resource
<
R
>
transcoded
=
transcoder
.
transcode
(
result
);
if
(
Log
.
isLoggable
(
TAG
,
Log
.
VERBOSE
))
{
Log
.
d
(
TAG
,
"transcoded in "
+
(
SystemClock
.
currentThreadTimeMillis
()
-
start
));
}
cb
.
onResourceReady
(
transcoded
);
}
else
{
cb
.
onException
(
null
);
...
...
@@ -100,7 +115,12 @@ public class SourceResourceRunner<T, Z, R> implements Runnable, DiskCache.Writer
@Override
public
boolean
write
(
OutputStream
os
)
{
return
encoder
.
encode
(
result
,
os
);
long
start
=
SystemClock
.
currentThreadTimeMillis
();
boolean
success
=
encoder
.
encode
(
result
,
os
);
if
(
Log
.
isLoggable
(
TAG
,
Log
.
VERBOSE
))
{
Log
.
v
(
TAG
,
"wrote to disk cache in "
+
(
SystemClock
.
currentThreadTimeMillis
()
-
start
));
}
return
success
;
}
@Override
...
...
library/src/test/java/com/bumptech/glide/load/engine/SourceResourceRunnerTest.java
浏览文件 @
feec80e8
...
...
@@ -12,6 +12,8 @@ import com.bumptech.glide.load.resource.transcode.ResourceTranscoder;
import
com.bumptech.glide.request.ResourceCallback
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.robolectric.RobolectricTestRunner
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
...
...
@@ -32,6 +34,7 @@ import static org.mockito.Mockito.never;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
@RunWith
(
RobolectricTestRunner
.
class
)
public
class
SourceResourceRunnerTest
{
private
SourceResourceHarness
harness
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录