[
  {
    "path": ".gitignore",
    "content": "# Built application files\n*.apk\n*.ap_\n\n# Files for the Dalvik VM\n*.dex\n\n# Java class files\n*.class\n\n# Generated files\nbin/\ngen/\n\n# Gradle files\n.gradle/\nbuild/\n/*/build/\n\n# Local configuration file (sdk path, etc)\nlocal.properties\n\n# Proguard folder generated by Eclipse\nproguard/\n\n# Log Files\n*.log\n\n# Eclipse project files\n.classpath\n.project\n.settings/\n\n# Intellij project files\n*.iml\n*.ipr\n*.iws\n.idea/\n\n# Mac system files\n.DS_Store\n\n*.keystore"
  },
  {
    "path": "README.md",
    "content": ":running:BGAFlowLayout-Android:running:\r\n============\r\n\r\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/cn.bingoogolapple/bga-flowlayout/badge.svg)](https://maven-badges.herokuapp.com/maven-central/cn.bingoogolapple/bga-flowlayout)\r\n\r\nAndroid流式布局，可配置是否将每一行的空白区域平均分配给子控件。\r\n\r\n最开始是参考[鸿洋_的这篇文章](http://blog.csdn.net/lmj623565791/article/details/38352503)的思路实现的，后来根据产品经理出的需求，增加了将每一行的空白区域平均分配给子控件。\r\n\r\ndemo中分别演示了在xml使用方式和在java代码中动态添加\r\n\r\n### 效果图\r\n\r\n![Image of 平均分配剩余空间](http://7xk9dj.com1.z0.glb.clouddn.com/flowlayout/screenshots/bga-flowlayout-demo1.gif)\r\n![Image of 不平均分配剩余空间](http://7xk9dj.com1.z0.glb.clouddn.com/flowlayout/screenshots/bga-flowlayout-demo2.gif)\r\n\r\n### Gradle依赖\r\n\r\n```groovy\r\ndependencies {\r\n    compile 'cn.bingoogolapple:bga-flowlayout:latestVersion@aar'\r\n}\r\n```\r\n\r\n### 自定义属性说明\r\n\r\n```xml\r\n<declare-styleable name=\"BGAFlowLayout\">\r\n    <!-- 标签之间的水平间距 -->\r\n    <attr name=\"fl_horizontalChildGap\" format=\"dimension\" />\r\n    <!-- 标签之间的垂直间距 -->\r\n    <attr name=\"fl_verticalChildGap\" format=\"dimension\" />\r\n    <!-- 是否平均分配每一行的剩余水平方向的空白区域给该行的标签 -->\r\n    <attr name=\"fl_isDistributionWhiteSpacing\" format=\"boolean\" />\r\n</declare-styleable>\r\n```\r\n\r\n## 作者联系方式\r\n\r\n| 个人主页 | 邮箱 |\r\n| ------------- | ------------ |\r\n| <a  href=\"https://www.bingoogolapple.cn\" target=\"_blank\">bingoogolapple.cn</a>  | <a href=\"mailto:bingoogolapple@gmail.com\" target=\"_blank\">bingoogolapple@gmail.com</a> |\r\n\r\n| 个人微信号 | 微信群 | 公众号 |\r\n| ------------ | ------------ | ------------ |\r\n| <img width=\"180\" alt=\"个人微信号\" src=\"https://github.com/bingoogolapple/bga-god-assistant-config/raw/main/images/BGAQrCode.png\"> | <img width=\"180\" alt=\"微信群\" src=\"https://github.com/bingoogolapple/bga-god-assistant-config/raw/main/images/WeChatGroup1QrCode.jpg\"> | <img width=\"180\" alt=\"公众号\" src=\"https://github.com/bingoogolapple/bga-god-assistant-config/raw/main/images/GongZhongHao.png\"> |\r\n\r\n| 个人 QQ 号 | QQ 群 |\r\n| ------------ | ------------ |\r\n| <img width=\"180\" alt=\"个人 QQ 号\" src=\"https://github.com/bingoogolapple/bga-god-assistant-config/raw/main/images/BGAQQQrCode.jpg\"> | <img width=\"180\" alt=\"QQ 群\" src=\"https://github.com/bingoogolapple/bga-god-assistant-config/raw/main/images/QQGroup1QrCode.jpg\"> |\r\n\r\n## 打赏支持作者\r\n\r\n如果您觉得 BGA 系列开源库或工具软件帮您节省了大量的开发时间，可以扫描下方的二维码打赏支持。您的支持将鼓励我继续创作，打赏后还可以加我微信免费开通一年 [上帝小助手浏览器扩展/插件开发平台](https://github.com/bingoogolapple/bga-god-assistant-config) 的会员服务\r\n\r\n| 微信 | QQ | 支付宝 |\r\n| ------------- | ------------- | ------------- |\r\n| <img width=\"180\" alt=\"微信\" src=\"https://github.com/bingoogolapple/bga-god-assistant-config/raw/main/images/donate-wechat.jpg\"> | <img width=\"180\" alt=\"QQ\" src=\"https://github.com/bingoogolapple/bga-god-assistant-config/raw/main/images/donate-qq.jpg\"> | <img width=\"180\" alt=\"支付宝\" src=\"https://github.com/bingoogolapple/bga-god-assistant-config/raw/main/images/donate-alipay.jpg\"> |\r\n\r\n## 作者项目推荐\r\n\r\n* 欢迎您使用我开发的第一个独立开发软件产品 [上帝小助手浏览器扩展/插件开发平台](https://github.com/bingoogolapple/bga-god-assistant-config)\r\n"
  },
  {
    "path": "build.gradle",
    "content": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\n\nbuildscript {\n    repositories {\n        jcenter()\n    }\n    dependencies {\n        classpath 'com.android.tools.build:gradle:2.0.0-alpha2'\n\n        // NOTE: Do not place your application dependencies here; they belong\n        // in the individual module build.gradle files\n    }\n}\n\nallprojects {\n    repositories {\n        jcenter()\n    }\n}\n"
  },
  {
    "path": "demo/build.gradle",
    "content": "apply plugin: 'com.android.application'\n\nandroid {\n    compileSdkVersion ANDROID_BUILD_SDK_VERSION as int\n    buildToolsVersion ANDROID_BUILD_TOOLS_VERSION\n\n    defaultConfig {\n        minSdkVersion ANDROID_BUILD_MIN_SDK_VERSION as int\n        targetSdkVersion ANDROID_BUILD_TARGET_SDK_VERSION as int\n        versionCode VERSION_CODE as int\n        versionName VERSION_NAME\n    }\n}\n\ndependencies {\n    compile 'com.android.support:appcompat-v7:23.1.1'\n    compile 'cn.bingoogolapple:bga-flowlayout:1.0.0@aar'\n//    compile project(':library')\n}\n"
  },
  {
    "path": "demo/src/main/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"cn.bingoogolapple.flowlayout.demo\">\n\n    <application\n        android:allowBackup=\"true\"\n        android:icon=\"@mipmap/ic_launcher\"\n        android:label=\"@string/app_name\"\n        android:theme=\"@style/AppTheme\">\n        <activity\n            android:name=\".MainActivity\"\n            android:configChanges=\"orientation|keyboard|keyboardHidden\"\n            android:label=\"@string/app_name\"\n            android:screenOrientation=\"portrait\"\n            android:windowSoftInputMode=\"adjustResize|stateAlwaysHidden\">\n            <intent-filter>\n                <action android:name=\"android.intent.action.MAIN\" />\n\n                <category android:name=\"android.intent.category.LAUNCHER\" />\n            </intent-filter>\n        </activity>\n    </application>\n\n</manifest>\n"
  },
  {
    "path": "demo/src/main/java/cn/bingoogolapple/flowlayout/demo/MainActivity.java",
    "content": "package cn.bingoogolapple.flowlayout.demo;\n\nimport android.graphics.Color;\nimport android.os.Bundle;\nimport android.support.v7.app.AppCompatActivity;\nimport android.text.TextUtils;\nimport android.view.Gravity;\nimport android.view.KeyEvent;\nimport android.view.ViewGroup;\nimport android.view.inputmethod.EditorInfo;\nimport android.widget.EditText;\nimport android.widget.TextView;\n\nimport cn.bingoogolapple.flowlayout.BGAFlowLayout;\n\npublic class MainActivity extends AppCompatActivity {\n    private String[] mVals = new String[]{\"bingo\", \"googol\", \"apple\", \"bingoogolapple\", \"helloworld\"};\n    private BGAFlowLayout mFlowLayout;\n    private EditText mTagEt;\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n        mTagEt = (EditText) findViewById(R.id.et_main_tag);\n        mFlowLayout = (BGAFlowLayout) findViewById(R.id.flowlayout);\n        initData();\n\n\n        mTagEt.setOnEditorActionListener(new TextView.OnEditorActionListener() {\n            @Override\n            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {\n                if (actionId == EditorInfo.IME_ACTION_GO) {\n                    String tag = mTagEt.getText().toString().trim();\n                    if (!TextUtils.isEmpty(tag)) {\n                        mFlowLayout.addView(getLabel(tag), mFlowLayout.getChildCount() - 1, new ViewGroup.MarginLayoutParams(ViewGroup.MarginLayoutParams.WRAP_CONTENT, ViewGroup.MarginLayoutParams.WRAP_CONTENT));\n                    }\n                    mTagEt.setText(\"\");\n                }\n                return true;\n            }\n        });\n    }\n\n    public void initData() {\n        for (int i = 0; i < mVals.length; i++) {\n            mFlowLayout.addView(getLabel(mVals[i]), mFlowLayout.getChildCount() - 1, new ViewGroup.MarginLayoutParams(ViewGroup.MarginLayoutParams.WRAP_CONTENT, ViewGroup.MarginLayoutParams.WRAP_CONTENT));\n        }\n    }\n\n    private TextView getLabel(String text) {\n        TextView label = new TextView(this);\n        label.setTextColor(Color.WHITE);\n        label.setBackgroundResource(R.drawable.selector_tag);\n        label.setGravity(Gravity.CENTER);\n        label.setSingleLine(true);\n        label.setEllipsize(TextUtils.TruncateAt.END);\n        int padding = BGAFlowLayout.dp2px(this, 5);\n        label.setPadding(padding, padding, padding, padding);\n        label.setText(text);\n        return label;\n    }\n\n}\n"
  },
  {
    "path": "demo/src/main/res/drawable/selector_tag.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<selector xmlns:android=\"http://schemas.android.com/apk/res/android\">\n    <item android:state_enabled=\"true\" android:state_pressed=\"true\">\n        <shape android:shape=\"rectangle\">\n            <solid android:color=\"@color/colorPrimaryDark\" />\n            <corners android:radius=\"4dp\" />\n        </shape>\n    </item>\n    <item>\n        <shape android:shape=\"rectangle\">\n            <solid android:color=\"@color/colorPrimary\" />\n            <corners android:radius=\"4dp\" />\n        </shape>\n    </item>\n\n</selector>\n"
  },
  {
    "path": "demo/src/main/res/drawable/shape_stroke_line.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<shape xmlns:android=\"http://schemas.android.com/apk/res/android\">\n    <corners android:radius=\"4dp\" />\n\n    <solid android:color=\"@android:color/white\" />\n\n    <stroke\n        android:width=\"1px\"\n        android:color=\"#dedede\" />\n</shape>"
  },
  {
    "path": "demo/src/main/res/layout/activity_main.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<ScrollView xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n    style=\"@style/MatchMatch\">\n\n    <LinearLayout style=\"@style/MatchMatch.Vertical\">\n\n        <cn.bingoogolapple.flowlayout.BGAFlowLayout\n            style=\"@style/MatchWrap\"\n            android:background=\"#50a3fc\"\n            android:padding=\"10dp\"\n            app:fl_horizontalChildGap=\"15dp\"\n            app:fl_isDistributionWhiteSpacing=\"true\"\n            app:fl_verticalChildGap=\"10dp\">\n\n            <TextView\n                style=\"@style/TvMainTag\"\n                android:text=\"bingo\" />\n\n            <TextView\n                style=\"@style/TvMainTag\"\n                android:text=\"googol\" />\n\n            <TextView\n                style=\"@style/TvMainTag\"\n                android:text=\"apple\" />\n\n            <TextView\n                style=\"@style/TvMainTag\"\n                android:text=\"bingoogolapple\" />\n\n            <TextView\n                style=\"@style/TvMainTag\"\n                android:layout_height=\"40dp\"\n                android:text=\"HelloWorld\" />\n\n            <TextView\n                style=\"@style/TvMainTag\"\n                android:text=\"Android\" />\n\n            <TextView\n                style=\"@style/TvMainTag\"\n                android:text=\"iOS\" />\n\n            <TextView\n                style=\"@style/TvMainTag\"\n                android:text=\"PHP\" />\n\n            <TextView\n                style=\"@style/TvMainTag\"\n                android:text=\"PhoneGap\" />\n\n            <TextView\n                style=\"@style/TvMainTag\"\n                android:text=\"Cordova\" />\n\n            <TextView\n                style=\"@style/TvMainTag\"\n                android:text=\"AppCan\" />\n\n            <TextView\n                style=\"@style/TvMainTag\"\n                android:text=\"React Native\" />\n\n            <TextView\n                style=\"@style/TvMainTag\"\n                android:text=\"Ionic\" />\n\n        </cn.bingoogolapple.flowlayout.BGAFlowLayout>\n\n        <cn.bingoogolapple.flowlayout.BGAFlowLayout\n            android:id=\"@+id/flowlayout\"\n            style=\"@style/MatchWrap\"\n            android:background=\"#00cc7c\"\n            android:padding=\"5dp\"\n            app:fl_isDistributionWhiteSpacing=\"true\">\n\n            <EditText\n                android:id=\"@+id/et_main_tag\"\n                style=\"@style/WrapWrap\"\n                android:background=\"@drawable/shape_stroke_line\"\n                android:imeActionLabel=\"添加\"\n                android:imeOptions=\"actionGo\"\n                android:minWidth=\"120dp\"\n                android:padding=\"5dp\"\n                android:singleLine=\"true\"\n                android:textColor=\"@color/colorPrimary\" />\n        </cn.bingoogolapple.flowlayout.BGAFlowLayout>\n\n    </LinearLayout>\n\n</ScrollView>"
  },
  {
    "path": "demo/src/main/res/values/colors.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n    <color name=\"colorPrimaryDark\">#f57257</color>\n    <color name=\"colorPrimary\">#f46444</color>\n    <color name=\"navigationBarColor\">#f46444</color>\n\n    <color name=\"item_pressed\">#cccc</color>\n</resources>"
  },
  {
    "path": "demo/src/main/res/values/strings.xml",
    "content": "<resources>\n    <string name=\"app_name\">BGAFlowLayoutDemo</string>\n</resources>"
  },
  {
    "path": "demo/src/main/res/values/styles.xml",
    "content": "<resources>\n\n    <style name=\"AppBaseTheme\" parent=\"Theme.AppCompat.Light.DarkActionBar\">\n        <!-- 状态栏颜色 -->\n        <item name=\"colorPrimaryDark\">@color/colorPrimaryDark</item>\n        <!-- toolbar（actionbar）背景颜色 -->\n        <item name=\"colorPrimary\">@color/colorPrimary</item>\n        <item name=\"colorAccent\">@color/colorPrimary</item>\n    </style>\n\n    <style name=\"AppTheme\" parent=\"AppBaseTheme\"></style>\n\n    <style name=\"TvMainTag\" parent=\"WrapWrap\">\n        <item name=\"android:background\">@drawable/selector_tag</item>\n        <item name=\"android:padding\">5dp</item>\n        <item name=\"android:textColor\">@android:color/white</item>\n        <item name=\"android:gravity\">center</item>\n        <item name=\"android:singleLine\">true</item>\n        <item name=\"android:ellipsize\">end</item>\n    </style>\n\n\n</resources>"
  },
  {
    "path": "demo/src/main/res/values/styles_base.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources xmlns:android=\"http://schemas.android.com/apk/res/android\">\n\n    <style name=\"WrapMatch\">\n        <item name=\"android:layout_width\">wrap_content</item>\n        <item name=\"android:layout_height\">match_parent</item>\n    </style>\n\n    <style name=\"MatchWrap\">\n        <item name=\"android:layout_width\">match_parent</item>\n        <item name=\"android:layout_height\">wrap_content</item>\n    </style>\n\n    <style name=\"WrapWrap\">\n        <item name=\"android:layout_width\">wrap_content</item>\n        <item name=\"android:layout_height\">wrap_content</item>\n    </style>\n\n    <style name=\"MatchMatch\">\n        <item name=\"android:layout_width\">match_parent</item>\n        <item name=\"android:layout_height\">match_parent</item>\n    </style>\n\n    <style name=\"MatchAuto\">\n        <item name=\"android:layout_width\">match_parent</item>\n        <item name=\"android:layout_weight\">1</item>\n        <item name=\"android:layout_height\">0dp</item>\n    </style>\n\n    <style name=\"AutoMatch\">\n        <item name=\"android:layout_width\">0dp</item>\n        <item name=\"android:layout_weight\">1</item>\n        <item name=\"android:layout_height\">match_parent</item>\n    </style>\n\n    <style name=\"WrapAuto\">\n        <item name=\"android:layout_width\">wrap_content</item>\n        <item name=\"android:layout_weight\">1</item>\n        <item name=\"android:layout_height\">0dp</item>\n    </style>\n\n    <style name=\"AutoWrap\">\n        <item name=\"android:layout_width\">0dp</item>\n        <item name=\"android:layout_weight\">1</item>\n        <item name=\"android:layout_height\">wrap_content</item>\n    </style>\n\n    <style name=\"WrapMatch.Vertical\">\n        <item name=\"android:orientation\">vertical</item>\n    </style>\n\n    <style name=\"WrapMatch.Horizontal\">\n        <item name=\"android:orientation\">horizontal</item>\n    </style>\n\n    <style name=\"MatchWrap.Vertical\">\n        <item name=\"android:orientation\">vertical</item>\n    </style>\n\n    <style name=\"MatchWrap.Horizontal\">\n        <item name=\"android:orientation\">horizontal</item>\n    </style>\n\n    <style name=\"WrapWrap.Vertical\">\n        <item name=\"android:orientation\">vertical</item>\n    </style>\n\n    <style name=\"WrapWrap.Horizontal\">\n        <item name=\"android:orientation\">horizontal</item>\n    </style>\n\n    <style name=\"MatchMatch.Vertical\">\n        <item name=\"android:orientation\">vertical</item>\n    </style>\n\n    <style name=\"MatchMatch.Horizontal\">\n        <item name=\"android:orientation\">horizontal</item>\n    </style>\n\n    <style name=\"MatchAuto.Vertical\">\n        <item name=\"android:orientation\">vertical</item>\n    </style>\n\n    <style name=\"MatchAuto.Horizontal\">\n        <item name=\"android:orientation\">horizontal</item>\n    </style>\n\n    <style name=\"AutoMatch.Vertical\">\n        <item name=\"android:orientation\">vertical</item>\n    </style>\n\n    <style name=\"AutoMatch.Horizontal\">\n        <item name=\"android:orientation\">horizontal</item>\n    </style>\n\n    <style name=\"WrapAuto.Vertical\">\n        <item name=\"android:orientation\">vertical</item>\n    </style>\n\n    <style name=\"WrapAuto.Horizontal\">\n        <item name=\"android:orientation\">horizontal</item>\n    </style>\n\n    <style name=\"AutoWrap.Vertical\">\n        <item name=\"android:orientation\">vertical</item>\n    </style>\n\n    <style name=\"AutoWrap.Horizontal\">\n        <item name=\"android:orientation\">horizontal</item>\n    </style>\n\n    <style name=\"MatchOne\">\n        <item name=\"android:layout_width\">match_parent</item>\n        <item name=\"android:layout_height\">1px</item>\n    </style>\n\n    <style name=\"OneMatch\">\n        <item name=\"android:layout_width\">1px</item>\n        <item name=\"android:layout_height\">match_parent</item>\n    </style>\n</resources>"
  },
  {
    "path": "demo/src/main/res/values-v21/styles.xml",
    "content": "<resources>\n\n    <style name=\"AppTheme\" parent=\"AppBaseTheme\">\n        <!-- 底部导航栏的颜色 -->\n        <item name=\"android:navigationBarColor\">@color/navigationBarColor</item>\n        <!-- 系统将在window里面绘制status bar -->\n        <item name=\"android:windowDrawsSystemBarBackgrounds\">true</item>\n    </style>\n\n</resources>"
  },
  {
    "path": "gradle/wrapper/gradle-wrapper.properties",
    "content": "#Fri Dec 04 13:08:31 CST 2015\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_HOME\nzipStorePath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-2.8-all.zip\n"
  },
  {
    "path": "gradle.properties",
    "content": "ANDROID_BUILD_MIN_SDK_VERSION=10\nANDROID_BUILD_TARGET_SDK_VERSION=23\nANDROID_BUILD_SDK_VERSION=23\nANDROID_BUILD_TOOLS_VERSION=23.0.2\n\nVERSION_NAME=1.0.0\nVERSION_CODE=100"
  },
  {
    "path": "gradlew",
    "content": "#!/usr/bin/env bash\n\n##############################################################################\n##\n##  Gradle start up script for UN*X\n##\n##############################################################################\n\n# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nDEFAULT_JVM_OPTS=\"\"\n\nAPP_NAME=\"Gradle\"\nAPP_BASE_NAME=`basename \"$0\"`\n\n# Use the maximum available, or set MAX_FD != -1 to use that value.\nMAX_FD=\"maximum\"\n\nwarn ( ) {\n    echo \"$*\"\n}\n\ndie ( ) {\n    echo\n    echo \"$*\"\n    echo\n    exit 1\n}\n\n# OS specific support (must be 'true' or 'false').\ncygwin=false\nmsys=false\ndarwin=false\ncase \"`uname`\" in\n  CYGWIN* )\n    cygwin=true\n    ;;\n  Darwin* )\n    darwin=true\n    ;;\n  MINGW* )\n    msys=true\n    ;;\nesac\n\n# For Cygwin, ensure paths are in UNIX format before anything is touched.\nif $cygwin ; then\n    [ -n \"$JAVA_HOME\" ] && JAVA_HOME=`cygpath --unix \"$JAVA_HOME\"`\nfi\n\n# Attempt to set APP_HOME\n# Resolve links: $0 may be a link\nPRG=\"$0\"\n# Need this for relative symlinks.\nwhile [ -h \"$PRG\" ] ; do\n    ls=`ls -ld \"$PRG\"`\n    link=`expr \"$ls\" : '.*-> \\(.*\\)$'`\n    if expr \"$link\" : '/.*' > /dev/null; then\n        PRG=\"$link\"\n    else\n        PRG=`dirname \"$PRG\"`\"/$link\"\n    fi\ndone\nSAVED=\"`pwd`\"\ncd \"`dirname \\\"$PRG\\\"`/\" >&-\nAPP_HOME=\"`pwd -P`\"\ncd \"$SAVED\" >&-\n\nCLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar\n\n# Determine the Java command to use to start the JVM.\nif [ -n \"$JAVA_HOME\" ] ; then\n    if [ -x \"$JAVA_HOME/jre/sh/java\" ] ; then\n        # IBM's JDK on AIX uses strange locations for the executables\n        JAVACMD=\"$JAVA_HOME/jre/sh/java\"\n    else\n        JAVACMD=\"$JAVA_HOME/bin/java\"\n    fi\n    if [ ! -x \"$JAVACMD\" ] ; then\n        die \"ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\n    fi\nelse\n    JAVACMD=\"java\"\n    which java >/dev/null 2>&1 || die \"ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\nfi\n\n# Increase the maximum file descriptors if we can.\nif [ \"$cygwin\" = \"false\" -a \"$darwin\" = \"false\" ] ; then\n    MAX_FD_LIMIT=`ulimit -H -n`\n    if [ $? -eq 0 ] ; then\n        if [ \"$MAX_FD\" = \"maximum\" -o \"$MAX_FD\" = \"max\" ] ; then\n            MAX_FD=\"$MAX_FD_LIMIT\"\n        fi\n        ulimit -n $MAX_FD\n        if [ $? -ne 0 ] ; then\n            warn \"Could not set maximum file descriptor limit: $MAX_FD\"\n        fi\n    else\n        warn \"Could not query maximum file descriptor limit: $MAX_FD_LIMIT\"\n    fi\nfi\n\n# For Darwin, add options to specify how the application appears in the dock\nif $darwin; then\n    GRADLE_OPTS=\"$GRADLE_OPTS \\\"-Xdock:name=$APP_NAME\\\" \\\"-Xdock:icon=$APP_HOME/media/gradle.icns\\\"\"\nfi\n\n# For Cygwin, switch paths to Windows format before running java\nif $cygwin ; then\n    APP_HOME=`cygpath --path --mixed \"$APP_HOME\"`\n    CLASSPATH=`cygpath --path --mixed \"$CLASSPATH\"`\n\n    # We build the pattern for arguments to be converted via cygpath\n    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`\n    SEP=\"\"\n    for dir in $ROOTDIRSRAW ; do\n        ROOTDIRS=\"$ROOTDIRS$SEP$dir\"\n        SEP=\"|\"\n    done\n    OURCYGPATTERN=\"(^($ROOTDIRS))\"\n    # Add a user-defined pattern to the cygpath arguments\n    if [ \"$GRADLE_CYGPATTERN\" != \"\" ] ; then\n        OURCYGPATTERN=\"$OURCYGPATTERN|($GRADLE_CYGPATTERN)\"\n    fi\n    # Now convert the arguments - kludge to limit ourselves to /bin/sh\n    i=0\n    for arg in \"$@\" ; do\n        CHECK=`echo \"$arg\"|egrep -c \"$OURCYGPATTERN\" -`\n        CHECK2=`echo \"$arg\"|egrep -c \"^-\"`                                 ### Determine if an option\n\n        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition\n            eval `echo args$i`=`cygpath --path --ignore --mixed \"$arg\"`\n        else\n            eval `echo args$i`=\"\\\"$arg\\\"\"\n        fi\n        i=$((i+1))\n    done\n    case $i in\n        (0) set -- ;;\n        (1) set -- \"$args0\" ;;\n        (2) set -- \"$args0\" \"$args1\" ;;\n        (3) set -- \"$args0\" \"$args1\" \"$args2\" ;;\n        (4) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" ;;\n        (5) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" ;;\n        (6) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" ;;\n        (7) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" ;;\n        (8) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" ;;\n        (9) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" \"$args8\" ;;\n    esac\nfi\n\n# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules\nfunction splitJvmOpts() {\n    JVM_OPTS=(\"$@\")\n}\neval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS\nJVM_OPTS[${#JVM_OPTS[*]}]=\"-Dorg.gradle.appname=$APP_BASE_NAME\"\n\nexec \"$JAVACMD\" \"${JVM_OPTS[@]}\" -classpath \"$CLASSPATH\" org.gradle.wrapper.GradleWrapperMain \"$@\"\n"
  },
  {
    "path": "gradlew.bat",
    "content": "@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@rem  Gradle startup script for Windows\n@rem\n@rem ##########################################################################\n\n@rem Set local scope for the variables with windows NT shell\nif \"%OS%\"==\"Windows_NT\" setlocal\n\n@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nset DEFAULT_JVM_OPTS=\n\nset DIRNAME=%~dp0\nif \"%DIRNAME%\" == \"\" set DIRNAME=.\nset APP_BASE_NAME=%~n0\nset APP_HOME=%DIRNAME%\n\n@rem Find java.exe\nif defined JAVA_HOME goto findJavaFromJavaHome\n\nset JAVA_EXE=java.exe\n%JAVA_EXE% -version >NUL 2>&1\nif \"%ERRORLEVEL%\" == \"0\" goto init\n\necho.\necho ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\necho.\necho Please set the JAVA_HOME variable in your environment to match the\necho location of your Java installation.\n\ngoto fail\n\n:findJavaFromJavaHome\nset JAVA_HOME=%JAVA_HOME:\"=%\nset JAVA_EXE=%JAVA_HOME%/bin/java.exe\n\nif exist \"%JAVA_EXE%\" goto init\n\necho.\necho ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%\necho.\necho Please set the JAVA_HOME variable in your environment to match the\necho location of your Java installation.\n\ngoto fail\n\n:init\n@rem Get command-line arguments, handling Windowz variants\n\nif not \"%OS%\" == \"Windows_NT\" goto win9xME_args\nif \"%@eval[2+2]\" == \"4\" goto 4NT_args\n\n:win9xME_args\n@rem Slurp the command line arguments.\nset CMD_LINE_ARGS=\nset _SKIP=2\n\n:win9xME_args_slurp\nif \"x%~1\" == \"x\" goto execute\n\nset CMD_LINE_ARGS=%*\ngoto execute\n\n:4NT_args\n@rem Get arguments from the 4NT Shell from JP Software\nset CMD_LINE_ARGS=%$\n\n:execute\n@rem Setup the command line\n\nset CLASSPATH=%APP_HOME%\\gradle\\wrapper\\gradle-wrapper.jar\n\n@rem Execute Gradle\n\"%JAVA_EXE%\" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% \"-Dorg.gradle.appname=%APP_BASE_NAME%\" -classpath \"%CLASSPATH%\" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%\n\n:end\n@rem End local scope for the variables with windows NT shell\nif \"%ERRORLEVEL%\"==\"0\" goto mainEnd\n\n:fail\nrem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of\nrem the _cmd.exe /c_ return code!\nif  not \"\" == \"%GRADLE_EXIT_CONSOLE%\" exit 1\nexit /b 1\n\n:mainEnd\nif \"%OS%\"==\"Windows_NT\" endlocal\n\n:omega\n"
  },
  {
    "path": "library/build.gradle",
    "content": "apply plugin: 'com.android.library'\n\nandroid {\n    compileSdkVersion ANDROID_BUILD_SDK_VERSION as int\n    buildToolsVersion ANDROID_BUILD_TOOLS_VERSION\n\n    defaultConfig {\n        minSdkVersion ANDROID_BUILD_MIN_SDK_VERSION as int\n        targetSdkVersion ANDROID_BUILD_TARGET_SDK_VERSION as int\n    }\n}\n\n// gradle uploadArchives\napply from: 'https://raw.githubusercontent.com/bingoogolapple/PublishAar/master/central-publish.gradle'"
  },
  {
    "path": "library/gradle.properties",
    "content": "PUBLISH_AAR_ARTIFACT_ID=bga-flowlayout\nPUBLISH_AAR_DESCRIPTION=Android FlowLayout Library\nPUBLISH_AAR_GITHUB_REPOSITORIES_NAME=BGAFlowLayout-Android"
  },
  {
    "path": "library/src/main/AndroidManifest.xml",
    "content": "<manifest package=\"cn.bingoogolapple.flowlayout\"/>"
  },
  {
    "path": "library/src/main/java/cn/bingoogolapple/flowlayout/BGAFlowLayout.java",
    "content": "package cn.bingoogolapple.flowlayout;\n\nimport android.content.Context;\nimport android.content.res.TypedArray;\nimport android.util.AttributeSet;\nimport android.util.TypedValue;\nimport android.view.View;\nimport android.view.ViewGroup;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\n/**\n * 作者:王浩 邮件:bingoogolapple@gmail.com\n * 创建时间:15/6/24 11:21\n * 描述:流式布局\n */\npublic class BGAFlowLayout extends ViewGroup {\n    private List<Row> mRows = new ArrayList<>();\n    private int mHorizontalChildGap;\n    private int mVerticalChildGap;\n    private boolean mIsDistributionWhiteSpacing = true;\n\n    public BGAFlowLayout(Context context) {\n        this(context, null);\n    }\n\n    public BGAFlowLayout(Context context, AttributeSet attrs) {\n        this(context, attrs, 0);\n    }\n\n    public BGAFlowLayout(Context context, AttributeSet attrs, int defStyleAttr) {\n        super(context, attrs, defStyleAttr);\n        initDefaultAttrs(context);\n        initCustomAttrs(context, attrs);\n    }\n\n    private void initDefaultAttrs(Context context) {\n        mHorizontalChildGap = dp2px(context, 10);\n        mVerticalChildGap = dp2px(context, 10);\n    }\n\n    private void initCustomAttrs(Context context, AttributeSet attrs) {\n        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.BGAFlowLayout);\n        final int N = typedArray.getIndexCount();\n        for (int i = 0; i < N; i++) {\n            initCustomAttr(typedArray.getIndex(i), typedArray);\n        }\n        typedArray.recycle();\n    }\n\n    private void initCustomAttr(int attr, TypedArray typedArray) {\n        if (attr == R.styleable.BGAFlowLayout_fl_horizontalChildGap) {\n            /**\n             * getDimension和getDimensionPixelOffset的功能差不多,都是获取某个dimen的值,如果是dp或sp的单位,将其乘以density,如果是px,则不乘;两个函数的区别是一个返回float,一个返回int. getDimensionPixelSize则不管写的是dp还是sp还是px,都会乘以denstiy.\n             */\n            mHorizontalChildGap = typedArray.getDimensionPixelOffset(attr, mHorizontalChildGap);\n        } else if (attr == R.styleable.BGAFlowLayout_fl_verticalChildGap) {\n            mVerticalChildGap = typedArray.getDimensionPixelOffset(attr, mVerticalChildGap);\n        } else if (attr == R.styleable.BGAFlowLayout_fl_isDistributionWhiteSpacing) {\n            mIsDistributionWhiteSpacing = typedArray.getBoolean(attr, mIsDistributionWhiteSpacing);\n        }\n    }\n\n    @Override\n    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {\n        int sizeWidth = MeasureSpec.getSize(widthMeasureSpec);\n        int sizeHeight = MeasureSpec.getSize(heightMeasureSpec);\n        /**\n         * 1.EXACTLY:100dp,match_parent\n         * 2.AT_MOST:wrap_content\n         * 3.UNSPCIFIED:子控件想要多大就多大，很少见（ScrollView）\n         */\n        int modeHeight = MeasureSpec.getMode(heightMeasureSpec);\n\n        mRows.clear();\n        Row row = new Row(sizeWidth);\n\n        View child;\n        int childCount = getChildCount();\n        for (int i = 0; i < childCount; i++) {\n            child = getChildAt(i);\n            measureChild(child, widthMeasureSpec, heightMeasureSpec);\n            if (!row.addChild(child)) {\n                mRows.add(row);\n                row = new Row(sizeWidth);\n                row.addChild(child);\n            }\n        }\n\n        // 添加最后一行\n        if (!mRows.contains(row)) {\n            mRows.add(row);\n        }\n\n        int height = 0;\n        int rowCount = mRows.size();\n        for (int i = 0; i < rowCount; i++) {\n            height += mRows.get(i).mHeight;\n            if (i != rowCount - 1) {\n                height += mVerticalChildGap;\n            }\n        }\n        setMeasuredDimension(sizeWidth, modeHeight == MeasureSpec.EXACTLY ? sizeHeight : height + getPaddingTop() + getPaddingBottom());\n    }\n\n    @Override\n    protected void onLayout(boolean changed, int l, int t, int r, int b) {\n        int rowCount = mRows.size();\n        int top = getPaddingTop();\n        Row row;\n        for (int i = 0; i < rowCount; i++) {\n            row = mRows.get(i);\n            if (mIsDistributionWhiteSpacing && i != rowCount - 1) {\n                row.layout(true, top);\n            } else {\n                row.layout(false, top);\n            }\n            top += row.mHeight + mVerticalChildGap;\n        }\n    }\n\n    private class Row {\n        private List<View> mViews = new ArrayList<>();\n        private int mWidth;\n        private int mNewWidth;\n        private int mHeight;\n        private int mMaxWidth;\n\n        public Row(int sizeWidth) {\n            mMaxWidth = sizeWidth - getPaddingLeft() - getPaddingRight();\n        }\n\n        public boolean addChild(View child) {\n            if (isOutOfMaxWidth(child.getMeasuredWidth())) {\n                return false;\n            } else {\n                mViews.add(child);\n                mWidth = mNewWidth;\n\n                int childHeight = child.getMeasuredHeight();\n                mHeight = mHeight < childHeight ? childHeight : mHeight;\n                return true;\n            }\n        }\n\n        private boolean isOutOfMaxWidth(int childWidth) {\n            if (mViews.size() == 0) {\n                mNewWidth = mWidth + childWidth;\n            } else {\n                mNewWidth = mWidth + mHorizontalChildGap + childWidth;\n            }\n            return mNewWidth > mMaxWidth;\n        }\n\n        /**\n         * @param isNeedSplit 是否需要平均分配空白区域给每一个子孩子\n         * @param top\n         */\n        public void layout(boolean isNeedSplit, int top) {\n            if (mViews.size() == 0) {\n                return;\n            }\n\n            int left = getPaddingLeft();\n            int count = mViews.size();\n            int splitWidth = (mMaxWidth - mWidth) / count;\n            View view;\n            for (int i = 0; i < count; i++) {\n                view = mViews.get(i);\n                int childWidth = view.getMeasuredWidth();\n                int childHeight = view.getMeasuredHeight();\n                if (isNeedSplit) {\n                    childWidth = childWidth + splitWidth;\n                    view.getLayoutParams().width = childWidth;\n                    if (splitWidth > 0) {\n                        /**\n                         * 1.EXACTLY:100dp,match_parent\n                         * 2.AT_MOST:wrap_content\n                         * 3.UNSPCIFIED:子控件想要多大就多大，很少见（ScrollView）\n                         */\n                        int widthMeasureSpec = MeasureSpec.makeMeasureSpec(childWidth, MeasureSpec.EXACTLY);\n                        int heightMeasureSpec = MeasureSpec.makeMeasureSpec(childHeight, MeasureSpec.EXACTLY);\n                        view.measure(widthMeasureSpec, heightMeasureSpec);\n                    }\n                }\n\n                int topOffset = (int) ((mHeight - childHeight) / 2.0 + 0.5);\n                view.layout(left, top + topOffset, left + childWidth, top + topOffset + childHeight);\n\n                left += childWidth + mHorizontalChildGap;\n            }\n        }\n    }\n\n    public static int dp2px(Context context, float dpValue) {\n        return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dpValue, context.getResources().getDisplayMetrics());\n    }\n}"
  },
  {
    "path": "library/src/main/res/values/attrs.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n    <declare-styleable name=\"BGAFlowLayout\">\n        <!-- 标签之间的水平间距 -->\n        <attr name=\"fl_horizontalChildGap\" format=\"dimension\" />\n        <!-- 标签之间的垂直间距 -->\n        <attr name=\"fl_verticalChildGap\" format=\"dimension\" />\n        <!-- 是否平均分配每一行的剩余水平方向的空白区域给该行的标签 -->\n        <attr name=\"fl_isDistributionWhiteSpacing\" format=\"boolean\" />\n    </declare-styleable>\n</resources>"
  },
  {
    "path": "settings.gradle",
    "content": "include ':library', ':demo'\n"
  }
]