datas) {
64 | mDataList.clear();
65 | onlyAddAll(datas);
66 | }
67 |
68 | public int position;
69 | public void setSelected(int p) {
70 | position=p;
71 | }
72 |
73 | @Override
74 | public boolean isSelectedPosition(int poi) {
75 | if (poi == position) {
76 | return true;
77 | }
78 | return false;
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/app/src/main/java/com/cornflower1991/flowlayout/widget/FlowTagLayout.java:
--------------------------------------------------------------------------------
1 | package com.cornflower1991.flowlayout.widget;
2 |
3 | import android.content.Context;
4 | import android.database.DataSetObserver;
5 | import android.util.AttributeSet;
6 | import android.util.SparseBooleanArray;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.ListAdapter;
10 |
11 | import java.util.ArrayList;
12 | import java.util.Arrays;
13 | import java.util.List;
14 |
15 | /**
16 | * 流式标签布局
17 | * 原理:重写{@link ViewGroup#onMeasure(int, int)}
18 | * 和{@link ViewGroup#onLayout(boolean, int, int, int, int)}方法
19 | *
20 | * Created by yexiuliang on 2016/7/11.
21 | */
22 |
23 | public class FlowTagLayout extends ViewGroup {
24 | /**
25 | * FlowLayout not support checked
26 | */
27 | public static final int FLOW_TAG_CHECKED_NONE = 0;//只点击不选择
28 | /**
29 | * FlowLayout support single-select
30 | */
31 | public static final int FLOW_TAG_CHECKED_SINGLE = 1;//单选
32 | /**
33 | * FlowLayout support multi-select
34 | */
35 | public static final int FLOW_TAG_CHECKED_MULTI = 2;//多选
36 |
37 | /**
38 | * Should be used by subclasses to listen to changes in the dataset
39 | */
40 | AdapterDataSetObserver mDataSetObserver;
41 |
42 | /**
43 | * The adapter containing the data to be displayed by this view
44 | */
45 | ListAdapter mAdapter;
46 |
47 | /**
48 | * the tag click event callback
49 | */
50 | OnTagClickListener mOnTagClickListener;
51 |
52 | /**
53 | * the tag select event callback
54 | */
55 | OnTagSelectListener mOnTagSelectListener;
56 |
57 | /**
58 | * 标签流式布局选中模式,默认是不支持选中的
59 | */
60 | private int mTagCheckMode = FLOW_TAG_CHECKED_NONE;
61 |
62 | /**
63 | * 存储选中的tag
64 | */
65 | private SparseBooleanArray mCheckedTagArray = new SparseBooleanArray();
66 | /**
67 | * 子View的宽度,如果为0 则为warp_content
68 | */
69 | private int mWidth;
70 |
71 |
72 | public FlowTagLayout(Context context) {
73 | super(context);
74 |
75 | }
76 |
77 | public FlowTagLayout(Context context, AttributeSet attrs) {
78 | super(context, attrs);
79 |
80 | }
81 |
82 | public FlowTagLayout(Context context, AttributeSet attrs, int defStyleAttr) {
83 | super(context, attrs, defStyleAttr);
84 |
85 | }
86 |
87 |
88 | @Override
89 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
90 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
91 |
92 | //获取Padding
93 | // 获得它的父容器为它设置的测量模式和大小
94 | int sizeWidth = View.MeasureSpec.getSize(widthMeasureSpec);
95 | int sizeHeight = View.MeasureSpec.getSize(heightMeasureSpec);
96 | int modeWidth = View.MeasureSpec.getMode(widthMeasureSpec);
97 | int modeHeight = View.MeasureSpec.getMode(heightMeasureSpec);
98 |
99 | //FlowLayout最终的宽度和高度值
100 | int resultWidth = 0;
101 | int resultHeight = 0;
102 |
103 | //测量时每一行的宽度
104 | int lineWidth = 0;
105 | //测量时每一行的高度,加起来就是FlowLayout的高度
106 | int lineHeight = 0;
107 |
108 | //遍历每个子元素
109 | for (int i = 0, childCount = getChildCount(); i < childCount; i++) {
110 | View childView = getChildAt(i);
111 | //测量每一个子view的宽和高
112 | measureChild(childView, widthMeasureSpec, heightMeasureSpec);
113 |
114 | //获取到测量的宽和高
115 | int childWidth = childView.getMeasuredWidth();
116 | int childHeight = childView.getMeasuredHeight();
117 |
118 | //因为子View可能设置margin,这里要加上margin的距离
119 | ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) childView.getLayoutParams();
120 | int realChildWidth = childWidth + mlp.leftMargin + mlp.rightMargin;
121 | int realChildHeight = childHeight + mlp.topMargin + mlp.bottomMargin;
122 |
123 | //如果当前一行的宽度加上要加入的子view的宽度大于父容器给的宽度,就换行
124 | if ((lineWidth + realChildWidth) > sizeWidth) {
125 | //换行
126 | resultWidth = Math.max(lineWidth, realChildWidth);
127 | resultHeight += realChildHeight;
128 | //换行了,lineWidth和lineHeight重新算
129 | lineWidth = realChildWidth;
130 | lineHeight = realChildHeight;
131 | } else {
132 | //不换行,直接相加
133 | lineWidth += realChildWidth;
134 | //每一行的高度取二者最大值
135 | lineHeight = Math.max(lineHeight, realChildHeight);
136 | }
137 |
138 | //遍历到最后一个的时候,肯定走的是不换行
139 | if (i == childCount - 1) {
140 | resultWidth = Math.max(lineWidth, resultWidth);
141 | resultHeight += lineHeight;
142 | }
143 |
144 | setMeasuredDimension(modeWidth == View.MeasureSpec.EXACTLY ? sizeWidth : resultWidth,
145 | modeHeight == View.MeasureSpec.EXACTLY ? sizeHeight : resultHeight);
146 |
147 | }
148 |
149 | }
150 |
151 | @Override
152 | protected void onLayout(boolean changed, int l, int t, int r, int b) {
153 |
154 | int flowWidth = getWidth();
155 |
156 | int childLeft = 0;
157 | int childTop = 0;
158 |
159 | //遍历子控件,记录每个子view的位置
160 | for (int i = 0, childCount = getChildCount(); i < childCount; i++) {
161 | View childView = getChildAt(i);
162 |
163 | //跳过View.GONE的子View
164 | if (childView.getVisibility() == View.GONE) {
165 | continue;
166 | }
167 |
168 | //获取到测量的宽和高
169 | int childWidth = childView.getMeasuredWidth();
170 | int childHeight = childView.getMeasuredHeight();
171 |
172 | //因为子View可能设置margin,这里要加上margin的距离
173 | ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) childView.getLayoutParams();
174 |
175 | if (childLeft + mlp.leftMargin + childWidth + mlp.rightMargin > flowWidth) {
176 | //换行处理
177 | childTop += (mlp.topMargin + childHeight + mlp.bottomMargin);
178 | childLeft = 0;
179 | }
180 | //布局
181 | int left = childLeft + mlp.leftMargin;
182 | int top = childTop + mlp.topMargin;
183 | int right = childLeft + mlp.leftMargin + childWidth;
184 | int bottom = childTop + mlp.topMargin + childHeight;
185 | childView.layout(left, top, right, bottom);
186 |
187 | childLeft += (mlp.leftMargin + childWidth + mlp.rightMargin);
188 | }
189 | }
190 |
191 | @Override
192 | public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs) {
193 | return new ViewGroup.MarginLayoutParams(getContext(), attrs);
194 | }
195 |
196 | public ListAdapter getAdapter() {
197 | return mAdapter;
198 | }
199 |
200 | class AdapterDataSetObserver extends DataSetObserver {
201 | @Override
202 | public void onChanged() {
203 | super.onChanged();
204 | reloadData();
205 | }
206 |
207 | @Override
208 | public void onInvalidated() {
209 | super.onInvalidated();
210 | }
211 | }
212 |
213 |
214 | /**
215 | * 子View个数
216 | *
217 | * @param width
218 | */
219 | public void setChildWidth(int width) {
220 | this.mWidth = width;
221 | }
222 |
223 | /**
224 | * 重新加载刷新数据
225 | */
226 | private void reloadData() {
227 | removeAllViews();
228 |
229 | ViewGroup.MarginLayoutParams mMarginLayoutParams = new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
230 | if (mWidth != 0) {
231 | mMarginLayoutParams.width = mWidth;
232 | }
233 | boolean isSetted = false;
234 | for (int i = 0; i < mAdapter.getCount(); i++) {
235 | final int j = i;
236 | mCheckedTagArray.put(i, false);
237 | final View childView = mAdapter.getView(i, null, this);
238 | addView(childView, mMarginLayoutParams);
239 |
240 | if (mAdapter instanceof OnInitSelectedPosition) {
241 | boolean isSelected = ((OnInitSelectedPosition) mAdapter).isSelectedPosition(i);
242 | //判断一下模式
243 | if (mTagCheckMode == FLOW_TAG_CHECKED_SINGLE) {
244 | //单选只有第一个起作用
245 | if (isSelected && !isSetted) {
246 | mCheckedTagArray.put(i, true);
247 | childView.setSelected(true);
248 | isSetted = true;
249 | }
250 | } else if (mTagCheckMode == FLOW_TAG_CHECKED_MULTI) {
251 | if (isSelected) {
252 | mCheckedTagArray.put(i, true);
253 | childView.setSelected(true);
254 | }
255 | }
256 | }
257 |
258 | childView.setOnClickListener(new View.OnClickListener() {
259 | @Override
260 | public void onClick(View v) {
261 | if (mTagCheckMode == FLOW_TAG_CHECKED_NONE) {
262 | if (mOnTagClickListener != null) {
263 | mOnTagClickListener.onItemClick(FlowTagLayout.this, childView, j);
264 | }
265 | } else if (mTagCheckMode == FLOW_TAG_CHECKED_SINGLE) {
266 | //判断状态
267 | if (mCheckedTagArray.get(j)) {
268 | //单选模式下,必须选择一个
269 | // mCheckedTagArray.put(j, false);
270 | // childView.setSelected(false);
271 | // if (mOnTagSelectListener != null) {
272 | // mOnTagSelectListener.onItemSelect(FlowTagLayout.this, j,new ArrayList());
273 | // }
274 | return;
275 | }
276 | //更新全部状态为fasle
277 |
278 | for (int k = 0; k < mAdapter.getCount(); k++) {
279 | mCheckedTagArray.put(k, false);
280 | getChildAt(k).setSelected(false);
281 | }
282 | //更新点击状态
283 | mCheckedTagArray.put(j, true);
284 | childView.setSelected(true);
285 |
286 | if (mOnTagSelectListener != null) {
287 | mOnTagSelectListener.onItemSelect(FlowTagLayout.this, j, Arrays.asList(j));
288 | }
289 | } else if (mTagCheckMode == FLOW_TAG_CHECKED_MULTI) {
290 | if (mCheckedTagArray.get(j)) {
291 | mCheckedTagArray.put(j, false);
292 | childView.setSelected(false);
293 | } else {
294 | mCheckedTagArray.put(j, true);
295 | childView.setSelected(true);
296 | }
297 | //回调
298 | if (mOnTagSelectListener != null) {
299 | List list = new ArrayList();
300 | for (int k = 0; k < mAdapter.getCount(); k++) {
301 | if (mCheckedTagArray.get(k)) {
302 | list.add(k);
303 | }
304 | }
305 | mOnTagSelectListener.onItemSelect(FlowTagLayout.this, j, list);
306 | }
307 | }
308 | }
309 | });
310 | }
311 | }
312 |
313 | public void setOnTagClickListener(OnTagClickListener onTagClickListener) {
314 | this.mOnTagClickListener = onTagClickListener;
315 | }
316 |
317 | public void setOnTagSelectListener(OnTagSelectListener onTagSelectListener) {
318 | this.mOnTagSelectListener = onTagSelectListener;
319 | }
320 |
321 | /**
322 | * 像ListView、GridView一样使用FlowLayout
323 | *
324 | * @param adapter
325 | */
326 | public void setAdapter(ListAdapter adapter) {
327 | if (mAdapter != null && mDataSetObserver != null) {
328 | mAdapter.unregisterDataSetObserver(mDataSetObserver);
329 | }
330 |
331 | //清除现有的数据
332 | removeAllViews();
333 | mAdapter = adapter;
334 |
335 | if (mAdapter != null) {
336 | mDataSetObserver = new AdapterDataSetObserver();
337 | mAdapter.registerDataSetObserver(mDataSetObserver);
338 | }
339 | }
340 |
341 | /**
342 | * 获取标签模式
343 | *
344 | * @return
345 | */
346 | public int getmTagCheckMode() {
347 | return mTagCheckMode;
348 | }
349 |
350 | /**
351 | * 设置标签选中模式
352 | *
353 | * @param tagMode
354 | */
355 | public void setTagCheckedMode(int tagMode) {
356 | this.mTagCheckMode = tagMode;
357 | }
358 | }
359 |
--------------------------------------------------------------------------------
/app/src/main/java/com/cornflower1991/flowlayout/widget/OnInitSelectedPosition.java:
--------------------------------------------------------------------------------
1 | package com.cornflower1991.flowlayout.widget;
2 |
3 | /**
4 | * 初始化选择
5 | * Created by yexiuliang on 2016/7/11.
6 | */
7 |
8 | public interface OnInitSelectedPosition {
9 | boolean isSelectedPosition(int position);
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/java/com/cornflower1991/flowlayout/widget/OnTagClickListener.java:
--------------------------------------------------------------------------------
1 | package com.cornflower1991.flowlayout.widget;
2 |
3 | import android.view.View;
4 |
5 | /**
6 | * 点击
7 | * Created by yexiuliang on 2016/7/11.
8 | */
9 | public interface OnTagClickListener {
10 | void onItemClick(FlowTagLayout parent, View view, int position);
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/java/com/cornflower1991/flowlayout/widget/OnTagSelectListener.java:
--------------------------------------------------------------------------------
1 | package com.cornflower1991.flowlayout.widget;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | *单选 多选
7 | * Created by yexiuliang on 2016/7/11.
8 | */
9 | public interface OnTagSelectListener {
10 | void onItemSelect(FlowTagLayout parent, int positoin, List selectedList);
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/blue_rect_round_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 | -
10 |
11 |
12 |
13 |
14 |
15 | -
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
18 |
19 |
27 |
28 |
29 |
32 |
33 |
40 |
41 |
46 |
47 |
52 |
53 |
59 |
60 |
64 |
65 |
66 |
71 |
72 |
73 |
78 |
79 |
83 |
84 |
85 |
90 |
91 |
96 |
97 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/tag_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qiushi123/FlowLayout-master/902ffdcd762c3bf13434b2a7d29dd51ea7d90955/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qiushi123/FlowLayout-master/902ffdcd762c3bf13434b2a7d29dd51ea7d90955/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qiushi123/FlowLayout-master/902ffdcd762c3bf13434b2a7d29dd51ea7d90955/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qiushi123/FlowLayout-master/902ffdcd762c3bf13434b2a7d29dd51ea7d90955/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qiushi123/FlowLayout-master/902ffdcd762c3bf13434b2a7d29dd51ea7d90955/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #ffffff
7 |
8 | #00000000
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | FlowLayout
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
22 |
23 |
24 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/test/java/com/cornflower1991/flowlayout/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.cornflower1991.flowlayout;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.2.0-alpha5'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qiushi123/FlowLayout-master/902ffdcd762c3bf13434b2a7d29dd51ea7d90955/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/images/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qiushi123/FlowLayout-master/902ffdcd762c3bf13434b2a7d29dd51ea7d90955/images/1.png
--------------------------------------------------------------------------------
/images/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qiushi123/FlowLayout-master/902ffdcd762c3bf13434b2a7d29dd51ea7d90955/images/2.png
--------------------------------------------------------------------------------
/images/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qiushi123/FlowLayout-master/902ffdcd762c3bf13434b2a7d29dd51ea7d90955/images/3.png
--------------------------------------------------------------------------------
/images/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qiushi123/FlowLayout-master/902ffdcd762c3bf13434b2a7d29dd51ea7d90955/images/4.png
--------------------------------------------------------------------------------
/images/5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qiushi123/FlowLayout-master/902ffdcd762c3bf13434b2a7d29dd51ea7d90955/images/5.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------