[
  {
    "path": ".gitignore",
    "content": "*.iml\n.gradle\n/local.properties\n/.idea/workspace.xml\n/.idea/libraries\n.DS_Store\n/build\n/captures\n.externalNativeBuild\n/app\n"
  },
  {
    "path": ".idea/encodings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"Encoding\" addBOMForNewFiles=\"with NO BOM\" />\n</project>"
  },
  {
    "path": ".idea/gradle.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"GradleSettings\">\n    <option name=\"linkedExternalProjectsSettings\">\n      <GradleProjectSettings>\n        <compositeConfiguration>\n          <compositeBuild compositeDefinitionSource=\"SCRIPT\" />\n        </compositeConfiguration>\n        <option name=\"distributionType\" value=\"DEFAULT_WRAPPED\" />\n        <option name=\"externalProjectPath\" value=\"$PROJECT_DIR$\" />\n        <option name=\"modules\">\n          <set>\n            <option value=\"$PROJECT_DIR$\" />\n            <option value=\"$PROJECT_DIR$/app\" />\n            <option value=\"$PROJECT_DIR$/segmentedcontrolmodule\" />\n          </set>\n        </option>\n        <option name=\"resolveModulePerSourceSet\" value=\"false\" />\n      </GradleProjectSettings>\n    </option>\n  </component>\n</project>"
  },
  {
    "path": ".idea/misc.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"NullableNotNullManager\">\n    <option name=\"myDefaultNullable\" value=\"android.support.annotation.Nullable\" />\n    <option name=\"myDefaultNotNull\" value=\"android.support.annotation.NonNull\" />\n    <option name=\"myNullables\">\n      <value>\n        <list size=\"10\">\n          <item index=\"0\" class=\"java.lang.String\" itemvalue=\"org.jetbrains.annotations.Nullable\" />\n          <item index=\"1\" class=\"java.lang.String\" itemvalue=\"javax.annotation.Nullable\" />\n          <item index=\"2\" class=\"java.lang.String\" itemvalue=\"javax.annotation.CheckForNull\" />\n          <item index=\"3\" class=\"java.lang.String\" itemvalue=\"edu.umd.cs.findbugs.annotations.Nullable\" />\n          <item index=\"4\" class=\"java.lang.String\" itemvalue=\"android.support.annotation.Nullable\" />\n          <item index=\"5\" class=\"java.lang.String\" itemvalue=\"androidx.annotation.Nullable\" />\n          <item index=\"6\" class=\"java.lang.String\" itemvalue=\"androidx.annotation.RecentlyNullable\" />\n          <item index=\"7\" class=\"java.lang.String\" itemvalue=\"org.checkerframework.checker.nullness.qual.Nullable\" />\n          <item index=\"8\" class=\"java.lang.String\" itemvalue=\"org.checkerframework.checker.nullness.compatqual.NullableDecl\" />\n          <item index=\"9\" class=\"java.lang.String\" itemvalue=\"org.checkerframework.checker.nullness.compatqual.NullableType\" />\n        </list>\n      </value>\n    </option>\n    <option name=\"myNotNulls\">\n      <value>\n        <list size=\"9\">\n          <item index=\"0\" class=\"java.lang.String\" itemvalue=\"org.jetbrains.annotations.NotNull\" />\n          <item index=\"1\" class=\"java.lang.String\" itemvalue=\"javax.annotation.Nonnull\" />\n          <item index=\"2\" class=\"java.lang.String\" itemvalue=\"edu.umd.cs.findbugs.annotations.NonNull\" />\n          <item index=\"3\" class=\"java.lang.String\" itemvalue=\"android.support.annotation.NonNull\" />\n          <item index=\"4\" class=\"java.lang.String\" itemvalue=\"androidx.annotation.NonNull\" />\n          <item index=\"5\" class=\"java.lang.String\" itemvalue=\"androidx.annotation.RecentlyNonNull\" />\n          <item index=\"6\" class=\"java.lang.String\" itemvalue=\"org.checkerframework.checker.nullness.qual.NonNull\" />\n          <item index=\"7\" class=\"java.lang.String\" itemvalue=\"org.checkerframework.checker.nullness.compatqual.NonNullDecl\" />\n          <item index=\"8\" class=\"java.lang.String\" itemvalue=\"org.checkerframework.checker.nullness.compatqual.NonNullType\" />\n        </list>\n      </value>\n    </option>\n  </component>\n  <component name=\"ProjectRootManager\" version=\"2\" languageLevel=\"JDK_1_7\" project-jdk-name=\"1.8\" project-jdk-type=\"JavaSDK\">\n    <output url=\"file://$PROJECT_DIR$/build/classes\" />\n  </component>\n  <component name=\"ProjectType\">\n    <option name=\"id\" value=\"Android\" />\n  </component>\n</project>"
  },
  {
    "path": ".idea/modules.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"ProjectModuleManager\">\n    <modules>\n      <module fileurl=\"file://$PROJECT_DIR$/SegmentedControl_.iml\" filepath=\"$PROJECT_DIR$/SegmentedControl_.iml\" />\n      <module fileurl=\"file://$PROJECT_DIR$/app/app.iml\" filepath=\"$PROJECT_DIR$/app/app.iml\" />\n      <module fileurl=\"file://$PROJECT_DIR$/segmentedControl.iml\" filepath=\"$PROJECT_DIR$/segmentedControl.iml\" />\n      <module fileurl=\"file://$PROJECT_DIR$/segmentedcontrolmodule/segmentedcontrolmodule.iml\" filepath=\"$PROJECT_DIR$/segmentedcontrolmodule/segmentedcontrolmodule.iml\" />\n    </modules>\n  </component>\n</project>"
  },
  {
    "path": ".idea/runConfigurations.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"RunConfigurationProducerService\">\n    <option name=\"ignoredProducers\">\n      <set>\n        <option value=\"org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer\" />\n        <option value=\"org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer\" />\n        <option value=\"org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer\" />\n      </set>\n    </option>\n  </component>\n</project>"
  },
  {
    "path": ".idea/vcs.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"VcsDirectoryMappings\">\n    <mapping directory=\"\" vcs=\"Git\" />\n  </component>\n</project>"
  },
  {
    "path": "LICENSE",
    "content": "                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"{}\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright {yyyy} {name of copyright owner}\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "README.md",
    "content": "# Android SegmentedControl + multi row support + multi selection\n### minSdk API 14+\n\n![N|Solid](https://raw.githubusercontent.com/RobertApikyan/SegmentedControl/release_v0.1/app/src/main/res/mipmap-hdpi/ic_launcher.png)\n\n[Demo App, Play store link](https://play.google.com/store/apps/details?id=segmented_control.widget.custom.android.com.segmentedcontrolexample&hl=en)\n\n[Or try demo App online !](https://appetize.io/app/y4e91xhxgp47956bf73da4z4yg)\n\n[![](https://jitpack.io/v/RobertApikyan/SegmentedControl.svg)](https://jitpack.io/#RobertApikyan/SegmentedControl)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\n## Segmented control for Android, with a lot of customization properties\n\n<img src=\"https://raw.githubusercontent.com/RobertApikyan/SegmentedControl/release_v0.1/docs/intro.gif.gif\" width=\"300\" height=\"525\" />\n\n## ScreenShots\n\n<img src=\"https://raw.githubusercontent.com/RobertApikyan/SegmentedControl/intro/intro/ezgif.com-optimize.gif\" width=\"400\" />\n<img src=\"https://raw.githubusercontent.com/RobertApikyan/SegmentedControl/release_v0.1/docs/device-2017-09-14-133621.png\" width=\"400\" />\n<img src=\"https://raw.githubusercontent.com/RobertApikyan/SegmentedControl/release_v0.1/docs/device-2017-09-14-133711.png\" width=\"400\" />\n<img src=\"https://raw.githubusercontent.com/RobertApikyan/SegmentedControl/release_v0.1/docs/device-2017-09-14-133736.png\" width=\"400\" />\n<img src=\"https://raw.githubusercontent.com/RobertApikyan/SegmentedControl/release_v0.1/docs/device-2017-09-14-133907.png\" width=\"400\" />\n<img src=\"https://raw.githubusercontent.com/RobertApikyan/SegmentedControl/release_v0.1/docs/device-2017-09-14-134003.png\" width=\"400\" />\n<img src=\"https://raw.githubusercontent.com/RobertApikyan/SegmentedControl/release_v0.1/docs/device-2017-09-14-202249.png\" width=\"400\" />\n\n\n## Download\n### Gradle \nAdd to project level build.gradle\n```groovy\nallprojects {\n    repositories {\n        ...\n        maven { url 'https://jitpack.io' }\n    }\n}\n```\nAdd dependency to app module level build.gradle\n```groovy\ndependencies {\n    implementation 'com.github.RobertApikyan:SegmentedControl:1.2.0'\n}\n```\n### Maven\n```xml\n<repositories>\n\t<repository>\n\t    <id>jitpack.io</id>\n\t    <url>https://jitpack.io</url>\n\t</repository>\n</repositories>\n```\nAdd dependency\n```xml\n<dependency>\n    <groupId>com.github.RobertApikyan</groupId>\n    <artifactId>SegmentedControl</artifactId>\n    <version>1.1.3</version>\n</dependency>\n```\n\n \n### Done.\n\n## Simple usage in XML\n```xml\n<segmented_control.widget.custom.android.com.segmentedcontrol.SegmentedControl\n                android:id=\"@+id/segmented_control\"\n                android:layout_width=\"match_parent\"\n                android:layout_height=\"match_parent\"\n                android:layout_margin=\"8dp\"\n                app:columnCount=\"3\"\t\t\t\t       \n                app:distributeEvenly=\"true\"\n                app:textVerticalPadding=\"6dp\"\n                app:radius=\"12dp\"\n                app:segments=\"@array/your_array_data\" />\n```\n\nAttributes \n```xml\n     <attr name=\"supportedSelectionsCount\" format=\"boolean\" /> setSupportedSelectionsCount(int)\n     <attr name=\"reselectionEnabled\" format=\"boolean\" /> setDistributeEvenly(boolean)\n     <attr name=\"distributeEvenly\" format=\"boolean\" /> setDistributeEvenly(boolean)\n     <attr name=\"columnCount\" format=\"integer\" /> setColumnCount(int)\n     <attr name=\"segments\" format=\"reference\" /> addSegments(Object[]), addSegments(List)\n     <attr name=\"selectedStrokeColor\" format=\"color\" /> setSelectedStrokeColor(int)\n     <attr name=\"unSelectedStrokeColor\" format=\"color\" /> setUnSelectedStrokeColor(int)\n     <attr name=\"strokeWidth\" format=\"dimension\" / setStrokeWidth(int)\n     <attr name=\"selectedBackgroundColor\" format=\"color\" /> setSelectedBackgroundColor(int)\n     <attr name=\"unSelectedBackgroundColor\" format=\"color\" /> setUnSelectedBackgroundColor(int)\n     <attr name=\"selectedTextColor\" format=\"color\"/> setSelectedTextColor(int)\n     <attr name=\"unSelectedTextColor\" format=\"color\"/> setUnSelectedTextColor(int)\n     <attr name=\"textSize\" format=\"dimension\"/> setTextSize(int)\n     <attr name=\"selectionAnimationDuration\" format=\"integer\"/>\n     <attr name=\"focusedBackgroundColor\" format=\"color\"/>\n     <attr name=\"textHorizontalPadding\" format=\"dimension\"/> setTextHorizontalPadding(int)\n     <attr name=\"textVerticalPadding\" format=\"dimension\"/> setTextVerticalPadding(int)\n     <attr name=\"segmentVerticalMargin\" format=\"dimension\"/> setSegmentVerticalMargin(int)\n     <attr name=\"segmentHorizontalMargin\" format=\"dimension\"/> setSegmentHorizontalMargin(int)\n     <attr name=\"radius\" format=\"dimension\"/> setRadius(int)\n     <attr name=\"topLeftRadius\" format=\"dimension\"/> setTopLeftRadius(int)\n     <attr name=\"topRightRadius\" format=\"dimension\"/> setTopRightRadius(int)\n     <attr name=\"bottomRightRadius\" format=\"dimension\"/> setBottomRightRadius(int)\n     <attr name=\"bottomLeftRadius\" format=\"dimension\"/> setBottomLeftRadius(int)\n     <attr name=\"radiusForEverySegment\" format=\"boolean\"/> setRadiusForEverySegment(boolean)\n     <attr name=\"fontAssetPath\" format=\"string\"/>  setTypeFace(TypeFace)\n```\n        \n**Note:** After every configuration change call segmentedControl.notifyConfigIsChanged() method \n\n# Example\n```java\n        segmentedControl.setStrokeWidth(width.intValue());\n        segmentedControl.setColumnCount(columnCount);\n        segmentedControl.notifyConfigIsChanged();\n```\n\n> SegmentedControl uses SegmentAdapter and SegmentViewHolder for displaying segments. There are allready exist a default implementations for SegmentAdapter (SegmentAdapterImpl) and SegmentViewHolder (SegmentViewHolderImpl), but if you want to make your custom implementation... well here is the steps \n\n1. Define `segment_item.xml` inside `layouts` folder\n    ```xml\n    <LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        android:orientation=\"vertical\">\n\n        <TextView\n            android:id=\"@+id/text_view\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"match_parent\"\n            android:layout_gravity=\"center\"\n            android:layout_margin=\"2dp\"\n            android:background=\"@color/colorPrimary\"\n            android:gravity=\"center\"\n            android:textColor=\"@color/colorAccent\"\n            android:textSize=\"14sp\" />\n    </LinearLayout>\n    ```\n\n2. Create a `SegmentViewHolder` instance (`AppSegmentViewHolder`) (here I define the segment generic data type as a String)\n    ```java\n    public class AppSegmentViewHolder extends SegmentViewHolder<String> {\n        TextView textView;\n    \n        public AppSegmentViewHolder(@NonNull View sectionView) {\n            super(sectionView);\n            textView = (TextView) sectionView.findViewById(R.id.text_view);\n        }\n\n        @Override\n        protected void onSegmentBind(String segmentData) {\n            textView.setText(segmentData);\n        }\n    }\n    ```\n\n3. Create a `SegmentAdapter` instance \n    ```java\n    public class AppSegmentAdapter extends SegmentAdapter<String, AppSegmentViewHolder> {\n\n        @NonNull\n        @Override\n        protected AppSegmentViewHolder onCreateViewHolder(@NonNull LayoutInflater layoutInflater, ViewGroup viewGroup, int i) {\n            return new AppSegmentViewHolder(layoutInflater.inflate(R.layout.item_segment, null));\n        }\n    }\n    ```\n\n4. Pass the adapter to the segmentedControl\n    ```java\n    segmentedControl = (SegmentedControl) findViewById(R.id.segmented_control);\n    segmentedControl.setAdapter(new AppSegmentAdapter());\n    ```\n    \n5. Finally add segments data. \n    ```java\n    segmentedControl.addSegments(getResources().getStringArray(R.array.segments));\n    ```\nThat's it :)\n\nFor custom implementation use `SegmentedControlUtils` helper class in order to define segment background type and background radius.\n\n[![View Robert Apikyan profile on LinkedIn](https://www.linkedin.com/img/webpromo/btn_viewmy_160x33.png)](https://www.linkedin.com/in/robert-apikyan-24b915130/)\n\nLicense\n-------\n\n    Copyright 2017 Robert Apikyan\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\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        google()\n    }\n\n    dependencies {\n        classpath 'com.android.tools.build:gradle:3.4.1'\n        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'\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        google()\n        maven { url 'https://jitpack.io' }\n    }\n}\n\ntask clean(type: Delete) {\n    delete rootProject.buildDir\n}\n"
  },
  {
    "path": "gradle/wrapper/gradle-wrapper.properties",
    "content": "#Fri Apr 19 11:27:29 AMT 2019\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_HOME\nzipStorePath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-5.1.1-all.zip\n"
  },
  {
    "path": "gradle.properties",
    "content": "# Project-wide Gradle settings.\n\n# IDE (e.g. Android Studio) users:\n# Gradle settings configured through the IDE *will override*\n# any settings specified in this file.\n\n# For more details on how to configure your build environment visit\n# http://www.gradle.org/docs/current/userguide/build_environment.html\n\n# Specifies the JVM arguments used for the daemon process.\n# The setting is particularly useful for tweaking memory settings.\norg.gradle.jvmargs=-Xmx1536m\n\n# When configured, Gradle will run in incubating parallel mode.\n# This option should only be used with decoupled projects. More details, visit\n# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects\n# org.gradle.parallel=true\n"
  },
  {
    "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# 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\\\"`/\" >/dev/null\nAPP_HOME=\"`pwd -P`\"\ncd \"$SAVED\" >/dev/null\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    JAVACMD=`cygpath --unix \"$JAVACMD\"`\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": "segmentedcontrolmodule/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "segmentedcontrolmodule/build.gradle",
    "content": "apply plugin: 'com.android.library'\n\nandroid {\n    compileSdkVersion 28\n\n    defaultConfig {\n        minSdkVersion 14\n        targetSdkVersion 28\n        versionCode 1\n        versionName \"1.2.0\"\n\n        testInstrumentationRunner \"android.support.test.runner.AndroidJUnitRunner\"\n\n    }\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n        }\n    }\n}\n\ndependencies {\n    implementation fileTree(dir: 'libs', include: ['*.jar'])\n    implementation 'com.android.support:appcompat-v7:28.0.0'\n    api 'com.github.RobertApikyan:ViewComponent:1.0.3'\n    api 'com.github.RobertApikyan:SecLayout:1.0.3'\n}\n\ntask sourcesJar(type: Jar) {\n    from android.sourceSets.main.java.srcDirs\n    classifier = 'sources'\n}\n\nartifacts {\n    archives sourcesJar\n}\n"
  },
  {
    "path": "segmentedcontrolmodule/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in D:\\sdk/tools/proguard/proguard-android.txt\n# You can edit the include path and order by changing the proguardFiles\n# directive in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# Add any project specific keep options here:\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n\n# Uncomment this to preserve the line number information for\n# debugging stack traces.\n#-keepattributes SourceFile,LineNumberTable\n\n# If you keep the line number information, uncomment this to\n# hide the original source file name.\n#-renamesourcefileattribute SourceFile\n"
  },
  {
    "path": "segmentedcontrolmodule/src/main/AndroidManifest.xml",
    "content": "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n\n    package=\"segmented_control.widget.custom.android.com.segmented_control\">\n\n    <application android:label=\"@string/app_name\" />\n\n</manifest>\n"
  },
  {
    "path": "segmentedcontrolmodule/src/main/java/segmented_control/widget/custom/android/com/segmentedcontrol/Assert.java",
    "content": "package segmented_control.widget.custom.android.com.segmentedcontrol;\n\nimport section_layout.widget.custom.android.com.sectionlayout.SectionLayout;\n\n/**\n * Created by Robert Apikyan on 9/7/2017.\n */\n\nclass Assert {\n\n    static void adapter(SectionLayout.Adapter adapter) {\n        throwIf(adapter == null, new IllegalArgumentException(\"SegmentedControl#setAdapter -> adapter can't be null\"));\n    }\n\n    static void columnCount(int columnCount) {\n        throwIf(columnCount < Configs.DEFAULT_COLUMN_COUNT,\n                new IllegalArgumentException(\"SegmentedControl#setColumnCount -> columnCounts value is invalid:\" + \" \" + \"columnCount = \" + columnCount));\n    }\n\n    static void outOfBounds(int position, int size, String methodName) {\n        throwIf(position > size, new IndexOutOfBoundsException(methodName + \" -> \" + \"position = \" + position + \" \" + \"size = \" + size));\n    }\n\n    private static void throwIf(boolean willThrow, Exception exception) {\n        if (willThrow) {\n            try {\n                throw exception;\n            } catch (Exception e) {\n                e.printStackTrace();\n            }\n        }\n    }\n\n    public static void supportedSelectionsCount(int supportedSelectionsCount) {\n        throwIf(supportedSelectionsCount < Configs.DEFAULT_SUPPORTED_SELECTIONS_COUNT,\n                new IllegalStateException(\"SegmentedControl#setSupportedSelectionsCount -> supportedSelectionsCount value is invalid: \" +\n                        \" \" + \"supportedSelectionsCount= \"+supportedSelectionsCount));\n    }\n}\n\n"
  },
  {
    "path": "segmentedcontrolmodule/src/main/java/segmented_control/widget/custom/android/com/segmentedcontrol/Configs.java",
    "content": "package segmented_control.widget.custom.android.com.segmentedcontrol;\n\nimport segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column.SegmentDecoration;\n\n/**\n * Created by Robert Apikyan on 9/7/2017.\n */\n\nclass Configs {\n    static final int DEFAULT_COLUMN_COUNT = 2;\n    static final int DEFAULT_SUPPORTED_SELECTIONS_COUNT = 1;\n\n    boolean willDistributeEvenly;\n    boolean reselectionEnabled;\n\n    int columnCount;\n    int supportedSelectionsCount;\n\n    SegmentDecoration segmentDecoration = new SegmentDecoration();\n\n    static Configs getDefault() {\n        Configs configs = new Configs();\n        configs.reselectionEnabled = true;\n        configs.willDistributeEvenly = false;\n        configs.columnCount = DEFAULT_COLUMN_COUNT;\n        configs.supportedSelectionsCount = DEFAULT_SUPPORTED_SELECTIONS_COUNT;\n        return configs;\n    }\n}\n"
  },
  {
    "path": "segmentedcontrolmodule/src/main/java/segmented_control/widget/custom/android/com/segmentedcontrol/Consumer.java",
    "content": "package segmented_control.widget.custom.android.com.segmentedcontrol;\n\n/**\n * Created by Robert Apikyan on 9/8/2017.\n */\n\ninterface Consumer<T> {\n    void apply(T t);\n}\n"
  },
  {
    "path": "segmentedcontrolmodule/src/main/java/segmented_control/widget/custom/android/com/segmentedcontrol/Notifier.java",
    "content": "package segmented_control.widget.custom.android.com.segmentedcontrol;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column.SegmentViewHolder;\nimport segmented_control.widget.custom.android.com.segmentedcontrol.listeners.OnSegmentClickListener;\nimport segmented_control.widget.custom.android.com.segmentedcontrol.listeners.OnSegmentSelectRequestListener;\nimport segmented_control.widget.custom.android.com.segmentedcontrol.listeners.OnSegmentSelectedListener;\n\nimport static segmented_control.widget.custom.android.com.segmentedcontrol.utils.Utils.lazy;\n\n\n/**\n * Created by Robert Apikyan on 9/8/2017.\n */\n\nclass Notifier<D> implements OnSegmentClickListener<D>, OnSegmentSelectedListener<D>, OnSegmentSelectRequestListener<D> {\n    private List<OnSegmentClickListener<D>> onSegmentClickListeners;\n    private List<OnSegmentSelectedListener<D>> onSegmentSelectedListeners;\n    @SuppressWarnings(\"unchecked\")\n    private OnSegmentSelectRequestListener<D> onSegmentSelectRequestListener;\n\n    @Override\n    public void onSegmentClick(final SegmentViewHolder<D> segmentViewHolder) {\n        onEvent(onSegmentClickListeners, new Consumer<OnSegmentClickListener<D>>() {\n            @Override\n            public void apply(OnSegmentClickListener<D> onSegmentClickListener) {\n                onSegmentClickListener.onSegmentClick(segmentViewHolder);\n            }\n        });\n    }\n\n    @Override\n    public void onSegmentSelected(final SegmentViewHolder<D> segmentViewHolder, final boolean isSelected, final boolean isReselected) {\n        onEvent(onSegmentSelectedListeners, new Consumer<OnSegmentSelectedListener<D>>() {\n            @Override\n            public void apply(OnSegmentSelectedListener<D> onSegmentSelectedListener) {\n                onSegmentSelectedListener.onSegmentSelected(segmentViewHolder, isSelected, isReselected);\n            }\n        });\n    }\n\n    @Override\n    public boolean onSegmentSelectRequest(final SegmentViewHolder<D> segmentViewHolder) {\n        return onSegmentSelectRequestListener == null || onSegmentSelectRequestListener.onSegmentSelectRequest(segmentViewHolder);\n    }\n\n    void addOnSegmentClickListener(OnSegmentClickListener<D> onSegmentClickListener) {\n        onSegmentClickListeners = lazy(onSegmentClickListeners, new ArrayList<OnSegmentClickListener<D>>());\n        onSegmentClickListeners.add(onSegmentClickListener);\n    }\n\n    void removeOnSegmentClickListener(OnSegmentClickListener<D> onSegmentClickListener) {\n        onSegmentClickListeners = lazy(onSegmentClickListeners, new ArrayList<OnSegmentClickListener<D>>());\n        onSegmentClickListeners.remove(onSegmentClickListener);\n    }\n\n    void addOnSegmentSelectListener(OnSegmentSelectedListener<D> onSegmentSelectedListener) {\n        onSegmentSelectedListeners = lazy(onSegmentSelectedListeners, new ArrayList<OnSegmentSelectedListener<D>>());\n        onSegmentSelectedListeners.add(onSegmentSelectedListener);\n    }\n\n    void removeOnSegmentSelectListener(OnSegmentSelectedListener<D> onSegmentSelectedListener) {\n        onSegmentSelectedListeners = lazy(onSegmentSelectedListeners, new ArrayList<OnSegmentSelectedListener<D>>());\n        onSegmentSelectedListeners.remove(onSegmentSelectedListener);\n    }\n\n    void setOnSegmentSelectRequestListener(OnSegmentSelectRequestListener<D> onSegmentSelectRequestListener) {\n        this.onSegmentSelectRequestListener = onSegmentSelectRequestListener;\n    }\n\n\n    private <T> void onEvent(List<T> eventListeners, Consumer<T> listenerConsumer) {\n        if (eventListeners != null && eventListeners.size() != 0) {\n            for (T t : eventListeners) {\n                listenerConsumer.apply(t);\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "segmentedcontrolmodule/src/main/java/segmented_control/widget/custom/android/com/segmentedcontrol/SegmentConsumer.java",
    "content": "package segmented_control.widget.custom.android.com.segmentedcontrol;\n\nimport segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column.SegmentViewHolder;\n\npublic interface SegmentConsumer<D> {\n    void apply(SegmentViewHolder<D> segmentViewHolder);\n}"
  },
  {
    "path": "segmentedcontrolmodule/src/main/java/segmented_control/widget/custom/android/com/segmentedcontrol/SegmentedControl.java",
    "content": "package segmented_control.widget.custom.android.com.segmentedcontrol;\n\nimport android.content.Context;\nimport android.content.res.TypedArray;\nimport android.graphics.Typeface;\nimport android.support.annotation.NonNull;\nimport android.util.AttributeSet;\nimport android.util.TypedValue;\nimport android.view.LayoutInflater;\n\nimport java.util.List;\n\nimport section_layout.widget.custom.android.com.sectionlayout.SectionLayout;\nimport segmented_control.widget.custom.android.com.segmented_control.R;\nimport segmented_control.widget.custom.android.com.segmentedcontrol.custom_segment.SegmentAdapterImpl;\nimport segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column.SegmentAdapter;\nimport segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column.SegmentViewHolder;\nimport segmented_control.widget.custom.android.com.segmentedcontrol.listeners.OnSegmentClickListener;\nimport segmented_control.widget.custom.android.com.segmentedcontrol.listeners.OnSegmentSelectRequestListener;\nimport segmented_control.widget.custom.android.com.segmentedcontrol.listeners.OnSegmentSelectedListener;\nimport view_component.lib_android.com.view_component.base_view.layouts.ComponentFrameLayout;\n\nimport static segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column.SegmentDecoration.DEFAULT_SELECTION_ANIMATION_DURATION;\n\n/**\n * Created by Robert Apikyan on 8/18/2017.\n * /*     Attributes\n * <attr name=\"distributeEvenly\" format=\"boolean\" /> {@link #setDistributeEvenly(boolean)}\n * <attr name=\"reselectionEnabled\" format=\"boolean\" /> {@link #setReselectionEnabled(boolean)}\n * <attr name=\"columnCount\" format=\"integer\" /> {@link #setColumnCount(int)}\n * <attr name=\"segments\" format=\"reference\" /> {@link #addSegments(Object[])} {@link #addSegments(List)}\n * <attr name=\"supportedSegmentsCount\" format=\"reference\"/> {@link #setSupportedSelectionsCount(int)}\n * <attr name=\"selectedStrokeColor\" format=\"color\" /> {@link #setSelectedStrokeColor(int)}\n * <attr name=\"unSelectedStrokeColor\" format=\"color\" /> {@link #setUnSelectedStrokeColor(int)}\n * <attr name=\"strokeWidth\" format=\"dimension\" />{@link #setStrokeWidth(int)}\n * <attr name=\"selectedBackgroundColor\" format=\"color\" /> {@link #setSelectedBackgroundColor(int)}\n * <attr name=\"unSelectedBackgroundColor\" format=\"color\" /> {@link #setUnSelectedBackgroundColor(int)}\n * <attr name=\"selectedTextColor\" format=\"color\"/> {@link #setSelectedTextColor(int)}\n * <attr name=\"unSelectedTextColor\" format=\"color\"/> {@link #setUnSelectedTextColor(int)}\n * <attr name=\"textSize\" format=\"dimension\"/> {@link #setTextSize(int)}\n * <attr name=\"textHorizontalPadding\" format=\"dimension\"/> {@link #setTextHorizontalPadding(int)}\n * <attr name=\"textVerticalPadding\" format=\"dimension\"/> {@link #setTextVerticalPadding(int)}\n * <attr name=\"segmentVerticalMargin\" format=\"dimension\"/> {@link #setSegmentVerticalMargin(int)}\n * <attr name=\"segmentHorizontalMargin\" format=\"dimension\"/> {@link #setSegmentHorizontalMargin(int)}\n * <attr name=\"radius\" format=\"dimension\"/> {@link #setRadius(int)}\n * <attr name=\"topLeftRadius\" format=\"dimension\"/> {@link #setTopLeftRadius(int)}\n * <attr name=\"topRightRadius\" format=\"dimension\"/> {@link #setTopRightRadius(int)}\n * <attr name=\"bottomRightRadius\" format=\"dimension\"/> {@link #setBottomRightRadius(int)}\n * <attr name=\"bottomLeftRadius\" format=\"dimension\"/> {@link #setBottomLeftRadius(int)}\n * <attr name=\"radiusForEverySegment\" format=\"boolean\"/> {@link #setRadiusForEverySegment(boolean)}\n *\n * @param <D>\n */\npublic class SegmentedControl<D> extends ComponentFrameLayout<SegmentedControlViewComponent<D>,\n        SegmentedControlControllerComponent<D>> {\n    public SegmentedControl(Context context) {\n        this(context, null);\n    }\n\n    public SegmentedControl(Context context, AttributeSet attrs) {\n        this(context, attrs, 0);\n    }\n\n    public SegmentedControl(Context context, AttributeSet attrs, int defStyle) {\n        super(context, attrs, defStyle);\n        initAttr(attrs, defStyle);\n    }\n\n    private void initAttr(AttributeSet attrs, int defStyle) {\n        TypedArray typedArray = getContext().obtainStyledAttributes(attrs,\n                R.styleable.SegmentedControl,\n                defStyle, 0);\n        fetchAccentColor();\n        try {\n            attrDistributeEvenly(typedArray);\n            attrReselectionEnabled(typedArray);\n            attrColumnCount(typedArray);\n            attrSupportedSelectionsCount(typedArray);\n            attrSelectedStrokeColor(typedArray);\n            attrUnSelectedStrokeColor(typedArray);\n            attrStrokeWidth(typedArray);\n            attrSelectedBackgroundColor(typedArray);\n            attrFocusedBackgroundColor(typedArray);\n            attrSelectionAnimationDuration(typedArray);\n            attrUnSelectedBackgroundColor(typedArray);\n            attrSelectedTextColor(typedArray);\n            attrUnSelectedTextColor(typedArray);\n            attrTextSize(typedArray);\n            attrFontAssetPath(typedArray);\n            attrTextVerticalPadding(typedArray);\n            attrTextHorizontalPadding(typedArray);\n            attrSegmentHorizontalMargin(typedArray);\n            attrSegmentVerticalMargin(typedArray);\n            attrTopLeftRadius(typedArray);\n            attrTopRightRadius(typedArray);\n            attrBottomRightRadius(typedArray);\n            attrBottomLeftRadius(typedArray);\n            attrRadius(typedArray);\n            attrRadiusForEverySegment(typedArray);\n            attrSegments(typedArray);\n        } finally {\n            typedArray.recycle();\n        }\n    }\n\n    private void fetchAccentColor() {\n        TypedValue tv = new TypedValue();\n        TypedArray typedArray = getContext().obtainStyledAttributes(tv.data, new int[]{R.attr.colorAccent});\n        try {\n            getControllerComponent().setAccentColor(typedArray.getColor(0, 0));\n        } finally {\n            typedArray.recycle();\n        }\n    }\n\n    private void attrSelectedStrokeColor(TypedArray typedArray) {\n        obtainColorAttr(typedArray, R.styleable.SegmentedControl_selectedStrokeColor, new Consumer<Integer>() {\n            @Override\n            public void apply(Integer color) {\n                getControllerComponent().setSelectedStrokeColor(color);\n            }\n        });\n    }\n\n    private void attrUnSelectedStrokeColor(TypedArray typedArray) {\n        obtainColorAttr(typedArray, R.styleable.SegmentedControl_unSelectedStrokeColor, new Consumer<Integer>() {\n            @Override\n            public void apply(Integer color) {\n                getControllerComponent().setUnSelectedStrokeColor(color);\n            }\n        });\n    }\n\n    private void attrStrokeWidth(TypedArray typedArray) {\n        obtainDimensionAttr(typedArray, R.styleable.SegmentedControl_strokeWidth, new Consumer<Integer>() {\n            @Override\n            public void apply(Integer width) {\n                getControllerComponent().setStrokeWidth(width);\n            }\n        });\n    }\n\n    private void attrSelectedBackgroundColor(TypedArray typedArray) {\n        obtainColorAttr(typedArray, R.styleable.SegmentedControl_selectedBackgroundColor, new Consumer<Integer>() {\n            @Override\n            public void apply(Integer color) {\n                getControllerComponent().setSelectedBackgroundColor(color);\n            }\n        });\n    }\n\n    private void attrUnSelectedBackgroundColor(TypedArray typedArray) {\n        obtainColorAttr(typedArray, R.styleable.SegmentedControl_unSelectedBackgroundColor, new Consumer<Integer>() {\n            @Override\n            public void apply(Integer color) {\n                getControllerComponent().setUnSelectedBackgroundColor(color);\n            }\n        });\n    }\n\n    private void attrFocusedBackgroundColor(TypedArray typedArray) {\n        obtainColorAttr(typedArray, R.styleable.SegmentedControl_focusedBackgroundColor, new Consumer<Integer>() {\n            @Override\n            public void apply(Integer color) {\n                getControllerComponent().setFocusedBackgroundColor(color);\n            }\n        });\n    }\n\n    private void attrSelectionAnimationDuration(TypedArray typedArray) {\n        getControllerComponent().setSelectionAnimationDuration(\n                typedArray.getInt(R.styleable.SegmentedControl_selectionAnimationDuration,\n                        DEFAULT_SELECTION_ANIMATION_DURATION));\n    }\n\n    private void attrSelectedTextColor(TypedArray typedArray) {\n        obtainColorAttr(typedArray, R.styleable.SegmentedControl_selectedTextColor, new Consumer<Integer>() {\n            @Override\n            public void apply(Integer color) {\n                getControllerComponent().setSelectedTextColor(color);\n            }\n        });\n    }\n\n    private void attrUnSelectedTextColor(TypedArray typedArray) {\n        obtainColorAttr(typedArray, R.styleable.SegmentedControl_unSelectedTextColor, new Consumer<Integer>() {\n            @Override\n            public void apply(Integer color) {\n                getControllerComponent().setUnSelectedTextColor(color);\n            }\n        });\n    }\n\n    private void attrTextSize(TypedArray typedArray) {\n        int textSize = typedArray.getDimensionPixelSize(R.styleable.SegmentedControl_textSize,\n                (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 14,\n                        getResources().getDisplayMetrics()));\n        if (textSize > 0) {\n            getControllerComponent().setTextSize(textSize);\n        }\n    }\n\n    private void attrFontAssetPath(TypedArray typedArray) {\n        String fontPath = typedArray.getString(R.styleable.SegmentedControl_fontAssetPath);\n        if (fontPath != null && !fontPath.isEmpty()) {\n            getControllerComponent().setTypeFace(Typeface.createFromAsset(getContext().getAssets(), fontPath));\n        }\n    }\n\n    private void attrTextVerticalPadding(TypedArray typedArray) {\n        obtainDimensionAttr(typedArray, R.styleable.SegmentedControl_textVerticalPadding, new Consumer<Integer>() {\n            @Override\n            public void apply(Integer dimen) {\n                getControllerComponent().setTextVerticalPadding(dimen);\n            }\n        });\n    }\n\n    private void attrTextHorizontalPadding(TypedArray typedArray) {\n        obtainDimensionAttr(typedArray, R.styleable.SegmentedControl_textHorizontalPadding, new Consumer<Integer>() {\n            @Override\n            public void apply(Integer dimen) {\n                getControllerComponent().setTextHorizontalPadding(dimen);\n            }\n        });\n    }\n\n    private void attrSegmentVerticalMargin(TypedArray typedArray) {\n        obtainDimensionAttr(typedArray, R.styleable.SegmentedControl_segmentVerticalMargin, new Consumer<Integer>() {\n            @Override\n            public void apply(Integer dimen) {\n                getControllerComponent().setSegmentVerticalMargin(dimen);\n            }\n        });\n    }\n\n    private void attrSegmentHorizontalMargin(TypedArray typedArray) {\n        obtainDimensionAttr(typedArray, R.styleable.SegmentedControl_segmentHorizontalMargin, new Consumer<Integer>() {\n            @Override\n            public void apply(Integer dimen) {\n                getControllerComponent().setSegmentHorizontalMargin(dimen);\n            }\n        });\n    }\n\n    private void attrRadius(TypedArray typedArray) {\n        obtainDimensionAttr(typedArray, R.styleable.SegmentedControl_radius, new Consumer<Integer>() {\n            @Override\n            public void apply(Integer dimen) {\n                getControllerComponent().setRadius(dimen);\n            }\n        });\n    }\n\n    private void attrTopLeftRadius(TypedArray typedArray) {\n        obtainDimensionAttr(typedArray, R.styleable.SegmentedControl_topLeftRadius, new Consumer<Integer>() {\n            @Override\n            public void apply(Integer dimen) {\n                getControllerComponent().setTopLeftRadius(dimen);\n            }\n        });\n    }\n\n    private void attrTopRightRadius(TypedArray typedArray) {\n        obtainDimensionAttr(typedArray, R.styleable.SegmentedControl_topRightRadius, new Consumer<Integer>() {\n            @Override\n            public void apply(Integer dimen) {\n                getControllerComponent().setTopRightRadius(dimen);\n            }\n        });\n    }\n\n    private void attrBottomRightRadius(TypedArray typedArray) {\n        obtainDimensionAttr(typedArray, R.styleable.SegmentedControl_bottomRightRadius, new Consumer<Integer>() {\n            @Override\n            public void apply(Integer dimen) {\n                getControllerComponent().setBottomRightRadius(dimen);\n            }\n        });\n    }\n\n    private void attrBottomLeftRadius(TypedArray typedArray) {\n        obtainDimensionAttr(typedArray, R.styleable.SegmentedControl_bottomLeftRadius, new Consumer<Integer>() {\n            @Override\n            public void apply(Integer dimen) {\n                getControllerComponent().setBottomLeftRadius(dimen);\n            }\n        });\n    }\n\n    private void attrRadiusForEverySegment(TypedArray typedArray) {\n        boolean radiusForEverySegment = typedArray.getBoolean(R.styleable.SegmentedControl_radiusForEverySegment, false);\n        getControllerComponent().setRadiusForEverySegment(radiusForEverySegment);\n    }\n\n    private void attrSegments(TypedArray typedArray) {\n        CharSequence[] items = typedArray.getTextArray(R.styleable.SegmentedControl_segments);\n        useDefaultAdapter();\n        //noinspection unchecked\n        getControllerComponent().addSegments((D[]) items);\n    }\n\n    private void attrColumnCount(TypedArray typedArray) {\n        int columnCount = typedArray.getInteger(R.styleable.SegmentedControl_columnCount, Configs.DEFAULT_COLUMN_COUNT);\n        getControllerComponent().setColumnCount(columnCount);\n        notifyConfigIsChanged();\n    }\n\n    private void attrSupportedSelectionsCount(TypedArray typedArray) {\n        int supportedSelectionsCount = typedArray.getInteger(R.styleable.SegmentedControl_supportedSelectionsCount, Configs.DEFAULT_SUPPORTED_SELECTIONS_COUNT);\n        if (supportedSelectionsCount > 0) {\n            getControllerComponent().setSupportedSelectionsCount(supportedSelectionsCount);\n        }\n    }\n\n    private void attrDistributeEvenly(TypedArray typedArray) {\n        boolean willDistribute = typedArray.getBoolean(R.styleable.SegmentedControl_distributeEvenly, false);\n        getControllerComponent().setDistributeEvenly(willDistribute);\n        getControllerComponent().notifyConfigIsChanged();\n    }\n\n    private void attrReselectionEnabled(TypedArray typedArray) {\n        boolean reselectionEnabled = typedArray.getBoolean(R.styleable.SegmentedControl_reselectionEnabled, true);\n        getControllerComponent().setReselectionEnabled(reselectionEnabled);\n    }\n\n    private void obtainColorAttr(TypedArray typedArray, int attr, Consumer<Integer> colorConsumer) {\n        int color = typedArray.getColor(attr, -2); // -1 is white\n        if (color != -2) {\n            colorConsumer.apply(color);\n        }\n    }\n\n    private void obtainDimensionAttr(TypedArray typedArray, int attr, Consumer<Integer> dimensionConsumer) {\n        int dimensionPixelSize = typedArray.getDimensionPixelSize(attr, -1);\n        if (dimensionPixelSize != -1) {\n            dimensionConsumer.apply(dimensionPixelSize);\n        }\n    }\n\n    @NonNull\n    @Override\n    public SegmentedControlViewComponent<D> createViewComponent(@NonNull LayoutInflater layoutInflater) {\n        addView(new SectionLayout<D>(getContext()), 0);\n        return new SegmentedControlViewComponent<>(this);\n    }\n\n    @NonNull\n    @Override\n    public SegmentedControlControllerComponent<D> createControllerComponent() {\n        return new SegmentedControlControllerComponent<>();\n    }\n\n    /**\n     * Will enabled multy selection, default value is 1, only one item can be selected at the time\n     * @param supportedSelectionsCount specifies the count of selected segments at the same time,\n     *                                 if the selection count is reached the elder selection\n     *                                 will be unselected\n     */\n    public void setSupportedSelectionsCount(int supportedSelectionsCount) {\n        Assert.supportedSelectionsCount(supportedSelectionsCount);\n        getControllerComponent().setSupportedSelectionsCount(supportedSelectionsCount);\n    }\n\n    /**\n     * @param columnCount The column count for SegmentedControl\n     */\n    public void setColumnCount(int columnCount) {\n        Assert.columnCount(columnCount);\n        getControllerComponent().setColumnCount(columnCount);\n    }\n\n    /**\n     * @param adapter, NonNull adapter (extended from {@link SegmentAdapter})\n     */\n    public void setAdapter(@NonNull SegmentAdapter adapter) {\n        Assert.adapter(adapter);\n        getControllerComponent().setAdapter(adapter);\n    }\n\n    /**\n     * set the adapter {@link SegmentAdapter} with {@link segmented_control.widget.custom.android.com.segmentedcontrol.custom_segment.SegmentViewHolderImpl} view holder\n     * where data D data type is String. use segmentedControl.addSegments(String[] segmentDataArray) or segmentedControl.addSegments(List<String> segmentDataList) methods\n     */\n    public void useDefaultAdapter() {\n        setAdapter(new SegmentAdapterImpl());\n    }\n\n    /**\n     * Add segments to segmentController\n     *\n     * @param segmentData, specified array Data type\n     */\n    public void addSegments(D[] segmentData) {\n        getControllerComponent().addSegments(segmentData);\n    }\n\n    /**\n     * Add segments to segmentController\n     *\n     * @param segmentData, specified list Data type\n     */\n    public void addSegments(List<D> segmentData) {\n        getControllerComponent().addSegments(segmentData);\n    }\n\n    /**\n     * @param willDistributeEvenly, true each section width with will be equal to each other,\n     *                              false each section width will be measured depending on its content width;\n     */\n    public void setDistributeEvenly(boolean willDistributeEvenly) {\n        getControllerComponent().setDistributeEvenly(willDistributeEvenly);\n    }\n\n    /**\n     * @param isEnabled if true second click to segment will not turn it from selected to unselected state,\n     *                  if false the second click will turn it from selected to un selected state,\n     *                  default value is true\n     */\n    public void setReselectionEnabled(boolean isEnabled) {\n        getControllerComponent().setReselectionEnabled(isEnabled);\n    }\n\n    /**\n     * @param onSegmentClickListener, every time click event will be notified,\n     *                                even if the segment is already selected\n     */\n    public void addOnSegmentClickListener(OnSegmentClickListener<D> onSegmentClickListener) {\n        getControllerComponent().addOnSegmentClickListener(onSegmentClickListener);\n    }\n\n    /**\n     * @param onSegmentClickListener, every time click event will be notified,\n     *                                even if the segment is already selected\n     *                                <p>\n     *                                Remove listener\n     */\n    public void removeOnSegmentClickListener(OnSegmentClickListener<D> onSegmentClickListener) {\n        getControllerComponent().removeOnSegmentClickListener(onSegmentClickListener);\n    }\n\n    /**\n     * @param onSegmentSelectedListener, event will be notified, when segment is selected and unSelected and reselected,\n     *                                   for more info check out {@link OnSegmentSelectedListener} class\n     */\n    public void addOnSegmentSelectListener(OnSegmentSelectedListener<D> onSegmentSelectedListener) {\n        getControllerComponent().addOnSegmentSelectListener(onSegmentSelectedListener);\n    }\n\n    /**\n     * @param onSegmentSelectedListener, event will be notified, when segment is selected and unSelected and reselected,\n     *                                   for more info check out {@link OnSegmentSelectedListener} class\n     *                                   <p>\n     *                                   Remove listener\n     */\n    public void removeOnSegmentSelectListener(OnSegmentSelectedListener<D> onSegmentSelectedListener) {\n        getControllerComponent().removeOnSegmentSelectListener(onSegmentSelectedListener);\n    }\n\n    /**\n     * @param onSegmentSelectRequestListener, event will be triggered after click event and before selection event\n     *                                        for more info click out {@link OnSegmentSelectRequestListener} class\n     */\n    public void setOnSegmentSelectRequestListener(OnSegmentSelectRequestListener<D> onSegmentSelectRequestListener) {\n        getControllerComponent().setOnSegmentSelectRequestListener(onSegmentSelectRequestListener);\n    }\n\n    /**\n     * Removes all segments\n     */\n    public void removeAllSegments() {\n        getControllerComponent().removeAllSegments();\n    }\n\n    /**\n     * find the segment view holder with the segment absolute position\n     *\n     * @param position, the segment position\n     * @return SegmentViewHolder instance for specified position\n     */\n    public SegmentViewHolder<D> findSegmentByAbsolutePosition(int position) {\n        Assert.outOfBounds(position, size(), \"SegmentedControl#findSegmentByAbsolutePosition\");\n        return getControllerComponent().findSegmentByAbsolutePosition(position);\n    }\n\n    /**\n     * find the segment with column number and row position\n     *\n     * @param column, Segment column number\n     * @param row,    Segment row position\n     * @return SegmentViewHolder instance for specified column and row numbers\n     */\n    public SegmentViewHolder<D> findSegmentByColumnAndRow(int column, int row) {\n        Assert.outOfBounds(getControllerComponent().getAbsolutePosition(column, row), size(), \"SegmentedControl#setSelectedSegment\");\n        return getControllerComponent().findSegmentByColumnAndRow(column, row);\n    }\n\n    /**\n     * Select the selected position\n     *\n     * @param position, Segment position\n     */\n    public void setSelectedSegment(int position) {\n        Assert.outOfBounds(position, size(), \"SegmentedControl#setSelectedSegment\");\n        getControllerComponent().setSelectedSegment(position);\n    }\n\n    /**\n     * Select the segment with specified column number and row position\n     *\n     * @param column, Segment column number\n     * @param row,    Segment row position\n     */\n    public void setSelectedSegment(int column, int row) {\n        Assert.outOfBounds(getControllerComponent().getAbsolutePosition(column, row), size(), \"SegmentedControl#setSelectedSegment\");\n        getControllerComponent().setSelectedSegment(column, row);\n    }\n\n    /**\n     * Iterate on segments, and pass the view holders as an argument for {@link SegmentConsumer}\n     *\n     * @param segmentConsumer, Segment consumer\n     */\n    public void forEachSegment(SegmentConsumer<D> segmentConsumer) {\n        getControllerComponent().forEachSegment(segmentConsumer);\n    }\n\n    public void setSelectedStrokeColor(int color) {\n        getControllerComponent().setSelectedStrokeColor(color);\n    }\n\n    public void setUnSelectedStrokeColor(int color) {\n        getControllerComponent().setUnSelectedStrokeColor(color);\n    }\n\n    public void setFocusedBackgroundColor(int color) {\n        getControllerComponent().setFocusedBackgroundColor(color);\n    }\n\n    /**\n     * Set segments selection animation duration value\n     *\n     * @param duration in milliseconds\n     */\n    public void setSelectionAnimationDuration(int duration) {\n        getControllerComponent().setSelectionAnimationDuration(duration);\n    }\n\n    public void setStrokeWidth(int width) {\n        getControllerComponent().setStrokeWidth(width);\n    }\n\n    public void setSelectedBackgroundColor(int color) {\n        getControllerComponent().setSelectedBackgroundColor(color);\n    }\n\n    public void setUnSelectedBackgroundColor(int color) {\n        getControllerComponent().setUnSelectedBackgroundColor(color);\n    }\n\n    public void setSelectedTextColor(int color) {\n        getControllerComponent().setSelectedTextColor(color);\n    }\n\n    public void setUnSelectedTextColor(int color) {\n        getControllerComponent().setUnSelectedTextColor(color);\n    }\n\n    public void setTextSize(int textSize) {\n        getControllerComponent().setTextSize(textSize);\n    }\n\n    public void setTypeFace(Typeface typeFace) {\n        getControllerComponent().setTypeFace(typeFace);\n    }\n\n    public void setTextVerticalPadding(int padding) {\n        getControllerComponent().setTextVerticalPadding(padding);\n    }\n\n    public void setTextHorizontalPadding(int padding) {\n        getControllerComponent().setTextHorizontalPadding(padding);\n    }\n\n    public void setSegmentVerticalMargin(int margin) {\n        getControllerComponent().setSegmentVerticalMargin(margin);\n    }\n\n    public void setSegmentHorizontalMargin(int margin) {\n        getControllerComponent().setSegmentHorizontalMargin(margin);\n    }\n\n    public void setRadius(int radius) {\n        getControllerComponent().setRadius(radius);\n    }\n\n    public void setTopLeftRadius(int radius) {\n        getControllerComponent().setTopLeftRadius(radius);\n    }\n\n    public void setTopRightRadius(int radius) {\n        getControllerComponent().setTopRightRadius(radius);\n    }\n\n    public void setBottomRightRadius(int radius) {\n        getControllerComponent().setBottomRightRadius(radius);\n    }\n\n    public void setBottomLeftRadius(int radius) {\n        getControllerComponent().setBottomLeftRadius(radius);\n    }\n\n    /**\n     * @param radiusForEverySegment, true every segment corners will be rounded, false only top left,top right, bottom right and bottom left corners will be rounded\n     */\n    public void setRadiusForEverySegment(boolean radiusForEverySegment) {\n        getControllerComponent().setRadiusForEverySegment(radiusForEverySegment);\n    }\n\n    /**\n     * Removes the last selected segment selection, SegmentViewHolder's onSegmentSelected  method will be called\n     * with isSelected = false, isReselected = false\n     */\n    public void clearSelection() {\n        getControllerComponent().clearSelection(false);\n    }\n\n    /**\n     * Removes the last selected segment selection, SegmentViewHolder's onSegmentSelected  method will be called\n     * with isSelected = false, isReselected = false.\n     *\n     * @param notifySegmentSelectedListener if true SegmentSelectedListeners will be notified.\n     */\n    public void clearSelection(boolean notifySegmentSelectedListener) {\n        getControllerComponent().clearSelection(notifySegmentSelectedListener);\n    }\n\n    /**\n     * Call this method after every configuration change\n     * setColumnCount, setRadius et...\n     */\n    public void notifyConfigIsChanged() {\n        getControllerComponent().notifyConfigIsChanged();\n    }\n\n    public int size() {\n        return getControllerComponent().size();\n    }\n\n//    public SegmentViewHolder<D> getSelectedViewHolder() {\n//        return getControllerComponent().getSelectedViewHolder();\n//    }\n\n    /**\n     * @return int[]{column,row} Section column and row numbers\n     */\n    public int[] getLastSelectedColumnAndRow() {\n        return getControllerComponent().getLastSelectedColumnAndRow();\n    }\n\n    public int getLastSelectedAbsolutePosition() {\n        return getControllerComponent().getLastSelectedAbsolutePosition();\n    }\n\n    public boolean hasSelectedSegment() {\n        return getControllerComponent().isSelected();\n    }\n}\n"
  },
  {
    "path": "segmentedcontrolmodule/src/main/java/segmented_control/widget/custom/android/com/segmentedcontrol/SegmentedControlControllerComponent.java",
    "content": "package segmented_control.widget.custom.android.com.segmentedcontrol;\n\nimport android.graphics.Typeface;\nimport android.support.annotation.Nullable;\n\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.LinkedList;\nimport java.util.List;\nimport java.util.Queue;\n\nimport section_layout.widget.custom.android.com.sectionlayout.SectionLayout;\nimport section_layout.widget.custom.android.com.sectionlayout.distributive_section_layout.DistributiveSectionLayout;\nimport segmented_control.widget.custom.android.com.segmentedcontrol.item_row.SegmentRowAdapter;\nimport segmented_control.widget.custom.android.com.segmentedcontrol.item_row.SegmentRowViewHolder;\nimport segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column.SegmentAdapter;\nimport segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column.SegmentData;\nimport segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column.SegmentDecoration;\nimport segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column.SegmentViewHolder;\nimport segmented_control.widget.custom.android.com.segmentedcontrol.listeners.OnSegmentClickListener;\nimport segmented_control.widget.custom.android.com.segmentedcontrol.listeners.OnSegmentSelectRequestListener;\nimport segmented_control.widget.custom.android.com.segmentedcontrol.listeners.OnSegmentSelectedListener;\nimport view_component.lib_android.com.view_component.base_view.ControllerComponent;\n\n/**\n * Created by Robert Apikyan on 9/5/2017.\n */\n\nclass SegmentedControlControllerComponent<D> extends ControllerComponent<SegmentedControlViewComponent<D>> {\n    private final Configs configs = Configs.getDefault();\n    //    private SegmentViewHolder<D> lastClickedSegmentViewHolder;\n    private LinkedList<SegmentViewHolder<D>> selectedSegments = new LinkedList<>();\n    private final Notifier<D> notifier = new Notifier<>();\n    private final List<D> dataList = new ArrayList<>();\n\n//    private final OnSegmentClickListener<D> _onSegmentClickListener = new OnSegmentClickListener<D>() {\n//        @Override\n//        public void onSegmentClick(SegmentViewHolder<D> segmentViewHolder) {\n//            notifier.onSegmentClick(segmentViewHolder);\n//\n//            if (segmentViewHolder.equals(lastClickedSegmentViewHolder)) {\n//                // on section reselected\n//                segmentViewHolder.setSelected(true);\n//                notifier.onSegmentSelected(segmentViewHolder, true, true);\n//            } else if (notifier.onSegmentSelectRequest(segmentViewHolder)) {\n//                // on section selected\n//                // unSelect the last one\n//                if (lastClickedSegmentViewHolder != null) {\n//                    lastClickedSegmentViewHolder.setSelected(false);\n//                    notifier.onSegmentSelected(lastClickedSegmentViewHolder, false, false);\n//                }\n//                // select the current\n//                lastClickedSegmentViewHolder = segmentViewHolder;\n//                segmentViewHolder.setSelected(true);\n//                notifier.onSegmentSelected(segmentViewHolder, true, false);\n//            }\n//        }\n//    };\n\n    private final OnSegmentClickListener<D> onSegmentClickListener = new OnSegmentClickListener<D>() {\n        @Override\n        public void onSegmentClick(SegmentViewHolder<D> segmentViewHolder) {\n            notifier.onSegmentClick(segmentViewHolder);\n\n            int index = selectedSegments.indexOf(segmentViewHolder);\n            boolean contains = index != -1;\n            if (contains) {\n                // on section reselected\n                SegmentViewHolder<D> viewHolder = selectedSegments.get(index);\n                if (configs.reselectionEnabled){\n                    viewHolder.setSelected(true);\n                    notifier.onSegmentSelected(segmentViewHolder, true, true);\n                }else{\n                    selectedSegments.remove(index);\n                    viewHolder.setSelected(false);\n                    notifier.onSegmentSelected(segmentViewHolder, false, false);\n                }\n\n            } else if (notifier.onSegmentSelectRequest(segmentViewHolder)) {\n                // on section selected\n                // unSelect the last one\n                SegmentViewHolder<D> lastSelected = addSelectedSegmentViewHolder(segmentViewHolder);\n                if (lastSelected != null) {\n                    lastSelected.setSelected(false);\n                    notifier.onSegmentSelected(lastSelected, false, false);\n                }\n                // select the current\n                segmentViewHolder.setSelected(true);\n                notifier.onSegmentSelected(segmentViewHolder, true, false);\n            }\n        }\n    };\n\n    /**\n     * Watch the supported selections count, if limit is reached the oldest segment will be removed from\n     * selections list and returned back to method caller\n     *\n     * @param segmentViewHolder new selected segment;\n     * @return oldest selection\n     */\n    @Nullable\n    private SegmentViewHolder<D> addSelectedSegmentViewHolder(SegmentViewHolder<D> segmentViewHolder) {\n        selectedSegments.add(segmentViewHolder);\n        if (selectedSegments.size() > configs.supportedSelectionsCount) {\n            return selectedSegments.remove(0);\n        }\n        return null;\n    }\n\n    private SegmentViewHolder<D> getLastSelectedViewHolder() {\n        return selectedSegments.size() > 0 ? selectedSegments.getLast() : null;\n    }\n\n    private void addSegment(D segmentData) {\n        if (getVerticalSectionLayout().size() == 0 || !canAddToLastRow()) {\n            addNewRow();\n        }\n\n        addSegmentToLastRow(segmentData);\n    }\n\n    // removeLastSelected = true\n//    private void removeAllSegments(boolean removeLastSelected) {\n//        for (int row = 0; row < getVerticalSectionLayout().size(); row++) {\n//            getHorizontalSectionLayout(row).removeAllSections();\n//        }\n//        getVerticalSectionLayout().removeAllSections();\n//        dataList.clear();\n//\n//        if (removeLastSelected) {\n//            lastClickedSegmentViewHolder = null;\n//        }\n//    }\n\n    private void removeAllSegments(boolean removeLastSelected) {\n        for (int row = 0; row < getVerticalSectionLayout().size(); row++) {\n            getHorizontalSectionLayout(row).removeAllSections();\n        }\n        getVerticalSectionLayout().removeAllSections();\n        dataList.clear();\n\n        if (removeLastSelected) {\n            selectedSegments.clear();\n        }\n    }\n\n    private void addSegmentToLastRow(D segmentData) {\n        DistributiveSectionLayout<SegmentData<D>> horizontalSectionLayout = getHorizontalSectionLayout(getLastRowIndex());\n        horizontalSectionLayout\n                .addSection(SegmentData.create(segmentData, onSegmentClickListener, getAbsolutePosition(getLastHorizontalSectionLayout().size(),\n                        getVerticalSectionLayout().size() - 1), getLastRowIndex(), horizontalSectionLayout.size(), size(), configs.columnCount, configs.segmentDecoration));\n        horizontalSectionLayout.requestLayout();\n    }\n\n    private int[] getRowAndColumnWithAbsolutePosition(int position) {\n        int smallDiff = position % configs.columnCount;\n        int diff = position - smallDiff;\n        int row = (diff / configs.columnCount) + (smallDiff == configs.columnCount ? 1 : 0);\n        int column = position % configs.columnCount;\n        return new int[]{row, column};\n    }\n\n    void notifyConfigIsChanged() {\n        recreate(false);\n    }\n\n//    public void clearSelection(boolean notifySegmentSelectedListener) {\n//        if (lastClickedSegmentViewHolder != null) {\n//            lastClickedSegmentViewHolder.setSelected(false);\n//\n//            if (notifySegmentSelectedListener) {\n//                notifier.onSegmentSelected(lastClickedSegmentViewHolder, false, false);\n//            }\n//\n//            lastClickedSegmentViewHolder = null;\n//        }\n//    }\n\n    public void clearSelection(boolean notifySegmentSelectedListener) {\n        if (!selectedSegments.isEmpty()) {\n            for (SegmentViewHolder<D> selectedSegment : selectedSegments) {\n                selectedSegment.setSelected(false);\n\n                if (notifySegmentSelectedListener) {\n                    notifier.onSegmentSelected(selectedSegment, false, false);\n                }\n            }\n\n            selectedSegments.clear();\n        }\n    }\n\n//    private void recreate(boolean removeLastSelected) {\n//        if (dataList.size() == 0) return;\n//        List<D> itemsData = new ArrayList<>(dataList);\n//        removeAllSegments(removeLastSelected);\n//        addSegments(itemsData);\n//        if (lastClickedSegmentViewHolder != null) {\n//            setSelectedSegment(lastClickedSegmentViewHolder.getAbsolutePosition());\n//        }\n//    }\n\n    private void recreate(boolean removeLastSelected) {\n        if (dataList.size() == 0) return;\n        List<D> itemsData = new ArrayList<>(dataList);\n        removeAllSegments(removeLastSelected);\n        addSegments(itemsData);\n\n        SegmentViewHolder<D> lastSelection = getLastSelectedViewHolder();\n        if (lastSelection != null) {\n            setSelectedSegment(lastSelection.getAbsolutePosition());\n        }\n    }\n\n    private boolean canAddToLastRow() {\n        return getHorizontalSectionLayout(getLastRowIndex()).size() < configs.columnCount;\n    }\n\n    private void addNewRow() {\n        //noinspection unchecked\n        getVerticalSectionLayout().addSection(configs.willDistributeEvenly);\n    }\n\n    private SectionLayout getVerticalSectionLayout() {\n        //noinspection ConstantConditions\n        return getViewComponent().verticalSectionLayout;\n    }\n\n    private DistributiveSectionLayout<SegmentData<D>> getHorizontalSectionLayout(int row) {\n        //noinspection unchecked\n        SegmentRowViewHolder<D> segmentedViewHolder = (SegmentRowViewHolder<D>) getVerticalSectionLayout().getViewHolderForAdapterPosition(row);\n        return segmentedViewHolder.getDistributiveSectionLayout();\n    }\n\n    private DistributiveSectionLayout<SegmentData<D>> getLastHorizontalSectionLayout() {\n        return getHorizontalSectionLayout(getLastRowIndex());\n    }\n\n    private int getLastRowIndex() {\n        return getVerticalSectionLayout().size() - 1;\n    }\n\n    SegmentViewHolder<D> findSegmentByAbsolutePosition(int position) {\n        int[] point = getRowAndColumnWithAbsolutePosition(position);\n        return findSegmentByColumnAndRow(point[0], point[1]);\n    }\n\n    SegmentViewHolder<D> findSegmentByColumnAndRow(int column, int row) {\n        return (SegmentViewHolder<D>) getHorizontalSectionLayout(column).getViewHolderForAdapterPosition(row);\n    }\n\n    void forEachSegment(SegmentConsumer<D> segmentConsumer) {\n        for (int row = 0; row < getVerticalSectionLayout().size(); row++) {\n            DistributiveSectionLayout<SegmentData<D>> horizontalSectionLayout = getHorizontalSectionLayout(row);\n            for (int column = 0; column < horizontalSectionLayout.size(); column++) {\n                segmentConsumer.apply(findSegmentByColumnAndRow(row, column));\n            }\n        }\n    }\n\n    void setAccentColor(int color) {\n        configs.segmentDecoration = SegmentDecoration.createDefault(getContext(), color);\n    }\n\n    void setSelectedStrokeColor(int color) {\n        configs.segmentDecoration.selectedStrokeColor = color;\n    }\n\n    void setUnSelectedStrokeColor(int color) {\n        configs.segmentDecoration.unSelectedStrokeColor = color;\n    }\n\n    void setStrokeWidth(int width) {\n        configs.segmentDecoration.strokeWidth = width;\n    }\n\n    void setSelectedBackgroundColor(int color) {\n        configs.segmentDecoration.selectBackgroundColor = color;\n    }\n\n    void setUnSelectedBackgroundColor(int color) {\n        configs.segmentDecoration.unSelectedBackgroundColor = color;\n    }\n\n    void setFocusedBackgroundColor(int color) {\n        configs.segmentDecoration.focusedBackgroundColor = color;\n    }\n\n    void setReselectionEnabled(boolean isEnabled){\n        configs.reselectionEnabled = isEnabled;\n    }\n\n    void setSelectionAnimationDuration(int duration) {\n        configs.segmentDecoration.selectionAnimationDuration = duration;\n    }\n\n    void setSelectedTextColor(int color) {\n        configs.segmentDecoration.selectedTextColor = color;\n    }\n\n    void setUnSelectedTextColor(int color) {\n        configs.segmentDecoration.unSelectedTextColor = color;\n    }\n\n    void setTextSize(int textSize) {\n        configs.segmentDecoration.textSize = textSize;\n    }\n\n    void setTypeFace(Typeface typeFace) {\n        configs.segmentDecoration.typeface = typeFace;\n    }\n\n    void setTextVerticalPadding(int padding) {\n        configs.segmentDecoration.textVerticalPadding = padding;\n    }\n\n    void setTextHorizontalPadding(int padding) {\n        configs.segmentDecoration.textHorizontalPadding = padding;\n    }\n\n    void setSegmentVerticalMargin(int margin) {\n        configs.segmentDecoration.segmentVerticalMargin = margin;\n    }\n\n    void setSegmentHorizontalMargin(int margin) {\n        configs.segmentDecoration.segmentHorizontalMargin = margin;\n    }\n\n    void setRadius(int radius) {\n        setTopLeftRadius(radius);\n        setTopRightRadius(radius);\n        setBottomRightRadius(radius);\n        setBottomLeftRadius(radius);\n    }\n\n    void setTopLeftRadius(int radius) {\n        configs.segmentDecoration.topLeftRadius = radius;\n    }\n\n    void setTopRightRadius(int radius) {\n        configs.segmentDecoration.topRightRadius = radius;\n    }\n\n    void setBottomRightRadius(int radius) {\n        configs.segmentDecoration.bottomRightRadius = radius;\n    }\n\n    void setBottomLeftRadius(int radius) {\n        configs.segmentDecoration.bottomLeftRadius = radius;\n    }\n\n    void setRadiusForEverySegment(boolean radiusForEverySegment) {\n        configs.segmentDecoration.radiusForEverySegment = radiusForEverySegment;\n    }\n\n    void setAdapter(SegmentAdapter adapter) {\n        //noinspection ConstantConditions, setAdapter will be called from SegmentedControl\n        getViewComponent().verticalSectionLayout.withAdapter(new SegmentRowAdapter(adapter));\n    }\n\n    void addSegments(D[] segmentDataArray) {\n        if (segmentDataArray == null || segmentDataArray.length == 0) return;\n        addSegments(new ArrayList<>(Arrays.asList(segmentDataArray)));\n    }\n\n    void addSegments(List<D> segmentDataList) {\n        if (segmentDataList == null || segmentDataList.size() == 0) return;\n\n        dataList.addAll(new ArrayList<>(segmentDataList));\n\n        for (D segmentData : dataList) {\n            addSegment(segmentData);\n        }\n    }\n\n    void removeAllSegments() {\n        removeAllSegments(true);\n    }\n\n    void setDistributeEvenly(boolean willDistributeEvenly) {\n        configs.willDistributeEvenly = willDistributeEvenly;\n    }\n\n    void setSupportedSelectionsCount(int supportedSelectionsCount) {\n        configs.supportedSelectionsCount = supportedSelectionsCount;\n    }\n\n    void setColumnCount(int columnCount) {\n        configs.columnCount = columnCount;\n    }\n\n    void addOnSegmentClickListener(OnSegmentClickListener<D> onSegmentClickListener) {\n        notifier.addOnSegmentClickListener(onSegmentClickListener);\n    }\n\n    void removeOnSegmentClickListener(OnSegmentClickListener<D> onSegmentClickListener) {\n        notifier.removeOnSegmentClickListener(onSegmentClickListener);\n    }\n\n    void addOnSegmentSelectListener(OnSegmentSelectedListener<D> onSegmentSelectedListener) {\n        notifier.addOnSegmentSelectListener(onSegmentSelectedListener);\n    }\n\n    void removeOnSegmentSelectListener(OnSegmentSelectedListener<D> onSegmentSelectedListener) {\n        notifier.removeOnSegmentSelectListener(onSegmentSelectedListener);\n    }\n\n    void setOnSegmentSelectRequestListener(OnSegmentSelectRequestListener<D> onSegmentSelectRequestListener) {\n        notifier.setOnSegmentSelectRequestListener(onSegmentSelectRequestListener);\n    }\n\n    void setSelectedSegment(int absolutePosition) {\n        int[] point = getRowAndColumnWithAbsolutePosition(absolutePosition);\n        setSelectedSegment(point[0], point[1]);\n    }\n\n    void setSelectedSegment(int column, int row) {\n        onSegmentClickListener.onSegmentClick(findSegmentByColumnAndRow(column, row));\n    }\n\n//    SegmentViewHolder<D> getSelectedViewHolder() {\n//        return lastClickedSegmentViewHolder;\n//    }\n\n    List<SegmentViewHolder<D>> getSelectedViewHolders() {\n        return selectedSegments;\n    }\n\n    int[] getLastSelectedColumnAndRow() {\n        SegmentViewHolder<D> lastSelection = getLastSelectedViewHolder();\n        if (lastSelection != null) {\n            return new int[]{lastSelection.getColumn(), lastSelection.getRow()};\n        } else {\n            return new int[]{-1, -1};\n        }\n    }\n\n    //\n    int getLastSelectedAbsolutePosition() {\n        SegmentViewHolder<D> lastSelection = getLastSelectedViewHolder();\n        if (lastSelection != null) {\n            return lastSelection.getAbsolutePosition();\n        } else {\n            return -1;\n        }\n    }\n\n//    boolean isSelected() {\n//        return lastClickedSegmentViewHolder != null;\n//    }\n\n    boolean isSelected() {\n        return !selectedSegments.isEmpty();\n    }\n\n    int size() {\n        return dataList.size();\n    }\n\n    int getAbsolutePosition(int column, int row) {\n        return row * configs.columnCount + column;\n    }\n}\n"
  },
  {
    "path": "segmentedcontrolmodule/src/main/java/segmented_control/widget/custom/android/com/segmentedcontrol/SegmentedControlViewComponent.java",
    "content": "package segmented_control.widget.custom.android.com.segmentedcontrol;\n\nimport android.support.annotation.NonNull;\nimport android.view.View;\nimport android.widget.LinearLayout;\n\nimport section_layout.widget.custom.android.com.sectionlayout.SectionLayout;\nimport view_component.lib_android.com.view_component.base_view.ViewComponent;\n\n/**\n * Created by Robert Apikyan on 9/5/2017.\n */\n\nclass SegmentedControlViewComponent<D> extends ViewComponent {\n    final SectionLayout<D> verticalSectionLayout;\n\n    SegmentedControlViewComponent(@NonNull View rootView) {\n        super(rootView);\n        //noinspection unchecked\n        verticalSectionLayout = (SectionLayout<D>) getRootViewGroup().getChildAt(0);\n        verticalSectionLayout.setOrientation(LinearLayout.VERTICAL);\n    }\n}\n"
  },
  {
    "path": "segmentedcontrolmodule/src/main/java/segmented_control/widget/custom/android/com/segmentedcontrol/custom_segment/SegmentAdapterImpl.java",
    "content": "package segmented_control.widget.custom.android.com.segmentedcontrol.custom_segment;\n\nimport android.support.annotation.NonNull;\nimport android.view.LayoutInflater;\nimport android.view.ViewGroup;\n\nimport segmented_control.widget.custom.android.com.segmented_control.R;\nimport segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column.SegmentAdapter;\n\n/**\n * Created by Robert Apikyan on 9/8/2017.\n */\n\npublic class SegmentAdapterImpl extends SegmentAdapter<CharSequence, SegmentViewHolderImpl> {\n\n    @NonNull\n    @Override\n    protected SegmentViewHolderImpl onCreateViewHolder(@NonNull LayoutInflater layoutInflater, ViewGroup viewGroup, int i) {\n        return new SegmentViewHolderImpl(layoutInflater.inflate(R.layout.item_segment_impl, null));\n    }\n}\n"
  },
  {
    "path": "segmentedcontrolmodule/src/main/java/segmented_control/widget/custom/android/com/segmentedcontrol/custom_segment/SegmentViewHolderImpl.java",
    "content": "package segmented_control.widget.custom.android.com.segmentedcontrol.custom_segment;\n\nimport android.animation.ValueAnimator;\nimport android.annotation.SuppressLint;\nimport android.graphics.drawable.Drawable;\nimport android.os.Build;\nimport android.support.annotation.NonNull;\nimport android.util.TypedValue;\nimport android.view.MotionEvent;\nimport android.view.View;\nimport android.view.ViewGroup;\nimport android.widget.TextView;\n\nimport segmented_control.widget.custom.android.com.segmented_control.R;\nimport segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column.SegmentViewHolder;\n\nimport static segmented_control.widget.custom.android.com.segmentedcontrol.utils.Utils.createBackgroundAnimation;\nimport static segmented_control.widget.custom.android.com.segmentedcontrol.utils.Utils.createRadius;\nimport static segmented_control.widget.custom.android.com.segmentedcontrol.utils.Utils.defineRadiusForPosition;\nimport static segmented_control.widget.custom.android.com.segmentedcontrol.utils.Utils.getBackground;\nimport static segmented_control.widget.custom.android.com.segmentedcontrol.utils.Utils.isInBounds;\n\n/**\n * Created by Robert Apikyan on 9/8/2017.\n */\n\npublic class SegmentViewHolderImpl extends SegmentViewHolder<CharSequence> {\n\n    private TextView itemTV;\n    private float[] radius;\n    private ValueAnimator va;\n    private int[] windowLocation;\n\n    private final ValueAnimator.AnimatorUpdateListener bgAnimListener = new ValueAnimator.AnimatorUpdateListener() {\n        @Override\n        public void onAnimationUpdate(ValueAnimator animation) {\n            int colorArgb = (int) animation.getAnimatedValue();\n            Drawable bg = getBackground(getStrokeWidth(), isSelected() ? getSelectedStrokeColor() : getUnSelectedStrokeColor(), colorArgb, radius);\n            setBackground(bg);\n        }\n    };\n\n    @SuppressWarnings(\"FieldCanBeLocal\")\n    private final View.OnTouchListener segmentTouchListener = new View.OnTouchListener() {\n        @SuppressLint(\"ClickableViewAccessibility\")\n        @Override\n        public boolean onTouch(View v, MotionEvent event) {\n            if (isSelected()) {\n                return false;\n            }\n            if (event.getAction() == MotionEvent.ACTION_DOWN) {\n                setBackground(getFocusedBackground());\n\n            } else if (event.getAction() == MotionEvent.ACTION_UP ||\n                    event.getAction() == MotionEvent.ACTION_CANCEL ||\n                    event.getAction() == MotionEvent.ACTION_POINTER_UP ||\n                    event.getAction() == MotionEvent.ACTION_OUTSIDE) {\n\n                if (!isInBounds(event.getX(), event.getY(), windowLocation[0], windowLocation[1],\n                        getSectionView().getMeasuredWidth(), getSectionView().getMeasuredHeight())) {\n\n                    setBackground(isSelected() ? getSelectedBackground() : getUnSelectedBackground());\n                }\n            }\n            return false;\n        }\n    };\n\n    public SegmentViewHolderImpl(@NonNull View sectionView) {\n        super(sectionView);\n        itemTV = sectionView.findViewById(R.id.item_segment_tv);\n        sectionView.setOnTouchListener(segmentTouchListener);\n    }\n\n    @Override\n    protected void onSegmentBind(CharSequence segmentData) {\n        initScreenLocation();\n        itemTV.setText(segmentData);\n        if (isRadiusForEverySegment()) {\n            radius = createRadius(getTopLeftRadius(), getTopRightRadius(), getBottomRightRadius(), getBottomLeftRadius());\n        } else {\n            radius = defineRadiusForPosition(getAbsolutePosition(), getColumnCount(), getCurrentSize(), getTopLeftRadius(), getTopRightRadius(), getBottomRightRadius(), getBottomLeftRadius());\n        }\n        setSectionDecorationSelected(false, false);\n        itemTV.setTextSize(TypedValue.COMPLEX_UNIT_PX, getTextSize());\n        if (getTypeFace() != null) {\n            itemTV.setTypeface(getTypeFace());\n        }\n        itemTV.setPadding(getTextHorizontalPadding(), getTextVerticalPadding(), getTextHorizontalPadding(), getTextVerticalPadding());\n        ((ViewGroup.MarginLayoutParams) itemTV.getLayoutParams()).setMargins(getSegmentHorizontalMargin(), getSegmentVerticalMargin(), getSegmentHorizontalMargin(), getSegmentVerticalMargin());\n    }\n\n    private void initScreenLocation() {\n        windowLocation = new int[2];\n        getSectionView().getLocationOnScreen(windowLocation);\n    }\n\n    @Override\n    public void onSegmentSelected(boolean isSelected, boolean isReselected) {\n        super.onSegmentSelected(isSelected, isReselected);\n        setSectionDecorationSelected(isSelected, isReselected);\n    }\n\n    private Drawable getSelectedBackground() {\n        return getBackground(getStrokeWidth(), getSelectedStrokeColor(), getSelectBackgroundColor(), radius);\n    }\n\n    private Drawable getUnSelectedBackground() {\n        return getBackground(getStrokeWidth(), getUnSelectedStrokeColor(), getUnSelectedBackgroundColor(), radius);\n    }\n\n    private Drawable getFocusedBackground() {\n        return getBackground(getStrokeWidth(), isSelected() ? getSelectedStrokeColor() : getUnSelectedStrokeColor(), getFocusedBackgroundColor(), radius);\n    }\n\n    private void setSectionDecorationSelected(boolean isSelected, boolean isReselected) {\n        if (isReselected)\n            return;\n\n        if (hasBackground()) {\n            animateNewBackground(isSelected);\n        } else {\n            setBackground(isSelected ? getSelectedBackground() : getUnSelectedBackground());\n        }\n\n        itemTV.setTextColor(isSelected ? getSelectedTextColor() : getUnSelectedTextColor());\n    }\n\n    private void animateNewBackground(boolean isSelected) {\n\n        if (va != null) {\n            va.end();\n            va.removeUpdateListener(bgAnimListener);\n        }\n\n        // animate\n        int startColor = isSelected ? getFocusedBackgroundColor() : getSelectBackgroundColor();\n        int endColor = isSelected ? getSelectBackgroundColor() : getUnSelectedBackgroundColor();\n\n        va = createBackgroundAnimation(startColor, endColor);\n\n        va.addUpdateListener(bgAnimListener);\n\n        va.setDuration(getSelectionAnimationDuration());\n\n        va.start();\n    }\n\n    private void setBackground(Drawable drawable) {\n        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {\n            itemTV.setBackground(drawable);\n        } else {\n            //noinspection deprecation\n            itemTV.setBackgroundDrawable(drawable);\n        }\n    }\n\n    private boolean hasBackground() {\n        return itemTV.getBackground() != null;\n    }\n}\n"
  },
  {
    "path": "segmentedcontrolmodule/src/main/java/segmented_control/widget/custom/android/com/segmentedcontrol/item_row/SegmentRowAdapter.java",
    "content": "package segmented_control.widget.custom.android.com.segmentedcontrol.item_row;\n\nimport android.support.annotation.NonNull;\nimport android.view.LayoutInflater;\nimport android.view.ViewGroup;\n\nimport section_layout.widget.custom.android.com.sectionlayout.SectionLayout;\nimport section_layout.widget.custom.android.com.sectionlayout.distributive_section_layout.DistributiveSectionLayout;\nimport segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column.SegmentAdapter;\nimport segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column.SegmentData;\n\n/**\n * Created by Robert Apikyan on 9/7/2017.\n */\n\npublic class SegmentRowAdapter<D> extends SectionLayout.Adapter<Boolean, SegmentRowViewHolder<SegmentData<D>>> {\n\n    private final SegmentAdapter segmentAdapter;\n\n    public SegmentRowAdapter(SegmentAdapter segmentAdapter) {\n        this.segmentAdapter = segmentAdapter;\n    }\n\n    @NonNull\n    @Override\n    protected SegmentRowViewHolder<SegmentData<D>> onCreateViewHolder(@NonNull LayoutInflater layoutInflater, ViewGroup viewGroup, int i) {\n        return new SegmentRowViewHolder<>(new DistributiveSectionLayout<SegmentData<D>>(layoutInflater.getContext()), segmentAdapter);\n    }\n}\n"
  },
  {
    "path": "segmentedcontrolmodule/src/main/java/segmented_control/widget/custom/android/com/segmentedcontrol/item_row/SegmentRowViewHolder.java",
    "content": "package segmented_control.widget.custom.android.com.segmentedcontrol.item_row;\n\nimport android.support.annotation.NonNull;\nimport android.view.View;\nimport android.widget.LinearLayout;\n\nimport section_layout.widget.custom.android.com.sectionlayout.SectionLayout;\nimport section_layout.widget.custom.android.com.sectionlayout.distributive_section_layout.DistributiveSectionLayout;\nimport segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column.SegmentAdapter;\nimport segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column.SegmentData;\n\n/**\n * Created by Robert Apikyan on 9/7/2017.\n */\n\npublic class SegmentRowViewHolder<D> extends SectionLayout.ViewHolder<Boolean> {\n    private final DistributiveSectionLayout<SegmentData<D>> distributiveSectionLayout;\n\n    SegmentRowViewHolder(@NonNull View sectionView, SegmentAdapter segmentAdapter) {\n        super(sectionView);\n        //noinspection unchecked\n        distributiveSectionLayout = (DistributiveSectionLayout<SegmentData<D>>) sectionView;\n        distributiveSectionLayout.setOrientation(LinearLayout.HORIZONTAL);\n        distributiveSectionLayout.withAdapter(segmentAdapter);\n    }\n\n    @Override\n    protected void onBind(Boolean willDistributeEvenly) {\n        distributiveSectionLayout.distributeEvenly(willDistributeEvenly);\n    }\n\n    public DistributiveSectionLayout<SegmentData<D>> getDistributiveSectionLayout() {\n        return distributiveSectionLayout;\n    }\n}\n"
  },
  {
    "path": "segmentedcontrolmodule/src/main/java/segmented_control/widget/custom/android/com/segmentedcontrol/item_row_column/SegmentAdapter.java",
    "content": "package segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column;\n\nimport section_layout.widget.custom.android.com.sectionlayout.distributive_section_layout.DistributiveSectionLayout;\n\n/**\n * Created by Robert Apikyan on 9/7/2017.\n */\n\npublic abstract class SegmentAdapter<D, VH extends SegmentViewHolder<D>> extends DistributiveSectionLayout.Adapter<SegmentData<D>, VH> {\n\n}\n"
  },
  {
    "path": "segmentedcontrolmodule/src/main/java/segmented_control/widget/custom/android/com/segmentedcontrol/item_row_column/SegmentBackgroundType.java",
    "content": "package segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column;\n\nimport android.support.annotation.IntDef;\n\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\n\nimport static segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column.SegmentBackgroundType.BOTTOM_LEFT_BG;\nimport static segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column.SegmentBackgroundType.BOTTOM_RIGHT_BG;\nimport static segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column.SegmentBackgroundType.BOTTOM_SINGLE_BG;\nimport static segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column.SegmentBackgroundType.MIDDLE_BG;\nimport static segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column.SegmentBackgroundType.SINGLE_BG;\nimport static segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column.SegmentBackgroundType.TOP_LEFT_BG;\nimport static segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column.SegmentBackgroundType.TOP_LEFT_SINGLE_BG;\nimport static segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column.SegmentBackgroundType.TOP_RIGHT_BG;\nimport static segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column.SegmentBackgroundType.TOP_RIGHT_SINGLE_BG;\nimport static segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column.SegmentBackgroundType.TOP_SINGLE_BG;\n\n/**\n * Created by Robert Apikyan on 9/12/2017.\n */\n@IntDef(value = {SINGLE_BG,\n        TOP_SINGLE_BG,\n        TOP_LEFT_BG,\n        TOP_LEFT_SINGLE_BG,\n        TOP_RIGHT_SINGLE_BG,\n        TOP_RIGHT_BG,\n        MIDDLE_BG,\n        BOTTOM_SINGLE_BG,\n        BOTTOM_LEFT_BG,\n        BOTTOM_RIGHT_BG})\n@Retention(RetentionPolicy.SOURCE)\npublic @interface SegmentBackgroundType {\n    int SINGLE_BG = 0;\n    int TOP_SINGLE_BG = 1;\n    int TOP_LEFT_BG = 2;\n    int TOP_LEFT_SINGLE_BG = 3;\n    int TOP_RIGHT_SINGLE_BG = 4;\n    int TOP_RIGHT_BG = 5;\n    int MIDDLE_BG = 6;\n    int BOTTOM_SINGLE_BG = 7;\n    int BOTTOM_LEFT_BG = 8;\n    int BOTTOM_RIGHT_BG = 9;\n}\n"
  },
  {
    "path": "segmentedcontrolmodule/src/main/java/segmented_control/widget/custom/android/com/segmentedcontrol/item_row_column/SegmentData.java",
    "content": "package segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column;\n\nimport android.graphics.Typeface;\n\nimport segmented_control.widget.custom.android.com.segmentedcontrol.listeners.OnSegmentClickListener;\n\n/**\n * Created by Robert Apikyan on 9/7/2017.\n */\n\npublic class SegmentData<D> {\n    boolean isSelected;\n    int absolutePosition;\n\n    private int row;\n    private int column;\n\n    private D segmentData;\n    private OnSegmentClickListener<D> onSegmentClickListener;\n\n    private SegmentDecoration segmentDecoration;\n    private int currentSize;\n    private int columnCount;\n\n    public static <D> SegmentData<D> create(D segmentData, OnSegmentClickListener<D> onSegmentClickListener, int absolutePosition, int row, int column, int currentSize, int columnCount, SegmentDecoration segmentDecoration) {\n        SegmentData<D> sd = new SegmentData<>();\n        sd.segmentData = segmentData;\n        sd.absolutePosition = absolutePosition;\n        sd.row = row;\n        sd.column = column;\n        sd.currentSize = currentSize;\n        sd.columnCount = columnCount;\n        sd.segmentDecoration = segmentDecoration;\n        sd.onSegmentClickListener = onSegmentClickListener;\n        return sd;\n    }\n\n    public boolean isSelected() {\n        return isSelected;\n    }\n\n    public int getAbsolutePosition() {\n        return absolutePosition;\n    }\n\n    public int getRow() {\n        return row;\n    }\n\n    public int getColumn() {\n        return column;\n    }\n\n    public D getSegmentData() {\n        return segmentData;\n    }\n\n    public OnSegmentClickListener<D> getOnSegmentClickListener() {\n        return onSegmentClickListener;\n    }\n\n    public int getSelectedStrokeColor() {\n        return segmentDecoration.getSelectedStrokeColor();\n    }\n\n    public int getUnSelectedStrokeColor() {\n        return segmentDecoration.getUnSelectedStrokeColor();\n    }\n\n    public int getStrokeWidth() {\n        return segmentDecoration.getStrokeWidth();\n    }\n\n    public int getSelectBackgroundColor() {\n        return segmentDecoration.getSelectBackgroundColor();\n    }\n\n    public int getUnSelectedBackgroundColor() {\n        return segmentDecoration.getUnSelectedBackgroundColor();\n    }\n\n    public int getFocusedBackgroundColor(){\n        return segmentDecoration.getFocusedBackgroundColor();\n    }\n\n    public int getSelectionAnimationDuration(){\n        return segmentDecoration.getSelectionAnimationDuration();\n    }\n\n    public int getSelectedTextColor() {\n        return segmentDecoration.getSelectedTextColor();\n    }\n\n    public int getUnSelectedTextColor() {\n        return segmentDecoration.getUnSelectedTextColor();\n    }\n\n    public int getTextSize() {\n        return segmentDecoration.getTextSize();\n    }\n\n    public Typeface getTypeFace(){\n        return segmentDecoration.getTypeface();\n    }\n\n    public int getTextHorizontalPadding() {\n        return segmentDecoration.getTextHorizontalPadding();\n    }\n\n    public int getTextVerticalPadding() {\n        return segmentDecoration.getTextVerticalPadding();\n    }\n\n    public int getSegmentVerticalMargin() {\n        return segmentDecoration.getSegmentVerticalMargin();\n    }\n\n    public int getSegmentHorizontalMargin() {\n        return segmentDecoration.getSegmentHorizontalMargin();\n    }\n\n    public int getTopLeftRadius() {\n        return segmentDecoration.getTopLeftRadius();\n    }\n\n    public int getTopRightRadius() {\n        return segmentDecoration.getTopRightRadius();\n    }\n\n    public int getBottomRightRadius() {\n        return segmentDecoration.getBottomRightRadius();\n    }\n\n    public int getBottomLeftRadius() {\n        return segmentDecoration.getBottomLeftRadius();\n    }\n\n    public boolean isRadiusForEverySegment() {\n        return segmentDecoration.isRadiusForEverySegment();\n    }\n\n    public int getCurrentSize() {\n        return currentSize;\n    }\n\n    public int getColumnCount() {\n        return columnCount;\n    }\n}\n"
  },
  {
    "path": "segmentedcontrolmodule/src/main/java/segmented_control/widget/custom/android/com/segmentedcontrol/item_row_column/SegmentDecoration.java",
    "content": "package segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column;\n\nimport android.content.Context;\nimport android.graphics.Color;\nimport android.graphics.Typeface;\nimport android.support.annotation.ColorInt;\nimport android.support.v4.content.ContextCompat;\n\n/**\n * Created by Robert Apikyan on 9/11/2017.\n */\n\npublic class SegmentDecoration {\n    public static final int DEFAULT_FOCUSED_BACKGROUND_ALPHA = 36;\n    public static final int DEFAULT_SELECTION_ANIMATION_DURATION = 196;\n\n    // segment decoration\n    // stroke\n    @ColorInt\n    public int selectedStrokeColor;\n    @ColorInt\n    public int unSelectedStrokeColor;\n    public int strokeWidth;\n    // background\n    @ColorInt\n    public int selectBackgroundColor;\n    @ColorInt\n    public int unSelectedBackgroundColor;\n    // focused segment background\n    public int focusedBackgroundColor;\n    // selection Animation Duration\n    public int selectionAnimationDuration;\n    // text\n    @ColorInt\n    public int selectedTextColor;\n    @ColorInt\n    public int unSelectedTextColor;\n    public int textSize;\n    // text padding\n    public int textHorizontalPadding;\n    public int textVerticalPadding;\n\n    // segment margins\n    public int segmentVerticalMargin;\n    public int segmentHorizontalMargin;\n\n    // segment font type\n    public Typeface typeface;\n\n    // radius\n    public int topLeftRadius;\n    public int topRightRadius;\n    public int bottomRightRadius;\n    public int bottomLeftRadius;\n    public boolean radiusForEverySegment = false; // def. value\n\n    public static SegmentDecoration createDefault(Context context, int accentColor) {\n        SegmentDecoration sd = new SegmentDecoration();\n        sd.selectedStrokeColor = accentColor;\n        sd.unSelectedStrokeColor = accentColor;\n        sd.selectBackgroundColor = accentColor;\n        sd.unSelectedBackgroundColor = ContextCompat.getColor(context, android.R.color.transparent);\n        sd.focusedBackgroundColor = Color.argb(DEFAULT_FOCUSED_BACKGROUND_ALPHA,\n                Color.red(accentColor),\n                Color.green(accentColor),\n                Color.blue(accentColor));\n        sd.selectionAnimationDuration = DEFAULT_SELECTION_ANIMATION_DURATION;\n        sd.selectedTextColor = ContextCompat.getColor(context, android.R.color.white);\n        sd.unSelectedTextColor = accentColor;\n        sd.strokeWidth = 1;\n        sd.typeface = null;\n        return sd;\n    }\n\n    public int getSelectedStrokeColor() {\n        return selectedStrokeColor;\n    }\n\n    public int getUnSelectedStrokeColor() {\n        return unSelectedStrokeColor;\n    }\n\n    public int getStrokeWidth() {\n        return strokeWidth;\n    }\n\n    public int getSelectBackgroundColor() {\n        return selectBackgroundColor;\n    }\n\n    public int getUnSelectedBackgroundColor() {\n        return unSelectedBackgroundColor;\n    }\n\n    public int getFocusedBackgroundColor() {\n        return focusedBackgroundColor;\n    }\n\n    public int getSelectionAnimationDuration() {\n        return selectionAnimationDuration;\n    }\n\n    public int getSelectedTextColor() {\n        return selectedTextColor;\n    }\n\n    public int getUnSelectedTextColor() {\n        return unSelectedTextColor;\n    }\n\n    public int getTextSize() {\n        return textSize;\n    }\n\n    public int getTextHorizontalPadding() {\n        return textHorizontalPadding;\n    }\n\n    public int getTextVerticalPadding() {\n        return textVerticalPadding;\n    }\n\n    public int getSegmentVerticalMargin() {\n        return segmentVerticalMargin;\n    }\n\n    public int getSegmentHorizontalMargin() {\n        return segmentHorizontalMargin;\n    }\n\n    public int getTopLeftRadius() {\n        return topLeftRadius;\n    }\n\n    public int getTopRightRadius() {\n        return topRightRadius;\n    }\n\n    public int getBottomRightRadius() {\n        return bottomRightRadius;\n    }\n\n    public int getBottomLeftRadius() {\n        return bottomLeftRadius;\n    }\n\n    public boolean isRadiusForEverySegment() {\n        return radiusForEverySegment;\n    }\n\n    public Typeface getTypeface() {\n        return typeface;\n    }\n\n    ;\n}\n"
  },
  {
    "path": "segmentedcontrolmodule/src/main/java/segmented_control/widget/custom/android/com/segmentedcontrol/item_row_column/SegmentViewHolder.java",
    "content": "package segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column;\n\nimport android.graphics.Typeface;\nimport android.support.annotation.NonNull;\nimport android.view.View;\n\nimport section_layout.widget.custom.android.com.sectionlayout.distributive_section_layout.DistributiveSectionLayout;\n\n/**\n * Created by Robert Apikyan on 9/7/2017.\n */\n\npublic abstract class SegmentViewHolder<D> extends DistributiveSectionLayout.ViewHolder<SegmentData<D>> {\n    private SegmentData<D> segmentData;\n\n    private final View.OnClickListener onSectionViewClickListener = new View.OnClickListener() {\n        @Override\n        public void onClick(View v) {\n            if (segmentData != null)\n                segmentData.getOnSegmentClickListener().onSegmentClick(SegmentViewHolder.this);\n        }\n    };\n\n    public SegmentViewHolder(@NonNull View sectionView) {\n        super(sectionView);\n    }\n\n    @Override\n    protected final void onBind(SegmentData<D> segmentData) {\n        this.segmentData = segmentData;\n        getSectionView().setOnClickListener(onSectionViewClickListener);\n        onSegmentBind(segmentData.getSegmentData());\n    }\n\n    public final void setSelected(boolean isSelected) {\n        if (segmentData.isSelected() && isSelected) {\n            segmentData.isSelected = true;\n            onSegmentSelected(true, true);\n        } else if (isSelected) {\n            segmentData.isSelected = true;\n            onSegmentSelected(true, false);\n        } else {\n            segmentData.isSelected = false;\n            onSegmentSelected(false, false);\n        }\n    }\n\n    /**\n     * Override this method in order to define, performed action, selected, unselected, reselected\n     *\n     * @param isSelected,   represent selected state\n     * @param isReselected, represent reselected state\n     */\n    public void onSegmentSelected(boolean isSelected, boolean isReselected) {\n\n    }\n\n    public int getAbsolutePosition() {\n        return segmentData.absolutePosition;\n    }\n\n    public boolean isSelected() {\n        return segmentData.isSelected;\n    }\n\n    public int getRow() {\n        return segmentData.getRow();\n    }\n\n    public int getColumn() {\n        return segmentData.getColumn();\n    }\n\n    public D getSegmentData() {\n        return segmentData.getSegmentData();\n    }\n\n    public int getSelectedStrokeColor() {\n        return segmentData.getSelectedStrokeColor();\n    }\n\n    public int getUnSelectedStrokeColor() {\n        return segmentData.getUnSelectedStrokeColor();\n    }\n\n    public int getStrokeWidth() {\n        return segmentData.getStrokeWidth();\n    }\n\n    public int getSelectBackgroundColor() {\n        return segmentData.getSelectBackgroundColor();\n    }\n\n    public int getUnSelectedBackgroundColor() {\n        return segmentData.getUnSelectedBackgroundColor();\n    }\n\n    public int getFocusedBackgroundColor(){\n        return segmentData.getFocusedBackgroundColor();\n    }\n\n    public int getSelectionAnimationDuration(){\n        return segmentData.getSelectionAnimationDuration();\n    }\n\n    public int getSelectedTextColor() {\n        return segmentData.getSelectedTextColor();\n    }\n\n    public int getUnSelectedTextColor() {\n        return segmentData.getUnSelectedTextColor();\n    }\n\n    public int getTextSize() {\n        return segmentData.getTextSize();\n    }\n\n    public Typeface getTypeFace(){return segmentData.getTypeFace();}\n\n    public int getCurrentSize() {\n        return segmentData.getCurrentSize();\n    }\n\n    public int getColumnCount() {\n        return segmentData.getColumnCount();\n    }\n\n    public int getTextHorizontalPadding() {\n        return segmentData.getTextHorizontalPadding();\n    }\n\n    public int getTextVerticalPadding() {\n        return segmentData.getTextVerticalPadding();\n    }\n\n    public int getSegmentVerticalMargin() {\n        return segmentData.getSegmentVerticalMargin();\n    }\n\n    public int getSegmentHorizontalMargin() {\n        return segmentData.getSegmentHorizontalMargin();\n    }\n\n    public int getTopLeftRadius() {\n        return segmentData.getTopLeftRadius();\n    }\n\n    public int getTopRightRadius() {\n        return segmentData.getTopRightRadius();\n    }\n\n    public int getBottomRightRadius() {\n        return segmentData.getBottomRightRadius();\n    }\n\n    public int getBottomLeftRadius() {\n        return segmentData.getBottomLeftRadius();\n    }\n\n    public boolean isRadiusForEverySegment() {\n        return segmentData.isRadiusForEverySegment();\n    }\n\n    protected abstract void onSegmentBind(D segmentData);\n}\n"
  },
  {
    "path": "segmentedcontrolmodule/src/main/java/segmented_control/widget/custom/android/com/segmentedcontrol/listeners/OnSegmentClickListener.java",
    "content": "package segmented_control.widget.custom.android.com.segmentedcontrol.listeners;\n\nimport segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column.SegmentViewHolder;\n\n/**\n * Created by Robert Apikyan on 9/7/2017.\n */\n\npublic interface OnSegmentClickListener<D> {\n    /**\n     * @param segmentViewHolder, the clicked segment view holder instance\n     */\n    void onSegmentClick(SegmentViewHolder<D> segmentViewHolder);\n}\n"
  },
  {
    "path": "segmentedcontrolmodule/src/main/java/segmented_control/widget/custom/android/com/segmentedcontrol/listeners/OnSegmentSelectRequestListener.java",
    "content": "package segmented_control.widget.custom.android.com.segmentedcontrol.listeners;\n\nimport segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column.SegmentViewHolder;\n\n/**\n * Created by Robert Apikyan on 9/12/2017.\n */\n\npublic interface OnSegmentSelectRequestListener<D> {\n    /**\n     * The event will be triggered before perform segment selection,and after segment click event\n     *\n     * @param segmentViewHolder, clicked segment view holder\n     * @return false segment selection will be ignored, true segment selection will be performed\n     */\n    boolean onSegmentSelectRequest(SegmentViewHolder<D> segmentViewHolder);\n}\n"
  },
  {
    "path": "segmentedcontrolmodule/src/main/java/segmented_control/widget/custom/android/com/segmentedcontrol/listeners/OnSegmentSelectedListener.java",
    "content": "package segmented_control.widget.custom.android.com.segmentedcontrol.listeners;\n\nimport segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column.SegmentViewHolder;\n\n/**\n * Created by Robert Apikyan on 9/7/2017.\n */\n\npublic interface OnSegmentSelectedListener<D> {\n    /**\n     * The Event will be triggered: if the segment is selected, reselected and unSelected\n     * 1. Segment is selected for first time:  isSelected = true ,isReselected = false\n     * 2. Segment is reselected: isSelected = true ,isReselected = true\n     * 3. Segment is unSelected: isSelected = false ,isReselected = false\n     *\n     * @param segmentViewHolder event related segmentViewHolder\n     * @param isSelected,       true segment is selected\n     * @param isReselected,     true segment is reselected\n     */\n    void onSegmentSelected(SegmentViewHolder<D> segmentViewHolder, boolean isSelected, boolean isReselected);\n}\n"
  },
  {
    "path": "segmentedcontrolmodule/src/main/java/segmented_control/widget/custom/android/com/segmentedcontrol/utils/ArgbEvaluator.java",
    "content": "package segmented_control.widget.custom.android.com.segmentedcontrol.utils;\n\nimport android.animation.TypeEvaluator;\nimport android.animation.ValueAnimator;\n\npublic class ArgbEvaluator implements TypeEvaluator {\n    private static final android.animation.ArgbEvaluator sInstance = new android.animation.ArgbEvaluator();\n\n    /**\n     * Returns an instance of <code>ArgbEvaluator</code> that may be used in\n     * {@link ValueAnimator#setEvaluator(TypeEvaluator)}. The same instance may\n     * be used in multiple <code>Animator</code>s because it holds no state.\n     * @return An instance of <code>ArgbEvalutor</code>.\n     *\n     * @hide\n     */\n    public static android.animation.ArgbEvaluator getInstance() {\n        return sInstance;\n    }\n\n    /**\n     * This function returns the calculated in-between value for a color\n     * given integers that represent the start and end values in the four\n     * bytes of the 32-bit int. Each channel is separately linearly interpolated\n     * and the resulting calculated values are recombined into the return value.\n     *\n     * @param fraction The fraction from the starting to the ending values\n     * @param startValue A 32-bit int value representing colors in the\n     * separate bytes of the parameter\n     * @param endValue A 32-bit int value representing colors in the\n     * separate bytes of the parameter\n     * @return A value that is calculated to be the linearly interpolated\n     * result, derived by separating the start and end values into separate\n     * color channels and interpolating each one separately, recombining the\n     * resulting values in the same way.\n     */\n    public Object evaluate(float fraction, Object startValue, Object endValue) {\n        int startInt = (Integer) startValue;\n        float startA = ((startInt >> 24) & 0xff) / 255.0f;\n        float startR = ((startInt >> 16) & 0xff) / 255.0f;\n        float startG = ((startInt >>  8) & 0xff) / 255.0f;\n        float startB = ( startInt        & 0xff) / 255.0f;\n\n        int endInt = (Integer) endValue;\n        float endA = ((endInt >> 24) & 0xff) / 255.0f;\n        float endR = ((endInt >> 16) & 0xff) / 255.0f;\n        float endG = ((endInt >>  8) & 0xff) / 255.0f;\n        float endB = ( endInt        & 0xff) / 255.0f;\n\n        // convert from sRGB to linear\n        startR = (float) Math.pow(startR, 2.2);\n        startG = (float) Math.pow(startG, 2.2);\n        startB = (float) Math.pow(startB, 2.2);\n\n        endR = (float) Math.pow(endR, 2.2);\n        endG = (float) Math.pow(endG, 2.2);\n        endB = (float) Math.pow(endB, 2.2);\n\n        // compute the interpolated color in linear space\n        float a = startA + fraction * (endA - startA);\n        float r = startR + fraction * (endR - startR);\n        float g = startG + fraction * (endG - startG);\n        float b = startB + fraction * (endB - startB);\n\n        // convert back to sRGB in the [0..255] range\n        a = a * 255.0f;\n        r = (float) Math.pow(r, 1.0 / 2.2) * 255.0f;\n        g = (float) Math.pow(g, 1.0 / 2.2) * 255.0f;\n        b = (float) Math.pow(b, 1.0 / 2.2) * 255.0f;\n\n        return Math.round(a) << 24 | Math.round(r) << 16 | Math.round(g) << 8 | Math.round(b);\n    }\n}"
  },
  {
    "path": "segmentedcontrolmodule/src/main/java/segmented_control/widget/custom/android/com/segmentedcontrol/utils/Utils.java",
    "content": "package segmented_control.widget.custom.android.com.segmentedcontrol.utils;\n\nimport android.animation.ObjectAnimator;\nimport android.animation.ValueAnimator;\nimport android.graphics.drawable.Drawable;\nimport android.graphics.drawable.GradientDrawable;\nimport android.support.annotation.IntRange;\nimport android.view.View;\n\nimport segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column.SegmentBackgroundType;\nimport segmented_control.widget.custom.android.com.segmentedcontrol.item_row_column.SegmentViewHolder;\n\n/**\n * Created by Robert Apikyan on 9/8/2017.\n */\n\npublic class Utils {\n    public static <T> T lazy(T nullable, T nonNull) {\n        if (nullable == null) {\n            nullable = nonNull;\n        }\n        return nullable;\n    }\n\n    /**\n     * Utility method, use to define segment background type\n     *\n     * @param absolutePosition, Segment absolute position from {@link SegmentViewHolder#getAbsolutePosition()}\n     * @param columnCount,      from {@link SegmentViewHolder#getColumnCount()}\n     * @param size,             from {@link SegmentViewHolder#getCurrentSize()}\n     * @return {@link SegmentBackgroundType}\n     */\n    @SegmentBackgroundType\n    public static int defineSegmentBackground(@IntRange(from = 0) int absolutePosition, @IntRange(from = 1) int columnCount, @IntRange(from = 1) int size) {\n\n        // if only one item\n        if (size == 1) {\n            return SegmentBackgroundType.SINGLE_BG;\n        }\n\n        // if one column\n        if (columnCount == 1) {\n            // for first\n            if (absolutePosition == 0) {\n                return SegmentBackgroundType.TOP_SINGLE_BG;\n            }\n\n            // for last\n            if (absolutePosition == size - 1) {\n                return SegmentBackgroundType.BOTTOM_SINGLE_BG;\n            }\n        }\n\n        // if not one column, but one row\n        if (size <= columnCount) {\n            if (absolutePosition == 0) {\n                return SegmentBackgroundType.TOP_LEFT_SINGLE_BG;\n            }\n\n            if (absolutePosition == size - 1) {\n                return SegmentBackgroundType.TOP_RIGHT_SINGLE_BG;\n            }\n        }\n\n        // if not one column and multi row\n        if (absolutePosition == 0) {\n            return SegmentBackgroundType.TOP_LEFT_BG;\n        }\n\n        if (absolutePosition == columnCount - 1) {\n            return SegmentBackgroundType.TOP_RIGHT_BG;\n        }\n\n        int notCompletedRowItemsCount = size % columnCount;\n\n        int completeRowsItemsCount = size - notCompletedRowItemsCount;\n\n        if (notCompletedRowItemsCount == 1 && absolutePosition == completeRowsItemsCount) {\n            return SegmentBackgroundType.BOTTOM_SINGLE_BG;\n        }\n\n        if (notCompletedRowItemsCount == 0) {\n            if (absolutePosition == size - columnCount) {\n                return SegmentBackgroundType.BOTTOM_LEFT_BG;\n            }\n            if (absolutePosition == size - 1) {\n                return SegmentBackgroundType.BOTTOM_RIGHT_BG;\n            }\n        } else if (notCompletedRowItemsCount > 0) {\n            if (absolutePosition == size - notCompletedRowItemsCount) {\n                return SegmentBackgroundType.BOTTOM_LEFT_BG;\n            }\n            if (absolutePosition == size - 1) {\n                return SegmentBackgroundType.BOTTOM_RIGHT_BG;\n            }\n        }\n\n        return SegmentBackgroundType.MIDDLE_BG;\n    }\n\n    /**\n     * Use to define segment corner radius\n     *\n     * @param absolutePosition,  Segment absolute position from {@link SegmentViewHolder#getAbsolutePosition()}\n     * @param columnCount,       from {@link SegmentViewHolder#getColumnCount()}\n     * @param size,              from {@link SegmentViewHolder#getCurrentSize()}\n     * @param topLeftRadius,     from {@link SegmentViewHolder#getTopLeftRadius()}\n     * @param topRightRadius,    from {@link SegmentViewHolder#getTopRightRadius()} ()}\n     * @param bottomRightRadius, from {@link SegmentViewHolder#getBottomRightRadius()}\n     * @param bottomLeftRadius,  from  {@link SegmentViewHolder#getBottomLeftRadius()}\n     * @return, float[] corners radius,\n     */\n    public static float[] defineRadiusForPosition(@IntRange(from = 0) int absolutePosition, @IntRange(from = 1) int columnCount, @IntRange(from = 1) int size,\n                                                  int topLeftRadius, int topRightRadius, int bottomRightRadius, int bottomLeftRadius) {\n        @SegmentBackgroundType\n        int bgType = defineSegmentBackground(absolutePosition, columnCount, size);\n\n        switch (bgType) {\n\n            case SegmentBackgroundType.BOTTOM_LEFT_BG:\n                return createRadius(0, 0, 0, bottomLeftRadius);\n\n            case SegmentBackgroundType.BOTTOM_RIGHT_BG:\n                return createRadius(0, 0, bottomRightRadius, 0);\n\n            case SegmentBackgroundType.BOTTOM_SINGLE_BG:\n                return createRadius(0, 0, bottomRightRadius, bottomLeftRadius);\n\n            case SegmentBackgroundType.MIDDLE_BG:\n                return createRadius(0, 0, 0, 0);\n\n            case SegmentBackgroundType.SINGLE_BG:\n                return createRadius(topLeftRadius, topRightRadius, bottomRightRadius, bottomLeftRadius);\n\n            case SegmentBackgroundType.TOP_LEFT_BG:\n                return createRadius(topLeftRadius, 0, 0, 0);\n\n            case SegmentBackgroundType.TOP_LEFT_SINGLE_BG:\n                return createRadius(topLeftRadius, 0, 0, bottomLeftRadius);\n\n            case SegmentBackgroundType.TOP_RIGHT_BG:\n                return createRadius(0, topRightRadius, 0, 0);\n\n            case SegmentBackgroundType.TOP_RIGHT_SINGLE_BG:\n                return createRadius(0, topRightRadius, bottomRightRadius, 0);\n\n            case SegmentBackgroundType.TOP_SINGLE_BG:\n                return createRadius(topLeftRadius, topRightRadius, 0, 0);\n\n            default:\n                return createRadius(0, 0, 0, 0);\n        }\n    }\n\n    public static float[] createRadius(float topLeft, float topRight, float bottomRight, float bottomLeft) {\n        return new float[]{topLeft, topLeft, topRight, topRight, bottomRight, bottomRight, bottomLeft, bottomLeft};\n    }\n\n    /**\n     * @param strokeWidth, stroke width\n     * @param strokeColor, stroke color\n     * @param argb,        background color\n     * @param radii,       use {@link #defineRadiusForPosition(int, int, int, int, int, int, int)} method to define radii\n     * @return background drawable\n     */\n    public static Drawable getBackground(int strokeWidth, int strokeColor, int argb, float[] radii) {\n        GradientDrawable drawable = new GradientDrawable();\n        drawable.setShape(GradientDrawable.RECTANGLE);\n        drawable.setStroke(strokeWidth, strokeColor);\n        drawable.setCornerRadii(radii);\n        drawable.setColor(argb);\n        return drawable;\n    }\n\n    public static ValueAnimator createBackgroundAnimation(int argbStart, int argbEnd) {\n        return ValueAnimator.ofObject(ArgbEvaluator.getInstance(), argbStart, argbEnd);\n    }\n\n    public static boolean isInBounds(float touchX, float touchY, float viewX, float viewY, float viewW, float viewH) {\n        return touchX >= viewX && touchX <= viewX + viewW && // in x bounds\n                touchY >= viewY && touchY <= viewY + viewH;\n    }\n}\n"
  },
  {
    "path": "segmentedcontrolmodule/src/main/res/layout/item_segment_impl.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<FrameLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:orientation=\"vertical\">\n\n<TextView\nandroid:id=\"@+id/item_segment_tv\"\nandroid:layout_width=\"match_parent\"\nandroid:layout_height=\"match_parent\"\nandroid:gravity=\"center\" />\n\n    </FrameLayout>"
  },
  {
    "path": "segmentedcontrolmodule/src/main/res/values/attr.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n    <declare-styleable name=\"SegmentedControl\">\n        <attr name=\"reselectionEnabled\" format=\"boolean\"/>\n        <attr name=\"distributeEvenly\" format=\"boolean\" />\n        <attr name=\"supportedSelectionsCount\" format=\"integer\"/>\n        <attr name=\"columnCount\" format=\"integer\" />\n        <attr name=\"segments\" format=\"reference\" />\n        <attr name=\"selectedStrokeColor\" format=\"color\" />\n        <attr name=\"unSelectedStrokeColor\" format=\"color\" />\n        <attr name=\"strokeWidth\" format=\"dimension\" />\n        <attr name=\"selectedBackgroundColor\" format=\"color\" />\n        <attr name=\"unSelectedBackgroundColor\" format=\"color\" />\n        <attr name=\"selectionAnimationDuration\" format=\"integer\"/>\n        <attr name=\"focusedBackgroundColor\" format=\"color\"/>\n        <attr name=\"selectedTextColor\" format=\"color\"/>\n        <attr name=\"unSelectedTextColor\" format=\"color\"/>\n        <attr name=\"textSize\" format=\"dimension\"/>\n        <attr name=\"textHorizontalPadding\" format=\"dimension\"/>\n        <attr name=\"textVerticalPadding\" format=\"dimension\"/>\n        <attr name=\"segmentVerticalMargin\" format=\"dimension\"/>\n        <attr name=\"segmentHorizontalMargin\" format=\"dimension\"/>\n        <attr name=\"radius\" format=\"dimension\"/>\n        <attr name=\"topLeftRadius\" format=\"dimension\"/>\n        <attr name=\"topRightRadius\" format=\"dimension\"/>\n        <attr name=\"bottomRightRadius\" format=\"dimension\"/>\n        <attr name=\"bottomLeftRadius\" format=\"dimension\"/>\n        <attr name=\"radiusForEverySegment\" format=\"boolean\"/>\n        <attr name=\"fontAssetPath\" format=\"string\"/>\n    </declare-styleable>\n</resources>"
  },
  {
    "path": "segmentedcontrolmodule/src/main/res/values/colors.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n    <color name=\"colorPrimary\">#3F51B5</color>\n    <color name=\"colorPrimaryDark\">#303F9F</color>\n    <color name=\"colorAccent\">#FF4081</color>\n</resources>"
  },
  {
    "path": "segmentedcontrolmodule/src/main/res/values/strings.xml",
    "content": "<resources>\n    <string name=\"app_name\">SegmentedControl</string>\n</resources>\n"
  },
  {
    "path": "settings.gradle",
    "content": "include ':app', ':segmentedcontrolmodule'\n"
  }
]