Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
沉迷打码的小凳子
glide
提交
e7812093
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,发现更多精彩内容 >>
提交
e7812093
编写于
9月 20, 2014
作者:
S
Sam Judd
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Workaround for framework NPE on KitKat.
Fixes #148
上级
a9d87fb5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
16 addition
and
9 deletion
+16
-9
library/src/main/java/com/bumptech/glide/load/engine/bitmap_recycle/SizeStrategy.java
...mptech/glide/load/engine/bitmap_recycle/SizeStrategy.java
+7
-4
library/src/main/java/com/bumptech/glide/util/Util.java
library/src/main/java/com/bumptech/glide/util/Util.java
+9
-5
未找到文件。
library/src/main/java/com/bumptech/glide/load/engine/bitmap_recycle/SizeStrategy.java
浏览文件 @
e7812093
...
...
@@ -3,6 +3,7 @@ package com.bumptech.glide.load.engine.bitmap_recycle;
import
android.annotation.TargetApi
;
import
android.graphics.Bitmap
;
import
android.os.Build
;
import
com.bumptech.glide.util.Util
;
import
java.util.TreeMap
;
...
...
@@ -19,7 +20,8 @@ class SizeStrategy implements LruPoolStrategy {
@Override
public
void
put
(
Bitmap
bitmap
)
{
final
Key
key
=
keyPool
.
get
(
bitmap
.
getAllocationByteCount
());
int
size
=
Util
.
getSize
(
bitmap
);
final
Key
key
=
keyPool
.
get
(
size
);
groupedMap
.
put
(
key
,
bitmap
);
...
...
@@ -52,7 +54,7 @@ class SizeStrategy implements LruPoolStrategy {
public
Bitmap
removeLast
()
{
Bitmap
removed
=
groupedMap
.
removeLast
();
if
(
removed
!=
null
)
{
final
int
removedSize
=
removed
.
getAllocationByteCount
(
);
final
int
removedSize
=
Util
.
getSize
(
removed
);
decrementBitmapOfSize
(
removedSize
);
}
return
removed
;
...
...
@@ -79,7 +81,7 @@ class SizeStrategy implements LruPoolStrategy {
@Override
public
int
getSize
(
Bitmap
bitmap
)
{
return
bitmap
.
getAllocationByteCount
(
);
return
Util
.
getSize
(
bitmap
);
}
@Override
...
...
@@ -97,7 +99,8 @@ class SizeStrategy implements LruPoolStrategy {
}
private
static
String
getBitmapString
(
Bitmap
bitmap
)
{
return
getBitmapString
(
bitmap
.
getAllocationByteCount
());
int
size
=
Util
.
getSize
(
bitmap
);
return
getBitmapString
(
size
);
}
private
static
String
getBitmapString
(
int
size
)
{
...
...
library/src/main/java/com/bumptech/glide/util/Util.java
浏览文件 @
e7812093
...
...
@@ -40,15 +40,19 @@ public class Util {
}
/**
* Returns the in memory size of the given {@link Bitmap}.
* Returns the in memory size of the given {@link Bitmap}
in bytes
.
*/
@TargetApi
(
Build
.
VERSION_CODES
.
KITKAT
)
public
static
int
getSize
(
Bitmap
bitmap
)
{
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
KITKAT
)
{
return
bitmap
.
getHeight
()
*
bitmap
.
getRowBytes
();
}
else
{
return
bitmap
.
getAllocationByteCount
();
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
KITKAT
)
{
// Workaround for KitKat initial release NPE in Bitmap, fixed in MR1. See issue #148.
try
{
return
bitmap
.
getAllocationByteCount
();
}
catch
(
NullPointerException
e
)
{
// Do nothing.
}
}
return
bitmap
.
getHeight
()
*
bitmap
.
getRowBytes
();
}
public
static
void
assertMainThread
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录