├── .gitignore ├── LICENSE.txt ├── README.md ├── app ├── .gitignore ├── build.gradle ├── gradle.properties ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── expandablepanel │ │ └── jorgecastilloprz │ │ └── com │ │ └── expandablepanel │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── assets │ ├── Roboto-Light.ttf │ └── Roboto-Thin.ttf │ ├── java │ └── expandablepanel │ │ └── jorgecastilloprz │ │ └── com │ │ └── expandablepanel │ │ └── ui │ │ ├── activities │ │ └── MainActivity.java │ │ ├── components │ │ └── CircledImageView.java │ │ ├── fragments │ │ ├── BasicBehaviorFragment.java │ │ └── InverseBehaviorFragment.java │ │ └── utils │ │ └── FragmentTypes.java │ └── res │ ├── drawable-hdpi │ ├── daybackground.png │ ├── ic_drawer.png │ ├── ic_launcher.png │ └── nightbackground.png │ ├── drawable-mdpi │ ├── daybackground.png │ ├── ic_drawer.png │ ├── ic_launcher.png │ └── nightbackground.png │ ├── drawable-xhdpi │ ├── avatar.png │ ├── ic_drawer.png │ └── ic_launcher.png │ ├── drawable-xxhdpi │ ├── ic_drawer.png │ └── ic_launcher.png │ ├── drawable-xxxhdpi │ ├── daybackground.png │ └── nightbackground.png │ ├── layout │ ├── activity_main.xml │ ├── fragment_basic_behaviour.xml │ ├── fragment_basic_expanded_behaviour.xml │ ├── fragment_inverse_behaviour.xml │ ├── fragment_inverse_expanded_behaviour.xml │ └── navigation_drawer_item.xml │ ├── menu │ └── main.xml │ ├── raw │ ├── en_generic_rgb_wo_60.png │ ├── sample1.gif │ ├── sample2.gif │ ├── sample3.gif │ └── sample4.gif │ └── values │ ├── arrays.xml │ ├── color.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── library ├── .gitignore ├── build.gradle ├── gradle.properties ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── jorgecastilloprz │ │ └── expandablepanel │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── jorgecastilloprz │ │ └── expandablepanel │ │ ├── ExpandablePanelView.java │ │ ├── anim │ │ └── HeightAnimation.java │ │ ├── controllers │ │ ├── AnimationController.java │ │ └── strategy │ │ │ ├── AbstractAnimationStrategy.java │ │ │ ├── BasicAnimationStrategy.java │ │ │ └── InverseAnimationStrategy.java │ │ └── listeners │ │ └── ExpandableListener.java │ └── res │ ├── drawable-hdpi │ └── ic_launcher.png │ ├── drawable-mdpi │ └── ic_launcher.png │ ├── drawable-xhdpi │ └── ic_launcher.png │ ├── drawable-xxhdpi │ └── ic_launcher.png │ └── values │ ├── attrs.xml │ └── strings.xml ├── maven_push.gradle └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | *~ 5 | 6 | # Files for the Dalvik VM 7 | *.dex 8 | 9 | # Java class files 10 | *.class 11 | 12 | # Generated files 13 | bin/ 14 | gen/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Intellij files 24 | .idea/ 25 | *.iml 26 | 27 | # Proguard folder generated by Eclipse 28 | proguard/ -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Expandable Panel Android Library 2 | ================================ 3 | 4 | ![Demo Screenshot 1](https://raw.githubusercontent.com/JorgeCastilloPrz/ExpandablePanel/master/app/src/main/res/raw/sample1.gif) 5 | ![Demo Screenshot 2](https://raw.githubusercontent.com/JorgeCastilloPrz/ExpandablePanel/master/app/src/main/res/raw/sample2.gif) 6 | ![Demo Screenshot 3](https://raw.githubusercontent.com/JorgeCastilloPrz/ExpandablePanel/master/app/src/main/res/raw/sample3.gif) 7 | ![Demo Screenshot 4](https://raw.githubusercontent.com/JorgeCastilloPrz/ExpandablePanel/master/app/src/main/res/raw/sample4.gif) 8 | 9 | Check ExpandablePanel Demo application on GooglePlay:
10 | 11 | Get it on Google Play 12 | 13 | 14 | Details 15 | ------- 16 | 17 | This Android library implements the expand by sliding logic for a top or a bottom view in a two children view composition. That's the default behaviour, but it allows you to set a different View as the expandable one, making this component support multiple views inside it. 18 | It supports ```Android SDK 2.1 (Eclair)``` as minimum. 19 | 20 | ExpandablePanel library brings a custom view class called ```ExpandablePanelView``` to the final user. It implements the needed logic for integrating the expandable logic into your own Android application. 21 | 22 | Custom Attributes 23 | ------------- 24 | 25 | ExpandablePanel lib allows you to customize the following properties. Feel free to combine them to create cool user interfaces: 26 | 27 | * ```expandablepanel:completionPercent```: % of the parent's height where you want the autocomplete animation to begin working. 28 | * ```expandablepanel:completeExpandAnimationSpeed```: Speed for the autocomplete animation. 29 | * ```expandablepanel:completeShrinkAnimationSpeed```: Speed for the autoshrink animation. 30 | * ```expandablepanel:beginExpanded```: Use it if you need the topView to begin expanded. If that's your case, the view will play a bounce animation at start to inform the user about the hidden bottom view. 31 | * ```expandablepanel:bounceCount```: Use it to set the number of times topView is going to play bounce animation when it begins expanded. 32 | * ```expandablepanel:invertBehavior```: Use it to invert the panel's behaviour and make bottomView become the expandable one. You can combine it with any other custom attributes. Bounce animation will get inverted too when using this attr. 33 | * ```expandablepanel:animableViewId```: Use it to assign an animable view using the view identifier if your ```ExpandablePanelView``` contains more than 2 child. This attribute is not mandatory, if you don't use it, first or second child (based on the ```expandablepanel:invertBehavior``` attribute) is going to be used as the animable view. 34 | * ```expandablepanel:autoAnimateOnClick```: Use this one to enable automatic expanding or shrinking when user clicks on animable view. 35 | 36 | Usage 37 | ----- 38 | 39 | In order to make it work, you will need to use ```ExpandablePanelView``` class into your Android XML Layout. 40 | 41 | * 1. Add ```ExpandablePanelView``` to the layout. 42 | * 2. Add two children views to the ExpandablePanelView XML element. 43 | * 3. ```ExpandablePanelView``` extends ```RelativeLayout```, so you will need to give an android id to the top view and setup the ```android:below``` attribute in the bottom one. 44 | * 4. Set the ```xmlns:draggable_view="http://schemas.android.com/apk/res-auto"``` if you are going to use any of the cusom attributes. 45 | 46 | 47 | Use ```ExpandableListener``` if you want your class to be able to get expandable callbacks. Following methods are offered to the user: 48 | 49 | * ```onExpandingStarted```: Dispatched when the user starts expanding the view. 50 | * ```onExpandingFinished```: Dispatched when autocomplete expanding animation is finished. 51 | * ```onShrinkStarted```: Dispatched when the user starts shrinking the view. 52 | * ```onShrinkFinished```: Dispatched when autocomplete shrinking animation is finished. 53 | * ```onExpandingTouchEvent```: Dispatched meanwhile the user is dragging to expand or shrink the view. This one is very useful if you want to map touch coordinates to your class and be able to use them for creating cool combined animations. 54 | 55 | Basic Usage 56 | ----------- 57 | 58 | ```xml 59 | 65 | 66 | 73 | 74 | 80 | 81 | 86 | 87 | 88 | 89 | 90 | ``` 91 | 92 | Begin Expanded Usage: 93 | --------------------- 94 | ```xml 95 | 105 | 106 | 112 | 113 | 118 | 119 | 120 | ``` 121 | 122 | Invert Behaviour Usage: 123 | ----------------------- 124 | 125 | 126 | * You will need to remove ```android:layout_below``` from bottomView and add ```android:layout_above``` to the top one, in order to make Android capable of setting ```fixed bottomView height``` before topView ```match_parent``` height. 127 | * You must set ```android:layout_alignParentBottom="true"``` in bottom view too. 128 | 129 | ```xml 130 | 136 | 137 | 146 | 147 | 152 | 153 | 158 | 159 | 165 | 166 | 171 | 172 | 173 | 174 | 180 | 181 | 182 | 183 | 184 | 191 | 192 | 193 | 194 | 195 | ``` 196 | 197 | Import ExpandablePanel dependency 198 | --------------------------------- 199 | Add the next code to your build.gradle project dependencies: 200 | ```groovy 201 | dependencies { 202 | compile 'com.github.jorgecastilloprz:expandablepanel:1.0.4@aar' 203 | } 204 | ``` 205 | Set the mavenCentral repo into the external build.gradle: 206 | ```groovy 207 | buildscript { 208 | repositories { 209 | mavenCentral() 210 | } 211 | dependencies { 212 | classpath 'com.android.tools.build:gradle:0.12.+' 213 | } 214 | } 215 | 216 | allprojects { 217 | repositories { 218 | mavenCentral() 219 | } 220 | } 221 | ``` 222 | If you are using Maven, use the following code: 223 | ```xml 224 | 225 | com.github.jorgecastilloprz 226 | expandablepanel 227 | 1.0.4 228 | aar 229 | 230 | ``` 231 | 232 | Developer 233 | --------- 234 | * Jorge Castillo Pérez 235 | * Twitter acc - @JorgeCastilloPr (https://twitter.com/jorgecastillopr) 236 | 237 | License 238 | ------- 239 | 240 | Copyright 2014 Jorge Castillo Pérez 241 | 242 | Licensed under the Apache License, Version 2.0 (the "License"); 243 | you may not use this file except in compliance with the License. 244 | You may obtain a copy of the License at 245 | 246 | http://www.apache.org/licenses/LICENSE-2.0 247 | 248 | Unless required by applicable law or agreed to in writing, software 249 | distributed under the License is distributed on an "AS IS" BASIS, 250 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 251 | See the License for the specific language governing permissions and 252 | limitations under the License. 253 | 254 | [1]: http://188.226.233.205/ExpandablePanel/sample1.gif 255 | [2]: http://188.226.233.205/ExpandablePanel/sample2.gif 256 | [3]: http://188.226.233.205/ExpandablePanel/sample3.gif 257 | [4]: http://188.226.233.205/ExpandablePanel/sample4.gif 258 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | *~ 5 | 6 | # Files for the Dalvik VM 7 | *.dex 8 | 9 | # Java class files 10 | *.class 11 | 12 | # Generated files 13 | bin/ 14 | gen/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Intellij files 24 | .idea/ 25 | *.iml 26 | 27 | # Proguard folder generated by Eclipse 28 | proguard/ -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion Integer.parseInt(project.ANDROID_COMPILE_SDK_VERSION) 5 | buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION 6 | 7 | defaultConfig { 8 | applicationId "expandablepanel.jorgecastilloprz.com.expandablepanel" 9 | minSdkVersion Integer.parseInt(ANDROID_SAMPLE_MIN_SDK) 10 | targetSdkVersion Integer.parseInt(project.ANDROID_TARGET_SDK_VERSION) 11 | versionCode Integer.parseInt(project.VERSION_CODE) 12 | versionName project.VERSION_NAME 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | compile 'com.android.support:appcompat-v7:19.+' 25 | compile project(":library") 26 | compile files ('libs/ nineoldandroids-2.4.0.jar') 27 | } 28 | 29 | apply from: '../maven_push.gradle' 30 | -------------------------------------------------------------------------------- /app/gradle.properties: -------------------------------------------------------------------------------- 1 | POM_NAME=ExpandablePanel Sample 2 | POM_ARTIFACT_ID=expandablepanel-sample 3 | POM_PACKAGING=aar -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/jorge/android/android-studio/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/expandablepanel/jorgecastilloprz/com/expandablepanel/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package expandablepanel.jorgecastilloprz.com.expandablepanel; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/assets/Roboto-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JorgeCastilloPrz/ExpandablePanel/12d7aca47599a80c2dadc6d0f56ff4dcd790926a/app/src/main/assets/Roboto-Light.ttf -------------------------------------------------------------------------------- /app/src/main/assets/Roboto-Thin.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JorgeCastilloPrz/ExpandablePanel/12d7aca47599a80c2dadc6d0f56ff4dcd790926a/app/src/main/assets/Roboto-Thin.ttf -------------------------------------------------------------------------------- /app/src/main/java/expandablepanel/jorgecastilloprz/com/expandablepanel/ui/activities/MainActivity.java: -------------------------------------------------------------------------------- 1 | package expandablepanel.jorgecastilloprz.com.expandablepanel.ui.activities; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.ActionBarDrawerToggle; 5 | import android.support.v4.app.Fragment; 6 | import android.support.v4.app.FragmentActivity; 7 | import android.support.v4.app.FragmentManager; 8 | import android.support.v4.widget.DrawerLayout; 9 | import android.view.Menu; 10 | import android.view.MenuItem; 11 | import android.view.View; 12 | import android.widget.AdapterView; 13 | import android.widget.ArrayAdapter; 14 | import android.widget.ListView; 15 | 16 | import expandablepanel.jorgecastilloprz.com.expandablepanel.R; 17 | import expandablepanel.jorgecastilloprz.com.expandablepanel.ui.fragments.BasicBehaviorFragment; 18 | import expandablepanel.jorgecastilloprz.com.expandablepanel.ui.fragments.InverseBehaviorFragment; 19 | import expandablepanel.jorgecastilloprz.com.expandablepanel.ui.utils.FragmentTypes; 20 | 21 | 22 | public class MainActivity extends FragmentActivity implements ListView.OnItemClickListener { 23 | 24 | private String[] sectionTitles; 25 | private DrawerLayout mDrawerLayout; 26 | private ActionBarDrawerToggle mDrawerToggle; 27 | private ListView mDrawerList; 28 | 29 | @Override 30 | protected void onCreate(Bundle savedInstanceState) { 31 | super.onCreate(savedInstanceState); 32 | setContentView(R.layout.activity_main); 33 | 34 | mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout); 35 | mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close); 36 | 37 | mDrawerLayout.setDrawerListener(mDrawerToggle); 38 | getActionBar().setDisplayHomeAsUpEnabled(true); 39 | 40 | sectionTitles = getResources().getStringArray(R.array.fragment_names); 41 | mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout); 42 | mDrawerList = (ListView) findViewById(R.id.left_drawer); 43 | 44 | mDrawerList.setAdapter(new ArrayAdapter(this, android.R.layout.simple_selectable_list_item, sectionTitles)); 45 | mDrawerList.setOnItemClickListener(this); 46 | 47 | selectItem(0); 48 | } 49 | 50 | @Override 51 | public boolean onCreateOptionsMenu(Menu menu) { 52 | getMenuInflater().inflate(R.menu.main, menu); 53 | return true; 54 | } 55 | 56 | @Override 57 | public boolean onOptionsItemSelected(MenuItem item) { 58 | if (mDrawerToggle.onOptionsItemSelected(item)) { 59 | return true; 60 | } 61 | 62 | if (item.getItemId() == R.id.actionExit) 63 | finish(); 64 | 65 | return super.onOptionsItemSelected(item); 66 | } 67 | 68 | private void selectItem(int position) { 69 | 70 | Fragment fragment = null; 71 | Bundle args; 72 | switch (position) { 73 | case 0: 74 | fragment = new BasicBehaviorFragment(); 75 | args = new Bundle(); 76 | args.putInt("type", FragmentTypes.BASIC.ordinal()); 77 | fragment.setArguments(args); 78 | break; 79 | case 1: 80 | fragment = new BasicBehaviorFragment(); 81 | args = new Bundle(); 82 | args.putInt("type", FragmentTypes.INVERSE.ordinal()); 83 | fragment.setArguments(args); 84 | break; 85 | case 2: 86 | fragment = new InverseBehaviorFragment(); 87 | args = new Bundle(); 88 | args.putInt("type", FragmentTypes.BASIC.ordinal()); 89 | fragment.setArguments(args); 90 | break; 91 | case 3: 92 | fragment = new InverseBehaviorFragment(); 93 | args = new Bundle(); 94 | args.putInt("type", FragmentTypes.INVERSE.ordinal()); 95 | fragment.setArguments(args); 96 | break; 97 | } 98 | 99 | FragmentManager fragmentManager = getSupportFragmentManager(); 100 | fragmentManager.beginTransaction() 101 | .replace(R.id.content_frame, fragment) 102 | .commit(); 103 | 104 | mDrawerList.setItemChecked(position, true); 105 | setTitle(sectionTitles[position]); 106 | mDrawerLayout.closeDrawer(mDrawerList); 107 | } 108 | 109 | @Override 110 | public void setTitle(CharSequence title) { 111 | getActionBar().setTitle(title); 112 | } 113 | 114 | @Override 115 | public void onItemClick(AdapterView parent, View view, int position, long id) { 116 | selectItem(position); 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /app/src/main/java/expandablepanel/jorgecastilloprz/com/expandablepanel/ui/components/CircledImageView.java: -------------------------------------------------------------------------------- 1 | package expandablepanel.jorgecastilloprz.com.expandablepanel.ui.components; 2 | 3 | import android.content.Context; 4 | import android.graphics.Bitmap; 5 | import android.graphics.Canvas; 6 | import android.graphics.Color; 7 | import android.graphics.Paint; 8 | import android.graphics.PorterDuff; 9 | import android.graphics.PorterDuffXfermode; 10 | import android.graphics.Rect; 11 | import android.graphics.drawable.BitmapDrawable; 12 | import android.graphics.drawable.Drawable; 13 | import android.util.AttributeSet; 14 | import android.widget.ImageView; 15 | 16 | /** 17 | * Created by jorge on 5/15/14. 18 | */ 19 | public class CircledImageView extends ImageView { 20 | 21 | public CircledImageView(Context context) { 22 | super(context); 23 | } 24 | 25 | public CircledImageView(Context context, AttributeSet attrs) { 26 | super(context, attrs); 27 | } 28 | 29 | public CircledImageView(Context context, AttributeSet attrs, int defStyle) { 30 | super(context, attrs, defStyle); 31 | } 32 | 33 | @Override 34 | protected void onDraw(Canvas canvas) { 35 | 36 | Drawable drawable = getDrawable(); 37 | 38 | if (drawable == null) { 39 | return; 40 | } 41 | 42 | if (getWidth() == 0 || getHeight() == 0) { 43 | return; 44 | } 45 | Bitmap b = ((BitmapDrawable)drawable).getBitmap() ; 46 | Bitmap bitmap = b.copy(Bitmap.Config.ARGB_8888, true); 47 | 48 | int w = getWidth(), h = getHeight(); 49 | 50 | 51 | Bitmap roundBitmap = getCroppedBitmap(bitmap, w); 52 | canvas.drawBitmap(roundBitmap, 0,0, null); 53 | 54 | } 55 | 56 | private static Bitmap getCroppedBitmap(Bitmap bmp, int radius) { 57 | 58 | Bitmap sbmp; 59 | 60 | if(bmp.getWidth() != radius || bmp.getHeight() != radius) 61 | sbmp = Bitmap.createScaledBitmap(bmp, radius, radius, false); 62 | else 63 | sbmp = bmp; 64 | 65 | Bitmap output = Bitmap.createBitmap(sbmp.getWidth(), sbmp.getHeight(), Bitmap.Config.ARGB_8888); 66 | Canvas canvas = new Canvas(output); 67 | 68 | final int color = 0xffa19774; 69 | final Paint paint = new Paint(); 70 | final Rect rect = new Rect(0, 0, sbmp.getWidth(), sbmp.getHeight()); 71 | 72 | paint.setAntiAlias(true); 73 | paint.setFilterBitmap(true); 74 | // paint.setDither(true); 75 | canvas.drawARGB(0, 0, 0, 0); 76 | 77 | canvas.drawCircle(sbmp.getWidth() / 2+0.7f, sbmp.getHeight() / 2+0.7f, 78 | sbmp.getWidth() / 2+0.1f, paint); 79 | paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); 80 | canvas.drawBitmap(sbmp, rect, rect, paint); 81 | 82 | // draw internal border 83 | paint.setColor(Color.parseColor("#ffffff")); 84 | paint.setStyle(Paint.Style.STROKE); 85 | paint.setStrokeWidth((float) 30); 86 | canvas.drawCircle(sbmp.getWidth()/ 2 + 0.7f, sbmp.getHeight() / 2 + 0.7f, sbmp.getWidth() / 2+0.1f, paint); 87 | 88 | return output; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /app/src/main/java/expandablepanel/jorgecastilloprz/com/expandablepanel/ui/fragments/BasicBehaviorFragment.java: -------------------------------------------------------------------------------- 1 | package expandablepanel.jorgecastilloprz.com.expandablepanel.ui.fragments; 2 | 3 | import android.animation.ObjectAnimator; 4 | import android.animation.ValueAnimator; 5 | import android.graphics.Typeface; 6 | import android.os.Bundle; 7 | import android.support.v4.app.Fragment; 8 | import android.view.LayoutInflater; 9 | import android.view.MotionEvent; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | import android.view.animation.DecelerateInterpolator; 13 | import android.widget.TextView; 14 | 15 | import com.jorgecastilloprz.expandablepanel.ExpandablePanelView; 16 | import com.jorgecastilloprz.expandablepanel.listeners.ExpandableListener; 17 | 18 | import expandablepanel.jorgecastilloprz.com.expandablepanel.R; 19 | import expandablepanel.jorgecastilloprz.com.expandablepanel.ui.utils.FragmentTypes; 20 | 21 | /** 22 | * Created by jorge on 31/07/14. 23 | */ 24 | public class BasicBehaviorFragment extends Fragment implements ExpandableListener { 25 | 26 | private View rootView; 27 | 28 | private View avatar; 29 | private ExpandablePanelView expandablePanelView; 30 | 31 | private Typeface robotoThin; 32 | private Typeface robotoLight; 33 | 34 | private TextView userName; 35 | private TextView userDetails; 36 | 37 | @Override 38 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 39 | if (rootView != null) 40 | return rootView; 41 | 42 | int fragmentType = getArguments().getInt("type", FragmentTypes.BASIC.ordinal()); 43 | 44 | switch (fragmentType) { 45 | case 0: 46 | rootView = inflater.inflate(R.layout.fragment_basic_behaviour, container, false); 47 | break; 48 | case 1: 49 | rootView = inflater.inflate(R.layout.fragment_basic_expanded_behaviour, container, false); 50 | break; 51 | } 52 | 53 | robotoLight = Typeface.createFromAsset(getActivity().getAssets(), "Roboto-Light.ttf"); 54 | robotoThin = Typeface.createFromAsset(getActivity().getAssets(), "Roboto-Thin.ttf"); 55 | 56 | userName = (TextView) rootView.findViewById(R.id.userName); 57 | userDetails = (TextView) rootView.findViewById(R.id.userDetails); 58 | 59 | userName.setTypeface(robotoThin); 60 | userDetails.setTypeface(robotoLight); 61 | 62 | avatar = rootView.findViewById(R.id.avatar); 63 | expandablePanelView = (ExpandablePanelView) rootView.findViewById(R.id.expandablePanelView); 64 | 65 | expandablePanelView.attachExpandableListener(this); 66 | 67 | return rootView; 68 | } 69 | 70 | @Override 71 | public void onExpandingStarted() { 72 | } 73 | 74 | @Override 75 | public void onExpandingFinished() { 76 | ValueAnimator avatarAnim = ObjectAnimator.ofFloat(avatar, "alpha", 1, 0, 0); 77 | avatarAnim.setDuration(1000).setInterpolator(new DecelerateInterpolator()); 78 | 79 | avatarAnim.start(); 80 | } 81 | 82 | @Override 83 | public void onShrinkStarted() { 84 | } 85 | 86 | @Override 87 | public void onShrinkFinished() { 88 | ValueAnimator avatarAnim = ObjectAnimator.ofFloat(avatar, "alpha", 0, 1, 1); 89 | avatarAnim.setDuration(1000).setInterpolator(new DecelerateInterpolator()); 90 | 91 | avatarAnim.start(); 92 | } 93 | 94 | @Override 95 | public void onExpandingTouchEvent(MotionEvent motionEvent) { 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /app/src/main/java/expandablepanel/jorgecastilloprz/com/expandablepanel/ui/fragments/InverseBehaviorFragment.java: -------------------------------------------------------------------------------- 1 | package expandablepanel.jorgecastilloprz.com.expandablepanel.ui.fragments; 2 | 3 | import android.animation.ObjectAnimator; 4 | import android.animation.ValueAnimator; 5 | import android.os.Bundle; 6 | import android.support.v4.app.Fragment; 7 | import android.view.LayoutInflater; 8 | import android.view.MotionEvent; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | import android.view.animation.DecelerateInterpolator; 12 | 13 | import com.jorgecastilloprz.expandablepanel.ExpandablePanelView; 14 | import com.jorgecastilloprz.expandablepanel.listeners.ExpandableListener; 15 | 16 | import expandablepanel.jorgecastilloprz.com.expandablepanel.R; 17 | import expandablepanel.jorgecastilloprz.com.expandablepanel.ui.utils.FragmentTypes; 18 | 19 | /** 20 | * Created by jorge on 31/07/14. 21 | */ 22 | public class InverseBehaviorFragment extends Fragment implements ExpandableListener{ 23 | 24 | private View rootView; 25 | 26 | private View avatar; 27 | private ExpandablePanelView expandablePanelView; 28 | 29 | @Override 30 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 31 | if (rootView != null) 32 | return rootView; 33 | 34 | int fragmentType = getArguments().getInt("type", FragmentTypes.BASIC.ordinal()); 35 | 36 | switch (fragmentType) { 37 | case 0: 38 | rootView = inflater.inflate(R.layout.fragment_inverse_behaviour, container, false); 39 | break; 40 | case 1: 41 | rootView = inflater.inflate(R.layout.fragment_inverse_expanded_behaviour, container, false); 42 | break; 43 | } 44 | 45 | avatar = rootView.findViewById(R.id.avatar); 46 | expandablePanelView = (ExpandablePanelView) rootView.findViewById(R.id.expandablePanelView); 47 | 48 | expandablePanelView.attachExpandableListener(this); 49 | 50 | return rootView; 51 | } 52 | 53 | @Override 54 | public void onExpandingStarted() { 55 | } 56 | 57 | @Override 58 | public void onExpandingFinished() { 59 | ValueAnimator avatarAnim = ObjectAnimator.ofFloat(avatar, "alpha", 1, 0, 0); 60 | avatarAnim.setDuration(1000).setInterpolator(new DecelerateInterpolator()); 61 | 62 | avatarAnim.start(); 63 | } 64 | 65 | @Override 66 | public void onShrinkStarted() { 67 | } 68 | 69 | @Override 70 | public void onShrinkFinished() { 71 | ValueAnimator avatarAnim = ObjectAnimator.ofFloat(avatar, "alpha", 0, 1, 1); 72 | avatarAnim.setDuration(1000).setInterpolator(new DecelerateInterpolator()); 73 | 74 | avatarAnim.start(); 75 | } 76 | 77 | @Override 78 | public void onExpandingTouchEvent(MotionEvent motionEvent) { 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /app/src/main/java/expandablepanel/jorgecastilloprz/com/expandablepanel/ui/utils/FragmentTypes.java: -------------------------------------------------------------------------------- 1 | package expandablepanel.jorgecastilloprz.com.expandablepanel.ui.utils; 2 | 3 | /** 4 | * Created by jorge on 31/07/14. 5 | */ 6 | public enum FragmentTypes { 7 | BASIC, INVERSE; 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/daybackground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JorgeCastilloPrz/ExpandablePanel/12d7aca47599a80c2dadc6d0f56ff4dcd790926a/app/src/main/res/drawable-hdpi/daybackground.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_drawer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JorgeCastilloPrz/ExpandablePanel/12d7aca47599a80c2dadc6d0f56ff4dcd790926a/app/src/main/res/drawable-hdpi/ic_drawer.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JorgeCastilloPrz/ExpandablePanel/12d7aca47599a80c2dadc6d0f56ff4dcd790926a/app/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/nightbackground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JorgeCastilloPrz/ExpandablePanel/12d7aca47599a80c2dadc6d0f56ff4dcd790926a/app/src/main/res/drawable-hdpi/nightbackground.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/daybackground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JorgeCastilloPrz/ExpandablePanel/12d7aca47599a80c2dadc6d0f56ff4dcd790926a/app/src/main/res/drawable-mdpi/daybackground.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_drawer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JorgeCastilloPrz/ExpandablePanel/12d7aca47599a80c2dadc6d0f56ff4dcd790926a/app/src/main/res/drawable-mdpi/ic_drawer.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JorgeCastilloPrz/ExpandablePanel/12d7aca47599a80c2dadc6d0f56ff4dcd790926a/app/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/nightbackground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JorgeCastilloPrz/ExpandablePanel/12d7aca47599a80c2dadc6d0f56ff4dcd790926a/app/src/main/res/drawable-mdpi/nightbackground.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JorgeCastilloPrz/ExpandablePanel/12d7aca47599a80c2dadc6d0f56ff4dcd790926a/app/src/main/res/drawable-xhdpi/avatar.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_drawer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JorgeCastilloPrz/ExpandablePanel/12d7aca47599a80c2dadc6d0f56ff4dcd790926a/app/src/main/res/drawable-xhdpi/ic_drawer.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JorgeCastilloPrz/ExpandablePanel/12d7aca47599a80c2dadc6d0f56ff4dcd790926a/app/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_drawer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JorgeCastilloPrz/ExpandablePanel/12d7aca47599a80c2dadc6d0f56ff4dcd790926a/app/src/main/res/drawable-xxhdpi/ic_drawer.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JorgeCastilloPrz/ExpandablePanel/12d7aca47599a80c2dadc6d0f56ff4dcd790926a/app/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/daybackground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JorgeCastilloPrz/ExpandablePanel/12d7aca47599a80c2dadc6d0f56ff4dcd790926a/app/src/main/res/drawable-xxxhdpi/daybackground.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/nightbackground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JorgeCastilloPrz/ExpandablePanel/12d7aca47599a80c2dadc6d0f56ff4dcd790926a/app/src/main/res/drawable-xxxhdpi/nightbackground.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_basic_behaviour.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 18 | 19 | 25 | 26 | 32 | 33 | 37 | 38 | 46 | 47 | 51 | 52 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 71 | 72 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_basic_expanded_behaviour.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 19 | 20 | 26 | 27 | 33 | 34 | 38 | 39 | 47 | 48 | 52 | 53 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 72 | 73 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_inverse_behaviour.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 19 | 20 | 25 | 26 | 31 | 32 | 38 | 39 | 44 | 45 | 46 | 47 | 53 | 54 | 55 | 56 | 57 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_inverse_expanded_behaviour.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 20 | 21 | 26 | 27 | 32 | 33 | 39 | 40 | 45 | 46 | 47 | 48 | 54 | 55 | 56 | 57 | 58 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /app/src/main/res/layout/navigation_drawer_item.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 5 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/raw/en_generic_rgb_wo_60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JorgeCastilloPrz/ExpandablePanel/12d7aca47599a80c2dadc6d0f56ff4dcd790926a/app/src/main/res/raw/en_generic_rgb_wo_60.png -------------------------------------------------------------------------------- /app/src/main/res/raw/sample1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JorgeCastilloPrz/ExpandablePanel/12d7aca47599a80c2dadc6d0f56ff4dcd790926a/app/src/main/res/raw/sample1.gif -------------------------------------------------------------------------------- /app/src/main/res/raw/sample2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JorgeCastilloPrz/ExpandablePanel/12d7aca47599a80c2dadc6d0f56ff4dcd790926a/app/src/main/res/raw/sample2.gif -------------------------------------------------------------------------------- /app/src/main/res/raw/sample3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JorgeCastilloPrz/ExpandablePanel/12d7aca47599a80c2dadc6d0f56ff4dcd790926a/app/src/main/res/raw/sample3.gif -------------------------------------------------------------------------------- /app/src/main/res/raw/sample4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JorgeCastilloPrz/ExpandablePanel/12d7aca47599a80c2dadc6d0f56ff4dcd790926a/app/src/main/res/raw/sample4.gif -------------------------------------------------------------------------------- /app/src/main/res/values/arrays.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Basic behaviour 5 | Basic expanded 6 | Inverse behaviour 7 | Inverse expanded 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/color.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #e91e63 4 | #00bcd4 5 | #E36517 6 | #f37427 7 | #FFA064 8 | #FAFAFA 9 | #2E2E2E 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 10dp 3 | 20dp 4 | 17dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ExpandablePanel Sample 4 | Exit 5 | John Doe 6 | Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. 7 | Drawer open 8 | Drawer closed 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | } 5 | dependencies { 6 | classpath 'com.android.tools.build:gradle:1.0.0' 7 | } 8 | } 9 | def isReleaseBuild() { 10 | return version.contains("SNAPSHOT") == false 11 | } 12 | 13 | allprojects { 14 | version = VERSION_NAME 15 | group = GROUP 16 | 17 | repositories { 18 | mavenCentral() 19 | } 20 | } 21 | 22 | apply plugin: 'android-reporting' -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | VERSION_NAME=1.0.4 2 | VERSION_CODE=5 3 | GROUP=com.github.jorgecastilloprz 4 | 5 | POM_DESCRIPTION=Android library implementing expandable logic by drag for a topView in a vertical 2 views combo. 6 | POM_URL=https://github.com/jorgecastilloprz/ExpandablePanel 7 | POM_SCM_URL=https://github.com/jorgecastilloprz/ExpandablePanel 8 | POM_SCM_CONNECTION=scm:git@github.com:jorgecastilloprz/expandablepanel.git 9 | POM_SCM_DEV_CONNECTION=scm:git@github.com:jorgecastilloprz/expandablepanel.git 10 | POM_LICENCE_NAME=The Apache Software License, Version 2.0 11 | POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt 12 | POM_LICENCE_DIST=repo 13 | POM_DEVELOPER_ID=jorgecastilloprz 14 | POM_DEVELOPER_NAME=Jorge Castillo Pérez 15 | 16 | ANDROID_BUILD_TOOLS_VERSION=20.0.0 17 | ANDROID_COMPILE_SDK_VERSION=20 18 | ANDROID_TARGET_SDK_VERSION=19 19 | ANDROID_MIN_SDK=7 20 | ANDROID_SAMPLE_MIN_SDK=14 -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JorgeCastilloPrz/ExpandablePanel/12d7aca47599a80c2dadc6d0f56ff4dcd790926a/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Jan 26 20:26:24 CET 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /library/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /library/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion Integer.parseInt(project.ANDROID_COMPILE_SDK_VERSION) 5 | buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION 6 | 7 | defaultConfig { 8 | minSdkVersion Integer.parseInt(ANDROID_MIN_SDK) 9 | targetSdkVersion Integer.parseInt(project.ANDROID_TARGET_SDK_VERSION) 10 | versionCode Integer.parseInt(project.VERSION_CODE) 11 | versionName project.VERSION_NAME 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | compile fileTree(dir: 'libs', include: ['*.jar']) 23 | } 24 | 25 | apply from: '../maven_push.gradle' 26 | -------------------------------------------------------------------------------- /library/gradle.properties: -------------------------------------------------------------------------------- 1 | POM_NAME=ExpandablePanel library 2 | POM_ARTIFACT_ID=expandablepanel 3 | POM_PACKAGING=aar -------------------------------------------------------------------------------- /library/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/jorge/android/android-studio/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/jorgecastilloprz/expandablepanel/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.jorgecastilloprz.expandablepanel; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /library/src/main/java/com/jorgecastilloprz/expandablepanel/ExpandablePanelView.java: -------------------------------------------------------------------------------- 1 | package com.jorgecastilloprz.expandablepanel; 2 | 3 | import android.annotation.TargetApi; 4 | import android.content.Context; 5 | import android.content.res.TypedArray; 6 | import android.os.Build; 7 | import android.util.AttributeSet; 8 | import android.util.Log; 9 | import android.view.MotionEvent; 10 | import android.view.View; 11 | import android.widget.RelativeLayout; 12 | 13 | import com.jorgecastilloprz.expandablepanel.controllers.AnimationController; 14 | import com.jorgecastilloprz.expandablepanel.controllers.strategy.BasicAnimationStrategy; 15 | import com.jorgecastilloprz.expandablepanel.controllers.strategy.InverseAnimationStrategy; 16 | import com.jorgecastilloprz.expandablepanel.listeners.ExpandableListener; 17 | 18 | /** 19 | * Created by jorge on 16/07/14. 20 | */ 21 | public class ExpandablePanelView extends RelativeLayout { 22 | 23 | private static final int DEFAULT_ANIMABLE_VIEW_ID = -1; 24 | 25 | private int lastY; 26 | private int displayHeight; 27 | private boolean expanded; 28 | private int initialAnimableViewHeight; 29 | private View animableView; 30 | 31 | private ExpandableListener expandableListener; 32 | 33 | private float completionPercent; 34 | private int completeExpandAnimationSpeed; 35 | private int completeShrinkAnimationSpeed; 36 | private boolean beginExpanded; 37 | private int bounceCount; 38 | private boolean invertBehavior; 39 | private int animableViewId; 40 | private boolean autoAnimateOnClick; 41 | 42 | private AnimationController animationController; 43 | 44 | public ExpandablePanelView(Context context) { 45 | super(context); 46 | init(null); 47 | } 48 | 49 | public ExpandablePanelView(Context context, AttributeSet attrs) { 50 | super(context, attrs); 51 | init(attrs); 52 | } 53 | 54 | @TargetApi(Build.VERSION_CODES.HONEYCOMB) 55 | public ExpandablePanelView(Context context, AttributeSet attrs, int defStyle) { 56 | super(context, attrs, defStyle); 57 | init(attrs); 58 | } 59 | 60 | private void init(AttributeSet attrs) { 61 | 62 | //Initial attrs 63 | if (attrs != null) { 64 | 65 | TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.ExpandablePanelView); 66 | 67 | completionPercent = a.getFloat(R.styleable.ExpandablePanelView_completionPercent, 0.75f); 68 | completeExpandAnimationSpeed = a.getInt(R.styleable.ExpandablePanelView_completeExpandAnimationSpeed, 200); 69 | completeShrinkAnimationSpeed = a.getInt(R.styleable.ExpandablePanelView_completeShrinkAnimationSpeed, 200); 70 | beginExpanded = a.getBoolean(R.styleable.ExpandablePanelView_beginExpanded, false); 71 | bounceCount = a.getInteger(R.styleable.ExpandablePanelView_bounceCount, 2); 72 | invertBehavior = a.getBoolean(R.styleable.ExpandablePanelView_invertBehavior, false); 73 | animableViewId = a.getResourceId(R.styleable.ExpandablePanelView_animableViewId, DEFAULT_ANIMABLE_VIEW_ID); 74 | autoAnimateOnClick = a.getBoolean(R.styleable.ExpandablePanelView_autoAnimateOnClick, false); 75 | 76 | a.recycle(); 77 | } 78 | } 79 | 80 | @Override 81 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 82 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); 83 | 84 | //Just first time 85 | if (initialAnimableViewHeight == 0 && animableView == null) { 86 | checkChildrenCount(); 87 | 88 | displayHeight = getMeasuredHeight(); 89 | 90 | assignAnimableView(); 91 | 92 | initialAnimableViewHeight = animableView.getMeasuredHeight(); 93 | 94 | if (beginExpanded) 95 | animableView.getLayoutParams().height = displayHeight; 96 | 97 | animationController = AnimationController.getInstance(displayHeight, animableView); 98 | 99 | if (!invertBehavior) 100 | animationController.setAnimationStrategy(new BasicAnimationStrategy(displayHeight, animableView)); 101 | else 102 | animationController.setAnimationStrategy(new InverseAnimationStrategy(displayHeight, animableView)); 103 | 104 | setInitialClickListenerIfNeeded(); 105 | playBounceAnimationIfNeeded(); 106 | } 107 | } 108 | 109 | private void assignAnimableView() { 110 | if (animableViewId != DEFAULT_ANIMABLE_VIEW_ID) { 111 | animableView = findViewById(animableViewId); 112 | if (animableView == null) { 113 | throw new IllegalArgumentException("Review your layout, you don't have a child of " + "ExpandablePanelView view with id " + animableViewId); 114 | } 115 | } else { 116 | if (!invertBehavior) 117 | animableView = getChildAt(0); 118 | else 119 | animableView = getChildAt(1); 120 | } 121 | } 122 | 123 | private void playBounceAnimationIfNeeded() { 124 | if (beginExpanded) { 125 | animationController.playBounceAnimation(bounceCount); 126 | } 127 | } 128 | 129 | /** 130 | * Attachs the listener for expanding/shrinking events 131 | * 132 | * @param expandableListener 133 | */ 134 | public void attachExpandableListener(ExpandableListener expandableListener) { 135 | this.expandableListener = expandableListener; 136 | } 137 | 138 | /** 139 | * Checks if children number is correct and logs an error if it is not 140 | */ 141 | private void checkChildrenCount() { 142 | if (getChildCount() != 2) 143 | Log.e(getResources().getString(R.string.tag), getResources().getString(R.string.wrong_number_children_error)); 144 | } 145 | 146 | public boolean isExpanded() { 147 | return expanded; 148 | } 149 | 150 | @Override 151 | public boolean onTouchEvent(MotionEvent motionEvent) { 152 | 153 | switch (motionEvent.getAction()) { 154 | case MotionEvent.ACTION_DOWN: 155 | lastY = (int) motionEvent.getY(); 156 | 157 | dispatchGenericMovementStarted(); 158 | 159 | break; 160 | 161 | case MotionEvent.ACTION_MOVE: 162 | 163 | int currentY = (int) motionEvent.getY(); 164 | int diff = (currentY - lastY); 165 | 166 | animationController.updateAnimableViewHeight(animableView, initialAnimableViewHeight, diff); 167 | 168 | lastY = currentY; 169 | dispatchOnTouchEvent(motionEvent); 170 | break; 171 | 172 | case MotionEvent.ACTION_UP: 173 | 174 | if (animableView.getMeasuredHeight() > displayHeight * completionPercent && !expanded) { 175 | animationController.completeAnimationToFullHeight(completeExpandAnimationSpeed); 176 | expanded = true; 177 | dispatchGenericMovementFinished(); 178 | } else { 179 | animationController.completeAnimationToInitialHeight(completeShrinkAnimationSpeed, initialAnimableViewHeight); 180 | expanded = false; 181 | dispatchGenericMovementFinished(); 182 | } 183 | 184 | break; 185 | } 186 | return true; 187 | } 188 | 189 | private void setInitialClickListenerIfNeeded() { 190 | if (autoAnimateOnClick) { 191 | animableView.setOnClickListener(new OnClickListener() { 192 | @Override 193 | public void onClick(View view) { 194 | if (expanded) { 195 | playAutoShrinkAnimation(); 196 | } 197 | else { 198 | playAutoExpandAnimation(); 199 | } 200 | } 201 | }); 202 | } 203 | } 204 | 205 | /** 206 | * Use this method to enable auto expanding anim 207 | */ 208 | private void playAutoExpandAnimation() { 209 | dispatchGenericMovementStarted(); 210 | animationController.completeAnimationToFullHeight(completeExpandAnimationSpeed); 211 | expanded = true; 212 | dispatchGenericMovementFinished(); 213 | } 214 | 215 | /** 216 | * Use this method to enable auto shrinking anim 217 | */ 218 | private void playAutoShrinkAnimation() { 219 | dispatchGenericMovementStarted(); 220 | animationController.completeAnimationToInitialHeight(completeExpandAnimationSpeed, initialAnimableViewHeight); 221 | expanded = false; 222 | dispatchGenericMovementFinished(); 223 | } 224 | 225 | //Listener actions 226 | 227 | private void dispatchGenericMovementStarted() { 228 | if (!expanded) 229 | dispatchExpandingStarted(); 230 | else 231 | dispatchShrinkingStarted(); 232 | } 233 | 234 | private void dispatchGenericMovementFinished() { 235 | if (!expanded) 236 | dispatchShrinkingFinished(); 237 | else 238 | dispatchExpandingFinished(); 239 | } 240 | 241 | /** 242 | * This listener is dispatched when the expanding begins by the user 243 | */ 244 | private void dispatchExpandingStarted() { 245 | if (expandableListener != null) 246 | expandableListener.onExpandingStarted(); 247 | } 248 | 249 | /** 250 | * This listener is dispatched when the expanding finishes 251 | */ 252 | private void dispatchExpandingFinished() { 253 | if (expandableListener != null) 254 | expandableListener.onExpandingFinished(); 255 | } 256 | 257 | /** 258 | * This listener is dispatched when the shrink (collapse) begins 259 | */ 260 | private void dispatchShrinkingStarted() { 261 | if (expandableListener != null) 262 | expandableListener.onShrinkStarted(); 263 | } 264 | 265 | /** 266 | * This listener is dispatched when the shrink (collapse) finishes 267 | */ 268 | private void dispatchShrinkingFinished() { 269 | if (expandableListener != null) 270 | expandableListener.onShrinkFinished(); 271 | } 272 | 273 | /** 274 | * This listener is dispatched meanwhile the expanding movement is being produced 275 | */ 276 | private void dispatchOnTouchEvent(MotionEvent motionEvent) { 277 | if (expandableListener != null) 278 | expandableListener.onExpandingTouchEvent(motionEvent); 279 | } 280 | 281 | /** 282 | * Used to disable bounce animation arbitrarily 283 | * (For example, if the user touchs the screen, he might not want to see the bounce anymore) 284 | * 285 | * @param bounceEnabled 286 | */ 287 | public void setBounceEnabled(boolean bounceEnabled) { 288 | animationController.setBounceEnabled(bounceEnabled); 289 | } 290 | } 291 | -------------------------------------------------------------------------------- /library/src/main/java/com/jorgecastilloprz/expandablepanel/anim/HeightAnimation.java: -------------------------------------------------------------------------------- 1 | package com.jorgecastilloprz.expandablepanel.anim; 2 | 3 | import android.view.View; 4 | import android.view.animation.Animation; 5 | import android.view.animation.Transformation; 6 | 7 | /** 8 | * Created by jorge on 5/15/14. 9 | */ 10 | public class HeightAnimation extends Animation { 11 | 12 | protected final int originalHeight; 13 | protected final View view; 14 | protected float perValue; 15 | 16 | public HeightAnimation(View view, int fromHeight, int toHeight) { 17 | this.view = view; 18 | this.originalHeight = fromHeight; 19 | this.perValue = (toHeight - fromHeight); 20 | } 21 | 22 | @Override 23 | protected void applyTransformation(float interpolatedTime, Transformation t) { 24 | view.getLayoutParams().height = (int) (originalHeight + perValue * interpolatedTime); 25 | view.requestLayout(); 26 | } 27 | 28 | @Override 29 | public boolean willChangeBounds() { 30 | return true; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /library/src/main/java/com/jorgecastilloprz/expandablepanel/controllers/AnimationController.java: -------------------------------------------------------------------------------- 1 | package com.jorgecastilloprz.expandablepanel.controllers; 2 | 3 | import android.view.View; 4 | 5 | import com.jorgecastilloprz.expandablepanel.controllers.strategy.AbstractAnimationStrategy; 6 | import com.jorgecastilloprz.expandablepanel.controllers.strategy.BasicAnimationStrategy; 7 | 8 | /** 9 | * Created by jorge on 28/07/14. 10 | */ 11 | public class AnimationController { 12 | 13 | private static AnimationController INSTANCE = null; 14 | private AbstractAnimationStrategy animationStrategy; 15 | 16 | private AnimationController(int displayHeight, View animableView){ 17 | this.animationStrategy = new BasicAnimationStrategy(displayHeight, animableView); //default strat 18 | } 19 | 20 | private synchronized static void createInstance(int displayHeight, View animableView) { 21 | if (INSTANCE == null) { 22 | INSTANCE = new AnimationController(displayHeight, animableView); 23 | } 24 | } 25 | 26 | public static AnimationController getInstance(int displayHeight, View animableView) { 27 | createInstance(displayHeight, animableView); 28 | return INSTANCE; 29 | } 30 | 31 | public void setAnimationStrategy(AbstractAnimationStrategy animationStrategy) { 32 | this.animationStrategy = animationStrategy; 33 | } 34 | 35 | public void setBounceEnabled(boolean bounceEnabled) { 36 | animationStrategy.setBounceEnabled(bounceEnabled); 37 | } 38 | 39 | public void updateAnimableViewHeight(View animableView, int initialAnimableLayoutHeight, int heightDiff) { 40 | animationStrategy.updateAnimableViewHeight(animableView, initialAnimableLayoutHeight, heightDiff); 41 | } 42 | 43 | public void playBounceAnimation(final int bounceCount) { 44 | animationStrategy.playBounceAnimation(bounceCount); 45 | } 46 | 47 | public void completeAnimationToFullHeight(int completeExpandAnimationSpeed) { 48 | animationStrategy.completeAnimationToFullHeight(completeExpandAnimationSpeed); 49 | } 50 | 51 | public void completeAnimationToInitialHeight(int completeShrinkAnimationSpeed, int initialAnimableLayoutHeight) { 52 | animationStrategy.completeAnimationToInitialHeight(completeShrinkAnimationSpeed, initialAnimableLayoutHeight); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /library/src/main/java/com/jorgecastilloprz/expandablepanel/controllers/strategy/AbstractAnimationStrategy.java: -------------------------------------------------------------------------------- 1 | package com.jorgecastilloprz.expandablepanel.controllers.strategy; 2 | 3 | import android.view.View; 4 | import android.view.animation.DecelerateInterpolator; 5 | 6 | import com.jorgecastilloprz.expandablepanel.anim.HeightAnimation; 7 | 8 | /** 9 | * Created by jorge on 28/07/14. 10 | */ 11 | public abstract class AbstractAnimationStrategy { 12 | 13 | protected boolean bounceEnabled = true; 14 | protected int displayHeight; 15 | protected View animableView; 16 | 17 | public AbstractAnimationStrategy(int displayHeight, View animableView) { 18 | this.displayHeight = displayHeight; 19 | this.animableView = animableView; 20 | } 21 | 22 | public void setBounceEnabled(boolean bounceEnabled) { 23 | this.bounceEnabled = bounceEnabled; 24 | } 25 | 26 | /** 27 | * Animates animableView until it reaches full screen height 28 | */ 29 | public void completeAnimationToFullHeight(int completeExpandAnimationSpeed) { 30 | HeightAnimation heightAnim = new HeightAnimation(animableView, animableView.getMeasuredHeight(), displayHeight); 31 | 32 | heightAnim.setDuration(completeExpandAnimationSpeed); 33 | heightAnim.setInterpolator(new DecelerateInterpolator()); 34 | animableView.startAnimation(heightAnim); 35 | } 36 | 37 | /** 38 | * Animates animableView to get its initial height back 39 | */ 40 | public void completeAnimationToInitialHeight(int completeShrinkAnimationSpeed, int initialAnimableLayoutHeight) { 41 | HeightAnimation heightAnim = new HeightAnimation(animableView, animableView.getMeasuredHeight(), initialAnimableLayoutHeight); 42 | 43 | heightAnim.setDuration(completeShrinkAnimationSpeed); 44 | heightAnim.setInterpolator(new DecelerateInterpolator()); 45 | animableView.startAnimation(heightAnim); 46 | } 47 | 48 | public abstract void playBounceAnimation(final int bounceCount); 49 | public abstract void updateAnimableViewHeight(View animableView, int initialAnimableLayoutHeight, int heightDiff); 50 | } 51 | -------------------------------------------------------------------------------- /library/src/main/java/com/jorgecastilloprz/expandablepanel/controllers/strategy/BasicAnimationStrategy.java: -------------------------------------------------------------------------------- 1 | package com.jorgecastilloprz.expandablepanel.controllers.strategy; 2 | 3 | import android.view.View; 4 | import android.view.animation.AccelerateDecelerateInterpolator; 5 | import android.view.animation.Animation; 6 | import android.view.animation.BounceInterpolator; 7 | import android.widget.RelativeLayout; 8 | 9 | import com.jorgecastilloprz.expandablepanel.anim.HeightAnimation; 10 | 11 | /** 12 | * Created by jorge on 28/07/14. 13 | */ 14 | public class BasicAnimationStrategy extends AbstractAnimationStrategy { 15 | 16 | public BasicAnimationStrategy(int displayHeight, View animableView) { 17 | super(displayHeight, animableView); 18 | } 19 | 20 | @Override 21 | public void playBounceAnimation(final int bounceCount) { 22 | 23 | if (bounceCount == 0 || !bounceEnabled) 24 | return; 25 | 26 | int heightValueToBounce = (int) (displayHeight * 0.95); 27 | int singleAnimDuration = 300; 28 | 29 | final HeightAnimation bounceAnimDown = new HeightAnimation(animableView, heightValueToBounce, displayHeight); 30 | bounceAnimDown.setDuration(singleAnimDuration); 31 | bounceAnimDown.setInterpolator(new BounceInterpolator()); 32 | bounceAnimDown.setStartOffset(singleAnimDuration); 33 | 34 | HeightAnimation bounceAnimUp = new HeightAnimation(animableView, displayHeight, heightValueToBounce); 35 | bounceAnimUp.setDuration(singleAnimDuration); 36 | bounceAnimUp.setInterpolator(new AccelerateDecelerateInterpolator()); 37 | bounceAnimUp.setAnimationListener(new Animation.AnimationListener() { 38 | @Override 39 | public void onAnimationStart(Animation animation) { 40 | } 41 | 42 | @Override 43 | public void onAnimationEnd(Animation animation) { 44 | animableView.startAnimation(bounceAnimDown); 45 | } 46 | 47 | @Override 48 | public void onAnimationRepeat(Animation animation) { 49 | } 50 | }); 51 | 52 | animableView.startAnimation(bounceAnimUp); 53 | 54 | animableView.postDelayed(new Runnable() { 55 | @Override 56 | public void run() { 57 | playBounceAnimation(bounceCount-1); 58 | } 59 | }, 2000); 60 | } 61 | 62 | @Override 63 | public void updateAnimableViewHeight(View animableView, int initialAnimableViewHeight, int heightDiff) { 64 | RelativeLayout.LayoutParams animableViewParams = (RelativeLayout.LayoutParams) animableView.getLayoutParams(); 65 | 66 | if (animableViewParams.height >= initialAnimableViewHeight) { 67 | animableViewParams.height += heightDiff; 68 | } 69 | 70 | animableView.setLayoutParams(animableViewParams); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /library/src/main/java/com/jorgecastilloprz/expandablepanel/controllers/strategy/InverseAnimationStrategy.java: -------------------------------------------------------------------------------- 1 | package com.jorgecastilloprz.expandablepanel.controllers.strategy; 2 | 3 | import android.view.View; 4 | import android.view.animation.AccelerateDecelerateInterpolator; 5 | import android.view.animation.Animation; 6 | import android.view.animation.BounceInterpolator; 7 | import android.widget.RelativeLayout; 8 | 9 | import com.jorgecastilloprz.expandablepanel.anim.HeightAnimation; 10 | 11 | /** 12 | * Created by jorge on 28/07/14. 13 | */ 14 | public class InverseAnimationStrategy extends AbstractAnimationStrategy { 15 | 16 | public InverseAnimationStrategy(int displayHeight, View animableView) { 17 | super(displayHeight, animableView); 18 | } 19 | 20 | @Override 21 | public void playBounceAnimation(final int bounceCount) { 22 | 23 | if (bounceCount == 0 || !bounceEnabled) 24 | return; 25 | 26 | int heightValueToBounce = (int) (displayHeight * 0.95); 27 | int singleAnimDuration = 300; 28 | 29 | final HeightAnimation bounceAnimDown = new HeightAnimation(animableView, heightValueToBounce, displayHeight); 30 | bounceAnimDown.setDuration(singleAnimDuration); 31 | bounceAnimDown.setInterpolator(new BounceInterpolator()); 32 | bounceAnimDown.setStartOffset(singleAnimDuration); 33 | 34 | HeightAnimation bounceAnimUp = new HeightAnimation(animableView, displayHeight, heightValueToBounce); 35 | bounceAnimUp.setDuration(singleAnimDuration); 36 | bounceAnimUp.setInterpolator(new AccelerateDecelerateInterpolator()); 37 | bounceAnimUp.setAnimationListener(new Animation.AnimationListener() { 38 | @Override 39 | public void onAnimationStart(Animation animation) { 40 | } 41 | 42 | @Override 43 | public void onAnimationEnd(Animation animation) { 44 | animableView.startAnimation(bounceAnimDown); 45 | } 46 | 47 | @Override 48 | public void onAnimationRepeat(Animation animation) { 49 | } 50 | }); 51 | 52 | animableView.startAnimation(bounceAnimUp); 53 | 54 | animableView.postDelayed(new Runnable() { 55 | @Override 56 | public void run() { 57 | playBounceAnimation(bounceCount-1); 58 | } 59 | }, 2000); 60 | } 61 | 62 | @Override 63 | public void updateAnimableViewHeight(View animableView, int initialAnimableViewHeight, int heightDiff) { 64 | RelativeLayout.LayoutParams animableViewParams = (RelativeLayout.LayoutParams) animableView.getLayoutParams(); 65 | 66 | if (animableViewParams.height >= initialAnimableViewHeight) { 67 | animableViewParams.height -= heightDiff; 68 | } 69 | 70 | animableView.setLayoutParams(animableViewParams); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /library/src/main/java/com/jorgecastilloprz/expandablepanel/listeners/ExpandableListener.java: -------------------------------------------------------------------------------- 1 | package com.jorgecastilloprz.expandablepanel.listeners; 2 | 3 | import android.view.MotionEvent; 4 | 5 | /** 6 | * Created by jorge on 19/07/14. 7 | */ 8 | public interface ExpandableListener { 9 | 10 | void onExpandingStarted(); 11 | void onExpandingFinished(); 12 | void onShrinkStarted(); 13 | void onShrinkFinished(); 14 | void onExpandingTouchEvent(MotionEvent motionEvent); 15 | } 16 | -------------------------------------------------------------------------------- /library/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JorgeCastilloPrz/ExpandablePanel/12d7aca47599a80c2dadc6d0f56ff4dcd790926a/library/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JorgeCastilloPrz/ExpandablePanel/12d7aca47599a80c2dadc6d0f56ff4dcd790926a/library/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JorgeCastilloPrz/ExpandablePanel/12d7aca47599a80c2dadc6d0f56ff4dcd790926a/library/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JorgeCastilloPrz/ExpandablePanel/12d7aca47599a80c2dadc6d0f56ff4dcd790926a/library/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /library/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /library/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ExpandablePanel 3 | ExpandablePanel 4 | Wrong children number. You must insert two children inside ExpandablePanelView in order to make it work. 5 | Animation is not happening. The view is already expanded. 6 | Animation is not happening. The view is already shrunk. 7 | 8 | -------------------------------------------------------------------------------- /maven_push.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'maven' 2 | apply plugin: 'signing' 3 | 4 | def sonatypeRepositoryUrl 5 | if (isReleaseBuild()) { 6 | println 'RELEASE BUILD' 7 | sonatypeRepositoryUrl = hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL 8 | : "https://oss.sonatype.org/service/local/staging/deploy/maven2/" 9 | } else { 10 | println 'DEBUG BUILD' 11 | sonatypeRepositoryUrl = hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL 12 | : "https://oss.sonatype.org/content/repositories/snapshots/" 13 | } 14 | 15 | def getRepositoryUsername() { 16 | return hasProperty('nexusUsername') ? nexusUsername : "" 17 | } 18 | 19 | def getRepositoryPassword() { 20 | return hasProperty('nexusPassword') ? nexusPassword : "" 21 | } 22 | 23 | afterEvaluate { project -> 24 | uploadArchives { 25 | repositories { 26 | mavenDeployer { 27 | beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } 28 | 29 | pom.artifactId = POM_ARTIFACT_ID 30 | 31 | repository(url: sonatypeRepositoryUrl) { 32 | authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) 33 | } 34 | 35 | pom.project { 36 | name POM_NAME 37 | packaging POM_PACKAGING 38 | description POM_DESCRIPTION 39 | url POM_URL 40 | 41 | scm { 42 | url POM_SCM_URL 43 | connection POM_SCM_CONNECTION 44 | developerConnection POM_SCM_DEV_CONNECTION 45 | } 46 | 47 | licenses { 48 | license { 49 | name POM_LICENCE_NAME 50 | url POM_LICENCE_URL 51 | distribution POM_LICENCE_DIST 52 | } 53 | } 54 | 55 | developers { 56 | developer { 57 | id POM_DEVELOPER_ID 58 | name POM_DEVELOPER_NAME 59 | } 60 | } 61 | } 62 | } 63 | } 64 | } 65 | 66 | signing { 67 | required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") } 68 | sign configurations.archives 69 | } 70 | 71 | task androidJavadocs(type: Javadoc) { 72 | source = android.sourceSets.main.java.sourceFiles 73 | } 74 | 75 | task androidJavadocsJar(type: Jar) { 76 | classifier = 'javadoc' 77 | //basename = artifact_id 78 | from androidJavadocs.destinationDir 79 | } 80 | 81 | task androidSourcesJar(type: Jar) { 82 | classifier = 'sources' 83 | //basename = artifact_id 84 | from android.sourceSets.main.java.sourceFiles 85 | } 86 | 87 | artifacts { 88 | //archives packageReleaseJar 89 | archives androidSourcesJar 90 | archives androidJavadocsJar 91 | } 92 | } -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':library' 2 | --------------------------------------------------------------------------------