Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
门心叼龙
flexbox-layout
提交
780427bb
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 搜索 >>
提交
780427bb
编写于
4月 13, 2017
作者:
T
Takeshi Hagikura
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix format (#258)
上级
5b2fff67
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
56 addition
and
49 deletion
+56
-49
demo-playground/src/main/java/com/google/android/flexbox/FlexItemEditFragment.java
...java/com/google/android/flexbox/FlexItemEditFragment.java
+9
-9
flexbox/src/androidTest/java/com/google/android/flexbox/FlexboxHelperTest.java
...st/java/com/google/android/flexbox/FlexboxHelperTest.java
+12
-10
flexbox/src/androidTest/java/com/google/android/flexbox/test/FlexboxAndroidTest.java
...a/com/google/android/flexbox/test/FlexboxAndroidTest.java
+1
-1
flexbox/src/androidTest/java/com/google/android/flexbox/test/FlexboxLayoutManagerConfigChangeTest.java
...id/flexbox/test/FlexboxLayoutManagerConfigChangeTest.java
+4
-2
flexbox/src/main/java/com/google/android/flexbox/FlexItem.java
...ox/src/main/java/com/google/android/flexbox/FlexItem.java
+2
-2
flexbox/src/main/java/com/google/android/flexbox/FlexLine.java
...ox/src/main/java/com/google/android/flexbox/FlexLine.java
+4
-4
flexbox/src/main/java/com/google/android/flexbox/FlexboxHelper.java
...c/main/java/com/google/android/flexbox/FlexboxHelper.java
+3
-2
flexbox/src/main/java/com/google/android/flexbox/FlexboxItemDecoration.java
...ava/com/google/android/flexbox/FlexboxItemDecoration.java
+6
-6
flexbox/src/main/java/com/google/android/flexbox/FlexboxLayout.java
...c/main/java/com/google/android/flexbox/FlexboxLayout.java
+1
-1
flexbox/src/main/java/com/google/android/flexbox/FlexboxLayoutManager.java
...java/com/google/android/flexbox/FlexboxLayoutManager.java
+14
-12
未找到文件。
demo-playground/src/main/java/com/google/android/flexbox/FlexItemEditFragment.java
浏览文件 @
780427bb
...
...
@@ -16,14 +16,6 @@
package
com.google.android.flexbox
;
import
com.google.android.apps.flexbox.R
;
import
com.google.android.flexbox.validators.DimensionInputValidator
;
import
com.google.android.flexbox.validators.FixedDimensionInputValidator
;
import
com.google.android.flexbox.validators.FlexBasisPercentInputValidator
;
import
com.google.android.flexbox.validators.InputValidator
;
import
com.google.android.flexbox.validators.IntegerInputValidator
;
import
com.google.android.flexbox.validators.NonNegativeDecimalInputValidator
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.os.Build
;
...
...
@@ -50,6 +42,14 @@ import android.widget.Spinner;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
com.google.android.apps.flexbox.R
;
import
com.google.android.flexbox.validators.DimensionInputValidator
;
import
com.google.android.flexbox.validators.FixedDimensionInputValidator
;
import
com.google.android.flexbox.validators.FlexBasisPercentInputValidator
;
import
com.google.android.flexbox.validators.InputValidator
;
import
com.google.android.flexbox.validators.IntegerInputValidator
;
import
com.google.android.flexbox.validators.NonNegativeDecimalInputValidator
;
/**
* DialogFragment that changes the properties for a flex item.
*/
...
...
@@ -318,7 +318,7 @@ public class FlexItemEditFragment extends DialogFragment {
// https://developer.android.com/training/keyboard-input/navigation.html
// But it requires API level 11 as a minimum sdk version. To support the lower level
// devices,
// doing it programatically.
// doing it program
m
atically.
for
(
int
i
=
0
;
i
<
textViews
.
length
;
i
++)
{
final
int
index
=
i
;
textViews
[
index
].
setOnEditorActionListener
(
new
TextView
.
OnEditorActionListener
()
{
...
...
flexbox/src/androidTest/java/com/google/android/flexbox/FlexboxHelperTest.java
浏览文件 @
780427bb
...
...
@@ -16,23 +16,25 @@
package
com.google.android.flexbox
;
import
com.google.android.flexbox.test.FlexboxTestActivity
;
import
static
com
.
google
.
android
.
flexbox
.
test
.
IsEqualAllowingError
.
isEqualAllowingError
;
import
org.junit.Before
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
static
junit
.
framework
.
Assert
.
assertEquals
;
import
static
junit
.
framework
.
Assert
.
assertNotNull
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
android.app.Activity
;
import
android.support.test.rule.ActivityTestRule
;
import
android.support.test.runner.AndroidJUnit4
;
import
android.view.View
;
import
static
com
.
google
.
android
.
flexbox
.
test
.
IsEqualAllowingError
.
isEqualAllowingError
;
import
static
junit
.
framework
.
Assert
.
assertEquals
;
import
static
junit
.
framework
.
Assert
.
assertNotNull
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
com.google.android.flexbox.test.FlexboxTestActivity
;
import
org.junit.Before
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
/**
* Unit tests for {@link FlexboxHelper}.
...
...
flexbox/src/androidTest/java/com/google/android/flexbox/test/FlexboxAndroidTest.java
浏览文件 @
780427bb
...
...
@@ -2275,7 +2275,7 @@ public class FlexboxAndroidTest {
@Override
public
void
apply
(
FlexboxLayout
flexboxLayout
)
{
flexboxLayout
.
setFlexWrap
(
FlexWrap
.
WRAP_REVERSE
);
}
}
});
TextView
textView1
=
(
TextView
)
activity
.
findViewById
(
R
.
id
.
text1
);
TextView
textView2
=
(
TextView
)
activity
.
findViewById
(
R
.
id
.
text2
);
...
...
flexbox/src/androidTest/java/com/google/android/flexbox/test/FlexboxLayoutManagerConfigChangeTest.java
浏览文件 @
780427bb
...
...
@@ -63,7 +63,8 @@ public class FlexboxLayoutManagerConfigChangeTest {
@Test
@FlakyTest
public
void
testFlexLinesDiscardedOnOrientationChange_direction_row
()
throws
Throwable
{
// Verifies the case that the calculated Flex lines are correctly discarded when a orientation
// Verifies the case that the calculated Flex lines are correctly discarded when a
// orientation
// happens with an Activity that handles configuration changes manually
final
ConfigChangeActivity
activity
=
mActivityRule
.
getActivity
();
final
FlexboxLayoutManager
layoutManager
=
new
FlexboxLayoutManager
();
...
...
@@ -122,7 +123,8 @@ public class FlexboxLayoutManagerConfigChangeTest {
@Test
@FlakyTest
public
void
testFlexLinesDiscardedOnOrientationChange_direction_column
()
throws
Throwable
{
// Verifies the case that the calculated Flex lines are correctly discarded when a orientation
// Verifies the case that the calculated Flex lines are correctly discarded when a
// orientation
// happens with an Activity that handles configuration changes manually
final
ConfigChangeActivity
activity
=
mActivityRule
.
getActivity
();
final
FlexboxLayoutManager
layoutManager
=
new
FlexboxLayoutManager
();
...
...
flexbox/src/main/java/com/google/android/flexbox/FlexItem.java
浏览文件 @
780427bb
...
...
@@ -53,7 +53,7 @@ interface FlexItem extends Parcelable {
* Sets the width attribute of the flex item.
*
* @param width the width attribute. Can be one of the
* constants MATCH_PARENT(-1) or WRAP_CONTENT(-2), or an exact size.
*
constants MATCH_PARENT(-1) or WRAP_CONTENT(-2), or an exact size.
*/
void
setWidth
(
int
width
);
...
...
@@ -69,7 +69,7 @@ interface FlexItem extends Parcelable {
* Sets the height attribute of the flex item.
*
* @param height the height attribute. Can be one of the
* constants MATCH_PARENT(-1) or WRAP_CONTENT(-2), or an exact size.
*
constants MATCH_PARENT(-1) or WRAP_CONTENT(-2), or an exact size.
*/
void
setHeight
(
int
height
);
...
...
flexbox/src/main/java/com/google/android/flexbox/FlexLine.java
浏览文件 @
780427bb
...
...
@@ -176,10 +176,10 @@ public class FlexLine {
/**
* Updates the position of the flex line from the contained view.
*
* @param view the view contained in this flex line
* @param leftDecoration the length of the decoration on the left of the view
* @param topDecoration the length of the decoration on the top of the view
* @param rightDecoration the length of the decoration on the right of the view
* @param view
the view contained in this flex line
* @param leftDecoration
the length of the decoration on the left of the view
* @param topDecoration
the length of the decoration on the top of the view
* @param rightDecoration
the length of the decoration on the right of the view
* @param bottomDecoration the length of the decoration on the bottom of the view
*/
void
updatePositionFromView
(
View
view
,
int
leftDecoration
,
int
topDecoration
,
...
...
flexbox/src/main/java/com/google/android/flexbox/FlexboxHelper.java
浏览文件 @
780427bb
...
...
@@ -17,6 +17,7 @@
package
com.google.android.flexbox
;
import
static
android
.
support
.
v7
.
widget
.
RecyclerView
.
NO_POSITION
;
import
static
com
.
google
.
android
.
flexbox
.
FlexItem
.
FLEX_BASIS_PERCENT_DEFAULT
;
import
android.support.annotation.NonNull
;
...
...
@@ -819,7 +820,7 @@ class FlexboxHelper {
}
private
void
addFlexLine
(
List
<
FlexLine
>
flexLines
,
FlexLine
flexLine
,
int
viewIndex
,
int
usedCrossSizeSoFar
)
{
int
usedCrossSizeSoFar
)
{
flexLine
.
mSumCrossSizeBefore
=
usedCrossSizeSoFar
;
mFlexContainer
.
onNewFlexLineAdded
(
flexLine
);
flexLine
.
mLastIndex
=
viewIndex
;
...
...
@@ -1441,7 +1442,7 @@ class FlexboxHelper {
// Flex lines should be aligned center like ALIGN_CONTENT_CENTER
mFlexContainer
.
setFlexLines
(
constructFlexLinesForAlignContentCenter
(
flexLines
,
size
,
totalCrossSize
));
totalCrossSize
));
break
;
}
// The value of free space along the cross axis which needs to be put on top
...
...
flexbox/src/main/java/com/google/android/flexbox/FlexboxItemDecoration.java
浏览文件 @
780427bb
...
...
@@ -32,9 +32,9 @@ import java.util.List;
*
* Orientation for the decoration can be either of:
* <ul>
*
<li>Horizontal (setOrientation(HORIZONTAL)</li>
*
<li>Vertical (setOrientation(VERTICAL)</li>
*
<li>Both orientation (setOrientation(BOTH)</li>
* <li>Horizontal (setOrientation(HORIZONTAL)</li>
* <li>Vertical (setOrientation(VERTICAL)</li>
* <li>Both orientation (setOrientation(BOTH)</li>
* </ul>.
* The default value is set to both.
*/
...
...
@@ -74,9 +74,9 @@ public class FlexboxItemDecoration extends RecyclerView.ItemDecoration {
* Set the orientation for the decoration.
* Orientation for the decoration can be either of:
* <ul>
*
<li>Horizontal (setOrientation(HORIZONTAL)</li>
*
<li>Vertical (setOrientation(VERTICAL)</li>
*
<li>Both orientation (setOrientation(BOTH)</li>
* <li>Horizontal (setOrientation(HORIZONTAL)</li>
* <li>Vertical (setOrientation(VERTICAL)</li>
* <li>Both orientation (setOrientation(BOTH)</li>
* </ul>.
*/
public
void
setOrientation
(
int
orientation
)
{
...
...
flexbox/src/main/java/com/google/android/flexbox/FlexboxLayout.java
浏览文件 @
780427bb
...
...
@@ -400,7 +400,7 @@ public class FlexboxLayout extends ViewGroup implements FlexContainer {
// Expand the views if alignItems (or mAlignSelf in each child view) is set to stretch
mFlexboxHelper
.
stretchViews
();
setMeasuredDimensionForFlex
(
mFlexDirection
,
widthMeasureSpec
,
heightMeasureSpec
,
flexLinesResult
.
mChildState
);
flexLinesResult
.
mChildState
);
}
/**
...
...
flexbox/src/main/java/com/google/android/flexbox/FlexboxLayoutManager.java
浏览文件 @
780427bb
...
...
@@ -1444,10 +1444,11 @@ public class FlexboxLayoutManager extends RecyclerView.LayoutManager implements
* The view holders are going to be filled toward the end position (bottom if the main axis
* direction is horizontal, right if the main axis direction if vertical).
*
* @param anchorInfo the anchor information where layout should start
* @param fromNextLine if set to {@code true}, layout starts from the next flex line set to
* the anchor information
* @param considerInfinite if set to {@code true}, the judgement if the infinite available space
* @param anchorInfo the anchor information where layout should start
* @param fromNextLine if set to {@code true}, layout starts from the next flex line set to
* the anchor information
* @param considerInfinite if set to {@code true}, the judgement if the infinite available
* space
* needs to be considered.
*/
private
void
updateLayoutStateToFillEnd
(
AnchorInfo
anchorInfo
,
boolean
fromNextLine
,
...
...
@@ -1483,7 +1484,8 @@ public class FlexboxLayoutManager extends RecyclerView.LayoutManager implements
* @param anchorInfo the anchor information where layout should start
* @param fromPreviousLine if set to {@code true}, layout starts from the next flex line set to
* the anchor information
* @param considerInfinite if set to {@code true}, the judgement if the infinite available space
* @param considerInfinite if set to {@code true}, the judgement if the infinite available
* space
* needs to be considered.
*/
private
void
updateLayoutStateToFillStart
(
AnchorInfo
anchorInfo
,
boolean
fromPreviousLine
,
...
...
@@ -1884,13 +1886,13 @@ public class FlexboxLayoutManager extends RecyclerView.LayoutManager implements
}
/**
* @param view the view to be examined if it's visible
* @param view
the view to be examined if it's visible
* @param completelyVisible when passed as {@code true}, this method checks if the view bounds
* don't overlap the bounds of the RecyclerView. When passed as
* {@code false}, this method checks if the view bounds are partially
* visible within the RecyclerView.
* @return if the view passed as an argument is visible (view bounds are within the parent
*
RecyclerView)
* RecyclerView)
*/
private
boolean
isViewVisible
(
View
view
,
boolean
completelyVisible
)
{
int
left
=
getPaddingLeft
();
...
...
@@ -1948,7 +1950,7 @@ public class FlexboxLayoutManager extends RecyclerView.LayoutManager implements
/**
* Returns the adapter position of the first fully visible view. This position does not include
* adapter changes that were dispatched after the last layout pass.
*
* @return The adapter position of the first fully visible item or
* {@link RecyclerView#NO_POSITION} if there aren't any visible items.
* @see #findFirstVisibleItemPosition()
...
...
@@ -1963,7 +1965,7 @@ public class FlexboxLayoutManager extends RecyclerView.LayoutManager implements
/**
* Returns the adapter position of the last visible view. This position does not include
* adapter changes that were dispatched after the last layout pass.
*
* If RecyclerView has item decorators, they will be considered in calculations as well.
* LayoutManager may pre-cache some views that are not necessarily visible. Those views
* are ignored in this method.
...
...
@@ -1982,7 +1984,7 @@ public class FlexboxLayoutManager extends RecyclerView.LayoutManager implements
/**
* Returns the adapter position of the last fully visible view. This position does not include
* adapter changes that were dispatched after the last layout pass.
*
* @return The adapter position of the last fully visible view or
* {@link RecyclerView#NO_POSITION} if there aren't any visible items.
* @see #findLastVisibleItemPosition()
...
...
@@ -1998,8 +2000,8 @@ public class FlexboxLayoutManager extends RecyclerView.LayoutManager implements
* Returns the first child that is visible in the provided index range, i.e. either partially or
* fully visible depending on the arguments provided.
*
* @param fromIndex the start index for searching the visible child
* @param toIndex the last index for searching the visible child
* @param fromIndex
the start index for searching the visible child
* @param toIndex
the last index for searching the visible child
* @param completelyVisible when passed as {@code true}, this method checks if the view bounds
* don't overlap the bounds of the RecyclerView. When passed as
* {@code false}, this method checks if the view bounds are partially
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录