├── .gitignore ├── .idea ├── caches │ └── build_file_checksums.ser ├── codeStyles │ └── Project.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── freeankit │ │ └── foldinganimation │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── freeankit │ │ │ └── foldinganimation │ │ │ ├── ListActivity.kt │ │ │ ├── MainActivity.kt │ │ │ └── SampleAdapter.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ ├── activity_list.xml │ │ ├── activity_main.xml │ │ └── recyclerview_item.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── freeankit │ └── foldinganimation │ └── ExampleUnitTest.kt ├── art ├── animationgif.gif └── video.mp4 ├── build.gradle ├── foldingkit ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── freeankit │ │ └── foldingit │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── cogitator │ │ │ └── foldingit │ │ │ ├── FoldingKit.kt │ │ │ ├── animation │ │ │ ├── AnimationEndListener.kt │ │ │ ├── FoldAnimation.kt │ │ │ └── HeightAnimation.kt │ │ │ └── views │ │ │ └── FoldingKitView.kt │ └── res │ │ └── values │ │ ├── attrs.xml │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── freeankit │ └── foldingit │ └── ExampleUnitTest.java ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArchitectAK/FoldingAnimationKotlin-Android/763d715e37fa3afa3dc2cd9494a71c7627edb45e/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 27 | 28 | 29 | 30 | 31 | 32 | 34 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FoldingAnimationKotlin-Android 2 | 3 | An Android library to allow developers to give folding animations to the views using Kotlin. 4 | 5 | ### I have written a [Medium Post here](https://goo.gl/2erWmn) on it. 6 | 7 | # Add dependency to your project 8 | 9 | - if using maven 10 | 11 | 12 | com.cogitator.foldingkit 13 | foldingkit 14 | 1.0.0 15 | pom 16 | 17 | 18 | - in app level build.gradle latest version 19 | 20 | implementation 'com.cogitator.foldingkit:foldingkit:1.1.0' 21 | 22 | 23 | 24 | 25 | 26 | ##### credits for inspiration 27 | - [Ramotion's Folding Cell](https://github.com/Ramotion/folding-cell) 28 | 29 | 30 | ### Would you like to buy me a cup of coffee? 31 | #### I'd appreciate even your little contribution to my work, it helps me keep this Open Source updated. If this project helped you or your business and if you feel like donating some bucks, you can Paypal me - ankitdroiddeveloper@gmail.com 32 | 33 | Buy Me a Coffee at ko-fi.com 34 | 35 | ### Contact - Let's connect to learn together 36 | - [Twitter](https://twitter.com/KumarAnkitRKE) 37 | - [Github](https://github.com/AnkitDroidGit) 38 | - [LinkedIn](https://www.linkedin.com/in/kumarankitkumar/) 39 | - [Facebook](https://www.facebook.com/freeankit) 40 | - [Slack](https://ankitdroid.slack.com) 41 | - [Stackoverflow](https://stackoverflow.com/users/3282461/android) 42 | - [Android App](https://play.google.com/store/apps/details?id=com.freeankit.ankitprofile) 43 | 44 | 45 | ### License 46 | 47 | Copyright 2018 Ankit Kumar 48 | 49 | Licensed under the Apache License, Version 2.0 (the "License"); 50 | you may not use this file except in compliance with the License. 51 | You may obtain a copy of the License at 52 | 53 | http://www.apache.org/licenses/LICENSE-2.0 54 | 55 | Unless required by applicable law or agreed to in writing, software 56 | distributed under the License is distributed on an "AS IS" BASIS, 57 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 58 | See the License for the specific language governing permissions and 59 | limitations under the License. 60 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | apply plugin: 'kotlin-android' 4 | 5 | apply plugin: 'kotlin-android-extensions' 6 | 7 | android { 8 | compileSdkVersion 28 9 | defaultConfig { 10 | applicationId "com.freeankit.foldinganimation" 11 | minSdkVersion 21 12 | targetSdkVersion 28 13 | versionCode 1 14 | versionName "1.0" 15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 16 | } 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | } 24 | 25 | dependencies { 26 | implementation fileTree(dir: 'libs', include: ['*.jar']) 27 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 28 | implementation 'com.android.support:appcompat-v7:28.0.0' 29 | implementation 'com.android.support.constraint:constraint-layout:1.1.3' 30 | implementation 'com.android.support:recyclerview-v7:28.0.0' 31 | implementation 'com.android.support:cardview-v7:28.0.0' 32 | testImplementation 'junit:junit:4.12' 33 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 34 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 35 | 36 | implementation project(':foldingkit') 37 | } 38 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/freeankit/foldinganimation/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.freeankit.foldinganimation 2 | 3 | import android.support.test.InstrumentationRegistry 4 | import android.support.test.runner.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getTargetContext() 22 | assertEquals("com.freeankit.foldinganimation", appContext.packageName) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/java/com/freeankit/foldinganimation/ListActivity.kt: -------------------------------------------------------------------------------- 1 | package com.freeankit.foldinganimation 2 | 3 | import android.os.Bundle 4 | import android.support.v7.app.AppCompatActivity 5 | import android.support.v7.widget.LinearLayoutManager 6 | import kotlinx.android.synthetic.main.activity_list.* 7 | 8 | /** 9 | * @author Ankit Kumar (ankitdroiddeveloper@gmail.com) on 18/05/2018 (MM/DD/YYYY) 10 | */ 11 | class ListActivity : AppCompatActivity() { 12 | override fun onCreate(savedInstanceState: Bundle?) { 13 | super.onCreate(savedInstanceState) 14 | setContentView(R.layout.activity_list) 15 | 16 | recyclerview.apply { 17 | setHasFixedSize(true) 18 | recyclerview.layoutManager = LinearLayoutManager(this@ListActivity) 19 | recyclerview.adapter = SampleAdapter() 20 | } 21 | 22 | } 23 | } -------------------------------------------------------------------------------- /app/src/main/java/com/freeankit/foldinganimation/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.freeankit.foldinganimation 2 | 3 | import android.content.Intent 4 | import android.os.Bundle 5 | import android.support.v7.app.AppCompatActivity 6 | import kotlinx.android.synthetic.main.activity_main.* 7 | import kotlinx.android.synthetic.main.recyclerview_item.* 8 | 9 | 10 | class MainActivity : AppCompatActivity() { 11 | 12 | override fun onCreate(savedInstanceState: Bundle?) { 13 | super.onCreate(savedInstanceState) 14 | setContentView(R.layout.activity_main) 15 | // get our folding cell 16 | 17 | // attach click listener to fold btn 18 | toggle_btn.setOnClickListener({ 19 | folding_cell.toggle(false) 20 | }) 21 | 22 | // attach click listener to toast btn 23 | toggle_instant_btn.setOnClickListener({ 24 | folding_cell.toggle(true) 25 | }) 26 | see_list.setOnClickListener({ 27 | startActivity(Intent(this, ListActivity::class.java)) 28 | }) 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/freeankit/foldinganimation/SampleAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.freeankit.foldinganimation 2 | 3 | import android.support.v7.widget.RecyclerView 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import kotlinx.android.synthetic.main.recyclerview_item.view.* 8 | 9 | 10 | /** 11 | * @author Ankit Kumar (ankitdroiddeveloper@gmail.com) on 20/05/2018 (MM/DD/YYYY) 12 | */ 13 | class SampleAdapter : RecyclerView.Adapter() { 14 | 15 | val unfoldedIndexes = HashSet() 16 | 17 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { 18 | val view = LayoutInflater.from(parent.context).inflate(R.layout.recyclerview_item, parent, false) 19 | return ViewHolder(view) 20 | } 21 | 22 | override fun getItemCount(): Int { 23 | return 10 24 | } 25 | 26 | override fun onBindViewHolder(holder: ViewHolder, position: Int) { 27 | holder.bind(position) 28 | } 29 | 30 | inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { 31 | fun bind(position: Int) = with(itemView) { 32 | 33 | // folding_cell.setBackgroundColor(resources.getColor(R.color.colorPrimary)) 34 | folding_cell.backSideColor = resources.getColor(R.color.colorPrimary) 35 | 36 | if (unfoldedIndexes.contains(position)) { 37 | cell_title_view.visibility = View.GONE 38 | cell_content_view.visibility = View.VISIBLE 39 | } else { 40 | cell_content_view.visibility = View.GONE 41 | cell_title_view.visibility = View.VISIBLE 42 | } 43 | 44 | itemView.setOnClickListener { 45 | // toggle clicked cell state 46 | folding_cell.toggle(false) 47 | // register in adapter that state for selected cell is toggled 48 | registerToggle(position) 49 | } 50 | } 51 | 52 | private fun registerToggle(position: Int) { 53 | if (unfoldedIndexes.contains(position)) 54 | registerFold(position) 55 | else 56 | registerUnfold(position) 57 | } 58 | 59 | private fun registerFold(position: Int) { 60 | unfoldedIndexes.remove(position) 61 | } 62 | 63 | private fun registerUnfold(position: Int) { 64 | unfoldedIndexes.add(position) 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 19 | 20 | 25 | 26 |