Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
沉迷打码的小凳子
glide
提交
4f987933
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,发现更多精彩内容 >>
提交
4f987933
编写于
12月 02, 2013
作者:
S
Sam Judd
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
code cleanup
上级
715fdf9b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
17 addition
and
15 deletion
+17
-15
library/src/com/bumptech/glide/ListPreloader.java
library/src/com/bumptech/glide/ListPreloader.java
+15
-13
samples/flickr/src/com/bumptech/glide/samples/flickr/FlickrPhotoGrid.java
...rc/com/bumptech/glide/samples/flickr/FlickrPhotoGrid.java
+1
-1
samples/flickr/src/com/bumptech/glide/samples/flickr/FlickrPhotoList.java
...rc/com/bumptech/glide/samples/flickr/FlickrPhotoList.java
+1
-1
未找到文件。
library/src/com/bumptech/glide/ListPreloader.java
浏览文件 @
4f987933
...
...
@@ -6,6 +6,7 @@ import android.graphics.Bitmap;
import
android.os.Build
;
import
android.widget.AbsListView
;
import
com.bumptech.glide.presenter.target.SimpleTarget
;
import
com.bumptech.glide.util.Log
;
import
java.util.ArrayDeque
;
import
java.util.LinkedList
;
...
...
@@ -37,7 +38,7 @@ public abstract class ListPreloader<T> implements AbsListView.OnScrollListener {
private
boolean
isIncreasing
=
true
;
/**
* C
reate
the preloader.
* C
onstructor for
the preloader.
*
* @param context A context
* @param maxPreload The maximum number of items in the list to load ahead (corresponds to adapter positions).
...
...
@@ -63,18 +64,18 @@ public abstract class ListPreloader<T> implements AbsListView.OnScrollListener {
}
/**
*
Get
the dimensions of the view in the list where the images will be displayed.
*
Returns
the dimensions of the view in the list where the images will be displayed.
* <p>
* Note - The dimensions returned here must precisely match those of the view in the list.
* </p>
* @param item A model
* @return The dimensions of the view where the item will be displayed
*/
protected
abstract
int
[]
getDimens
(
T
item
);
protected
abstract
int
[]
getDimens
ions
(
T
item
);
/**
*
Get a list of all models that need to be loaded for the list to display adapter items start - end. A list of any
* size can be returned so there can be multiple models per adapter position.
*
Returns a list of all models that need to be loaded for the list to display adapter items start - end. A list of
*
any
size can be returned so there can be multiple models per adapter position.
*
* @param start The smallest adapter position. Will be >= 0 && < adapter.getCount() && <= end
* @param end The largest adapter position. Will be >= 0 && < adapter.getCount && >= start
...
...
@@ -83,7 +84,7 @@ public abstract class ListPreloader<T> implements AbsListView.OnScrollListener {
protected
abstract
List
<
T
>
getItems
(
int
start
,
int
end
);
/**
*
Get
a glide request for a given item. Must exactly match the request used to load the image in the list. The
*
Returns
a glide request for a given item. Must exactly match the request used to load the image in the list. The
* target and context will be provided by the preloader.
*
* @param item The model to load.
...
...
@@ -113,15 +114,16 @@ public abstract class ListPreloader<T> implements AbsListView.OnScrollListener {
start
=
Math
.
min
(
totalItemCount
,
Math
.
max
(
0
,
start
));
List
<
T
>
items
=
getItems
(
start
,
end
);
// Increasing
if
(
from
<
to
)
{
// Increasing
final
int
numItems
=
items
.
size
();
for
(
int
i
=
0
;
i
<
numItems
;
i
++)
{
preload
(
items
,
i
);
preload
Item
(
items
,
i
);
}
}
else
{
// Decreasing
for
(
int
i
=
items
.
size
()
-
1
;
i
>=
0
;
i
--)
{
preload
(
items
,
i
);
preload
Item
(
items
,
i
);
}
}
...
...
@@ -129,11 +131,11 @@ public abstract class ListPreloader<T> implements AbsListView.OnScrollListener {
lastEnd
=
end
;
}
private
void
preload
(
List
<
T
>
items
,
int
position
)
{
private
void
preload
Item
(
List
<
T
>
items
,
int
position
)
{
final
T
item
=
items
.
get
(
position
);
final
int
[]
dimens
=
getDime
ns
(
item
);
if
(
dimens
!=
null
)
{
getRequest
(
item
).
into
(
preloadTargetQueue
.
next
(
dimens
[
0
],
dime
ns
[
1
])).
with
(
context
);
final
int
[]
dimens
ions
=
getDimensio
ns
(
item
);
if
(
dimens
ions
!=
null
)
{
getRequest
(
item
).
into
(
preloadTargetQueue
.
next
(
dimens
ions
[
0
],
dimensio
ns
[
1
])).
with
(
context
);
}
}
...
...
samples/flickr/src/com/bumptech/glide/samples/flickr/FlickrPhotoGrid.java
浏览文件 @
4f987933
...
...
@@ -75,7 +75,7 @@ public class FlickrPhotoGrid extends SherlockFragment implements PhotoViewer {
}
@Override
protected
int
[]
getDimens
(
Photo
item
)
{
protected
int
[]
getDimens
ions
(
Photo
item
)
{
return
dimens
;
}
...
...
samples/flickr/src/com/bumptech/glide/samples/flickr/FlickrPhotoList.java
浏览文件 @
4f987933
...
...
@@ -84,7 +84,7 @@ public class FlickrPhotoList extends SherlockFragment implements PhotoViewer {
}
@Override
protected
int
[]
getDimens
(
Photo
item
)
{
protected
int
[]
getDimens
ions
(
Photo
item
)
{
return
photoDimens
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录