Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
门心叼龙
flexbox-layout
提交
d277195a
F
flexbox-layout
项目概览
门心叼龙
/
flexbox-layout
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
flexbox-layout
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
d277195a
编写于
5月 31, 2016
作者:
T
Takeshi Hagikura
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes the #47
Change-Id: I6951cb986e096276255374e5962084353471a2ee
上级
163d5714
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
159 addition
and
10 deletion
+159
-10
flexbox/src/androidTest/java/com/google/android/flexbox/test/FlexboxAndroidTest.java
...a/com/google/android/flexbox/test/FlexboxAndroidTest.java
+58
-0
flexbox/src/androidTest/res/layout/activity_visibility_gone_first_item_in_flex_line_column.xml
...tivity_visibility_gone_first_item_in_flex_line_column.xml
+43
-0
flexbox/src/androidTest/res/layout/activity_visibility_gone_first_item_in_flex_line_row.xml
.../activity_visibility_gone_first_item_in_flex_line_row.xml
+43
-0
flexbox/src/main/java/com/google/android/flexbox/FlexboxLayout.java
...c/main/java/com/google/android/flexbox/FlexboxLayout.java
+15
-10
未找到文件。
flexbox/src/androidTest/java/com/google/android/flexbox/test/FlexboxAndroidTest.java
浏览文件 @
d277195a
...
...
@@ -2583,6 +2583,64 @@ public class FlexboxAndroidTest {
assertThat
(
textView5
.
getTop
(),
is
(
textView3
.
getBottom
()));
}
@Test
@FlakyTest
(
tolerance
=
TOLERANCE
)
public
void
testView_visibility_gone_first_item_in_flex_line_horizontal
()
throws
Throwable
{
// This test verifies if the FlexboxLayout is visible when the visibility of the first
// flex item in the second flex line (or arbitrary flex lines other than the first flex line)
// is set to "gone"
// There was an issue reported for that
// https://github.com/google/flexbox-layout/issues/47
final
FlexboxTestActivity
activity
=
mActivityRule
.
getActivity
();
mActivityRule
.
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
activity
.
setContentView
(
R
.
layout
.
activity_visibility_gone_first_item_in_flex_line_row
);
}
});
InstrumentationRegistry
.
getInstrumentation
().
waitForIdleSync
();
FlexboxLayout
flexboxLayout
=
(
FlexboxLayout
)
activity
.
findViewById
(
R
.
id
.
flexbox_layout
);
assertThat
(
flexboxLayout
.
getFlexWrap
(),
is
(
FlexboxLayout
.
FLEX_WRAP_WRAP
));
assertThat
(
flexboxLayout
.
getFlexDirection
(),
is
(
FlexboxLayout
.
FLEX_DIRECTION_ROW
));
TextView
textView1
=
(
TextView
)
activity
.
findViewById
(
R
.
id
.
text1
);
TextView
textView3
=
(
TextView
)
activity
.
findViewById
(
R
.
id
.
text3
);
assertTrue
(
flexboxLayout
.
getHeight
()
>
0
);
assertThat
(
flexboxLayout
.
getHeight
(),
is
(
textView1
.
getHeight
()
+
textView3
.
getHeight
()));
}
@Test
@FlakyTest
(
tolerance
=
TOLERANCE
)
public
void
testView_visibility_gone_first_item_in_flex_line_vertical
()
throws
Throwable
{
// This test verifies if the FlexboxLayout is visible when the visibility of the first
// flex item in the second flex line (or arbitrary flex lines other than the first flex line)
// is set to "gone"
// There was an issue reported for that
// https://github.com/google/flexbox-layout/issues/47
final
FlexboxTestActivity
activity
=
mActivityRule
.
getActivity
();
mActivityRule
.
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
activity
.
setContentView
(
R
.
layout
.
activity_visibility_gone_first_item_in_flex_line_column
);
}
});
InstrumentationRegistry
.
getInstrumentation
().
waitForIdleSync
();
FlexboxLayout
flexboxLayout
=
(
FlexboxLayout
)
activity
.
findViewById
(
R
.
id
.
flexbox_layout
);
assertThat
(
flexboxLayout
.
getFlexWrap
(),
is
(
FlexboxLayout
.
FLEX_WRAP_WRAP
));
assertThat
(
flexboxLayout
.
getFlexDirection
(),
is
(
FlexboxLayout
.
FLEX_DIRECTION_COLUMN
));
TextView
textView1
=
(
TextView
)
activity
.
findViewById
(
R
.
id
.
text1
);
TextView
textView3
=
(
TextView
)
activity
.
findViewById
(
R
.
id
.
text3
);
assertTrue
(
flexboxLayout
.
getWidth
()
>
0
);
assertThat
(
flexboxLayout
.
getWidth
(),
is
(
textView1
.
getWidth
()
+
textView3
.
getWidth
()));
}
@Test
@FlakyTest
(
tolerance
=
TOLERANCE
)
public
void
testView_visibility_invisible
()
throws
Throwable
{
...
...
flexbox/src/androidTest/res/layout/activity_visibility_gone_first_item_in_flex_line_column.xml
0 → 100644
浏览文件 @
d277195a
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2016 Google Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<com.google.android.flexbox.FlexboxLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:id=
"@+id/flexbox_layout"
android:layout_width=
"wrap_content"
android:layout_height=
"360dp"
app:flexDirection=
"column"
app:flexWrap=
"wrap"
>
<TextView
android:id=
"@+id/text1"
android:layout_width=
"wrap_content"
android:layout_height=
"160dp"
android:text=
"1"
/>
<TextView
android:id=
"@+id/text2"
android:layout_width=
"wrap_content"
android:layout_height=
"160dp"
android:text=
"2"
/>
<TextView
android:id=
"@+id/text3"
android:layout_width=
"wrap_content"
android:layout_height=
"160dp"
android:visibility=
"gone"
android:text=
"3"
/>
</com.google.android.flexbox.FlexboxLayout>
flexbox/src/androidTest/res/layout/activity_visibility_gone_first_item_in_flex_line_row.xml
0 → 100644
浏览文件 @
d277195a
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2016 Google Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<com.google.android.flexbox.FlexboxLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:id=
"@+id/flexbox_layout"
android:layout_width=
"360dp"
android:layout_height=
"wrap_content"
app:flexDirection=
"row"
app:flexWrap=
"wrap"
>
<TextView
android:id=
"@+id/text1"
android:layout_width=
"160dp"
android:layout_height=
"wrap_content"
android:text=
"1"
/>
<TextView
android:id=
"@+id/text2"
android:layout_width=
"160dp"
android:layout_height=
"wrap_content"
android:text=
"2"
/>
<TextView
android:id=
"@+id/text3"
android:layout_width=
"160dp"
android:layout_height=
"wrap_content"
android:visibility=
"gone"
android:text=
"3"
/>
</com.google.android.flexbox.FlexboxLayout>
flexbox/src/main/java/com/google/android/flexbox/FlexboxLayout.java
浏览文件 @
d277195a
...
...
@@ -442,9 +442,11 @@ public class FlexboxLayout extends ViewGroup {
for
(
int
i
=
0
;
i
<
childCount
;
i
++)
{
View
child
=
getReorderedChildAt
(
i
);
if
(
child
==
null
)
{
addFlexLineIfLastFlexItem
(
i
,
childCount
,
paddingEnd
,
flexLine
);
continue
;
}
else
if
(
child
.
getVisibility
()
==
View
.
GONE
)
{
flexLine
.
itemCount
++;
addFlexLineIfLastFlexItem
(
i
,
childCount
,
paddingEnd
,
flexLine
);
continue
;
}
...
...
@@ -519,11 +521,7 @@ public class FlexboxLayout extends ViewGroup {
child
.
getMeasuredHeight
()
-
child
.
getBaseline
()
+
lp
.
bottomMargin
);
}
if
(
i
==
childCount
-
1
&&
flexLine
.
itemCount
!=
0
)
{
// Add the flex line if this item is the last item
flexLine
.
mainSize
+=
paddingEnd
;
mFlexLines
.
add
(
flexLine
);
}
addFlexLineIfLastFlexItem
(
i
,
childCount
,
paddingEnd
,
flexLine
);
}
}
...
...
@@ -595,9 +593,11 @@ public class FlexboxLayout extends ViewGroup {
for
(
int
i
=
0
;
i
<
childCount
;
i
++)
{
View
child
=
getReorderedChildAt
(
i
);
if
(
child
==
null
)
{
addFlexLineIfLastFlexItem
(
i
,
childCount
,
paddingBottom
,
flexLine
);
continue
;
}
else
if
(
child
.
getVisibility
()
==
View
.
GONE
)
{
flexLine
.
itemCount
++;
addFlexLineIfLastFlexItem
(
i
,
childCount
,
paddingBottom
,
flexLine
);
continue
;
}
...
...
@@ -660,11 +660,7 @@ public class FlexboxLayout extends ViewGroup {
// later
flexLine
.
crossSize
=
Math
.
max
(
flexLine
.
crossSize
,
largestWidthInColumn
);
if
(
i
==
childCount
-
1
&&
flexLine
.
itemCount
!=
0
)
{
// Add the flex line if this item is the last item
flexLine
.
mainSize
+=
paddingBottom
;
mFlexLines
.
add
(
flexLine
);
}
addFlexLineIfLastFlexItem
(
i
,
childCount
,
paddingBottom
,
flexLine
);
}
determineMainSize
(
mFlexDirection
,
widthMeasureSpec
,
heightMeasureSpec
);
...
...
@@ -676,6 +672,15 @@ public class FlexboxLayout extends ViewGroup {
childState
);
}
private
void
addFlexLineIfLastFlexItem
(
int
childIndex
,
int
childCount
,
int
paddingToAdd
,
FlexLine
flexLine
)
{
if
(
childIndex
==
childCount
-
1
&&
flexLine
.
itemCount
!=
0
)
{
// Add the flex line if this item is the last item
flexLine
.
mainSize
+=
paddingToAdd
;
mFlexLines
.
add
(
flexLine
);
}
}
/**
* Determine the main size by expanding (shrinking if negative remaining free space is given)
* an individual child in each flex line if any children's flexGrow (or flexShrink if remaining
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录