Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
沉迷打码的小凳子
glide
提交
3d81fc2b
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,发现更多精彩内容 >>
提交
3d81fc2b
编写于
9月 06, 2014
作者:
S
Sam Judd
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Code comment fixes for RequestManagerRetriever.
上级
00b0acca
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
25 addition
and
14 deletion
+25
-14
library/src/androidTest/java/com/bumptech/glide/manager/Issue117Activity.java
...est/java/com/bumptech/glide/manager/Issue117Activity.java
+2
-3
library/src/androidTest/java/com/bumptech/glide/manager/RequestManagerRetrieverTest.java
...m/bumptech/glide/manager/RequestManagerRetrieverTest.java
+8
-6
library/src/main/java/com/bumptech/glide/manager/RequestManagerRetriever.java
...a/com/bumptech/glide/manager/RequestManagerRetriever.java
+15
-5
未找到文件。
library/src/androidTest/java/com/bumptech/glide/manager/Issue117Activity.java
浏览文件 @
3d81fc2b
...
...
@@ -16,13 +16,12 @@ import com.bumptech.glide.Glide;
/**
* A test activity to reproduce Issue #117: https://github.com/bumptech/glide/issues/117.
*/
public
class
Issue117Activity
extends
FragmentActivity
{
class
Issue117Activity
extends
FragmentActivity
{
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
ViewPager
viewPager
=
new
ViewPager
(
this
);
int
id
=
View
.
generateViewId
();
viewPager
.
setId
(
id
);
viewPager
.
setId
(
View
.
generateViewId
());
setContentView
(
viewPager
,
new
ViewGroup
.
LayoutParams
(
ViewGroup
.
LayoutParams
.
MATCH_PARENT
,
ViewGroup
.
LayoutParams
.
MATCH_PARENT
));
viewPager
.
setAdapter
(
new
Issue117Adapter
(
getSupportFragmentManager
()));
...
...
library/src/androidTest/java/com/bumptech/glide/manager/RequestManagerRetrieverTest.java
浏览文件 @
3d81fc2b
...
...
@@ -20,7 +20,7 @@ import org.robolectric.util.ActivityController;
import
static
com
.
bumptech
.
glide
.
tests
.
BackgroundUtil
.
testInBackground
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
hamcrest
.
Matchers
.
empty
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
...
...
@@ -40,14 +40,13 @@ public class RequestManagerRetrieverTest {
retriever
=
new
RequestManagerRetriever
();
harnesses
=
new
RetrieverHarness
[]
{
new
DefaultRetrieverHarness
(),
new
SupportRetrieverHarness
()
};
Robolectric
.
shadowOf
(
Looper
.
getMainLooper
()).
pause
();
}
@After
public
void
tearDown
()
{
Robolectric
.
shadowOf
(
Looper
.
getMainLooper
()).
runToEndOfTasks
();
assertT
rue
(
retriever
.
pendingRequestManagerFragments
.
isE
mpty
());
assertT
rue
(
retriever
.
pendingSupportRequestManagerFragments
.
isE
mpty
());
assertT
hat
(
retriever
.
pendingRequestManagerFragments
.
entrySet
(),
e
mpty
());
assertT
hat
(
retriever
.
pendingSupportRequestManagerFragments
.
entrySet
(),
e
mpty
());
}
@Test
...
...
@@ -56,7 +55,7 @@ public class RequestManagerRetrieverTest {
harness
.
doGet
();
Robolectric
.
shadowOf
(
Looper
.
getMainLooper
()).
runToEndOfTasks
();
assertT
hat
(
harness
.
hasFragmentWithTag
(
RequestManagerRetriever
.
TAG
),
is
(
true
));
assertT
rue
(
harness
.
hasFragmentWithTag
(
RequestManagerRetriever
.
TAG
));
}
}
...
...
@@ -241,8 +240,11 @@ public class RequestManagerRetrieverTest {
// See Issue #117: https://github.com/bumptech/glide/issues/117.
@Test
public
void
testCanCallGetInOnAttachToWindowInFragmentInViewPager
()
{
// Robolectric by default runs messages posted to the main looper synchronously, the framework does not. We post
// to the main thread here to work around an issue caused by a recursive method call so we need (and reasonably
// expect) our message to not run immediately
Robolectric
.
shadowOf
(
Looper
.
getMainLooper
()).
pause
();
Robolectric
.
buildActivity
(
Issue117Activity
.
class
).
create
().
start
().
resume
().
visible
();
Robolectric
.
shadowOf
(
Looper
.
getMainLooper
()).
runToEndOfTasks
();
}
private
interface
RetrieverHarness
{
...
...
library/src/main/java/com/bumptech/glide/manager/RequestManagerRetriever.java
浏览文件 @
3d81fc2b
...
...
@@ -12,6 +12,7 @@ import android.os.Message;
import
android.support.v4.app.Fragment
;
import
android.support.v4.app.FragmentActivity
;
import
android.support.v4.app.FragmentManager
;
import
android.util.Log
;
import
com.bumptech.glide.RequestManager
;
import
com.bumptech.glide.util.Util
;
...
...
@@ -202,17 +203,26 @@ public class RequestManagerRetriever implements Handler.Callback {
@Override
public
boolean
handleMessage
(
Message
message
)
{
boolean
handled
=
true
;
Object
removed
=
null
;
Object
key
=
null
;
switch
(
message
.
what
)
{
case
ID_REMOVE_FRAGMENT_MANAGER:
android
.
app
.
FragmentManager
fm
=
(
android
.
app
.
FragmentManager
)
message
.
obj
;
pendingRequestManagerFragments
.
remove
(
fm
);
return
true
;
key
=
fm
;
removed
=
pendingRequestManagerFragments
.
remove
(
fm
);
break
;
case
ID_REMOVE_SUPPORT_FRAGMENT_MANAGER:
FragmentManager
supportFm
=
(
FragmentManager
)
message
.
obj
;
pendingSupportRequestManagerFragments
.
remove
(
supportFm
);
return
true
;
key
=
supportFm
;
removed
=
pendingSupportRequestManagerFragments
.
remove
(
supportFm
);
break
;
default
:
return
false
;
handled
=
false
;
}
if
(
handled
&&
removed
==
null
&&
Log
.
isLoggable
(
TAG
,
Log
.
WARN
))
{
Log
.
w
(
TAG
,
"Failed to remove expected request manager fragment, manager: "
+
key
);
}
return
handled
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录