├── .github └── workflows │ └── ci.yml ├── .gitignore ├── LICENSE.txt ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── assets │ └── fonts │ │ └── RobotoCondensed-Regular.ttf │ ├── java │ └── com │ │ └── commit451 │ │ └── quickactionview │ │ └── sample │ │ ├── Cheese.kt │ │ ├── CheeseAdapter.kt │ │ ├── CheeseViewHolder.kt │ │ ├── Cheeses.kt │ │ ├── CustomActionsInAnimator.kt │ │ ├── CustomActionsTitleAnimator.kt │ │ ├── MainActivity.kt │ │ └── RecyclerViewActivity.kt │ └── res │ ├── drawable-nodpi │ ├── cheese_1.jpg │ ├── cheese_2.jpg │ ├── cheese_3.jpg │ ├── cheese_4.jpg │ └── cheese_5.jpg │ ├── drawable │ ├── ic_favorite_24dp.xml │ ├── ic_shopping_basket_24dp.xml │ ├── ic_shopping_basket_dark_24dp.xml │ ├── ic_thumb_up_black_24dp.xml │ ├── indicator.xml │ ├── sample_background_color.xml │ ├── sample_changing_icon.xml │ └── text_background.xml │ ├── layout │ ├── activity_main.xml │ ├── activity_recyclerview.xml │ └── item_cheese.xml │ ├── menu │ ├── actions.xml │ └── actions_2.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── mipmap-xxxhdpi │ └── ic_launcher.png │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── ids.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── quickactionview ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── commit451 │ │ └── quickactionview │ │ ├── Action.kt │ │ ├── ActionTitleView.kt │ │ ├── ActionView.kt │ │ ├── ActionsInAnimator.kt │ │ ├── ActionsOutAnimator.kt │ │ ├── ActionsTitleInAnimator.kt │ │ ├── ActionsTitleOutAnimator.kt │ │ ├── ColorUtils.kt │ │ ├── ConfigHelper.kt │ │ ├── QuickActionView.kt │ │ └── animator │ │ ├── FadeAnimator.kt │ │ ├── FadeInFadeOutActionsTitleAnimator.kt │ │ ├── PopAnimator.kt │ │ └── SlideFromCenterAnimator.kt │ └── res │ ├── drawable │ ├── qav_indicator.xml │ └── qav_text_background.xml │ └── values │ └── dimens.xml ├── screenshots └── qav.gif └── settings.gradle /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | on: [pull_request, push] 3 | jobs: 4 | build: 5 | runs-on: ubuntu-latest 6 | steps: 7 | - name: Checkout the code 8 | uses: actions/checkout@v2 9 | - name: Build the app 10 | run: ./gradlew build 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io 2 | 3 | ### Android ### 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | 19 | # Local configuration file (sdk path, etc) 20 | local.properties 21 | 22 | # Proguard folder generated by Eclipse 23 | proguard/ 24 | 25 | # Log Files 26 | *.log 27 | 28 | 29 | ### Intellij ### 30 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm 31 | 32 | *.iml 33 | 34 | ## Directory-based project format: 35 | .idea/ 36 | # if you remove the above rule, at least ignore the following: 37 | 38 | # User-specific stuff: 39 | # .idea/workspace.xml 40 | # .idea/tasks.xml 41 | # .idea/dictionaries 42 | 43 | # Sensitive or high-churn files: 44 | # .idea/dataSources.ids 45 | # .idea/dataSources.xml 46 | # .idea/sqlDataSources.xml 47 | # .idea/dynamic.xml 48 | # .idea/uiDesigner.xml 49 | 50 | # Gradle: 51 | # .idea/gradle.xml 52 | # .idea/libraries 53 | 54 | # Mongo Explorer plugin: 55 | # .idea/mongoSettings.xml 56 | 57 | ## File-based project format: 58 | *.ipr 59 | *.iws 60 | 61 | ## Plugin-specific files: 62 | 63 | # IntelliJ 64 | out/ 65 | 66 | # mpeltonen/sbt-idea plugin 67 | .idea_modules/ 68 | 69 | # JIRA plugin 70 | atlassian-ide-plugin.xml 71 | 72 | # Crashlytics plugin (for Android Studio and IntelliJ) 73 | com_crashlytics_export_strings.xml 74 | 75 | # Ignore Gradle GUI config 76 | gradle-app.setting 77 | 78 | # Mobile Tools for Java (J2ME) 79 | .mtj.tmp/ 80 | 81 | # Package Files # 82 | *.war 83 | *.ear 84 | 85 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 86 | hs_err_pid* 87 | 88 | *.DS_Store -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # QuickActionView 2 | View that shows quick actions when long pressed, inspired by Pinterest 3 | 4 | [![Build Status](https://travis-ci.org/Commit451/QuickActionView.svg?branch=master)](https://travis-ci.org/Commit451/QuickActionView) [![](https://jitpack.io/v/Commit451/QuickActionView.svg)](https://jitpack.io/#Commit451/QuickActionView) 5 | 6 | ![Sample Gif](https://raw.githubusercontent.com/Commit451/QuickActionView/master/screenshots/qav.gif) 7 | 8 | # Gradle Dependency 9 | 10 | Add this in your root `build.gradle` file (**not** your module `build.gradle` file): 11 | 12 | ```gradle 13 | allprojects { 14 | repositories { 15 | ... 16 | maven { url "https://jitpack.io" } 17 | } 18 | } 19 | ``` 20 | 21 | Then, add the library to your project `build.gradle` 22 | ```gradle 23 | dependencies { 24 | compile 'com.github.Commit451:QuickActionView:latest.release.here' 25 | } 26 | ``` 27 | 28 | # Basic Usage 29 | 30 | See the sample app for usage within a normal layout, as well as within a list using RecyclerView. In the most basic usage: 31 | 32 | ```java 33 | View view = findViewById(R.id.your_view); 34 | QuickActionView.make(this) 35 | .addActions(R.menu.actions) 36 | .register(view); 37 | ``` 38 | You can also create Actions at runtime: 39 | ```java 40 | Drawable icon = ContextCompat.getDrawable(this, R.drawable.ic_favorite_24dp); 41 | String title = getString(R.string.action_favorite); 42 | Action action = new Action(1337, icon, title); 43 | QuickActionView.make(this) 44 | .addAction(action) 45 | //more configuring 46 | .register(view); 47 | ``` 48 | 49 | # Configuring the QuickActionView 50 | 51 | QuickActionView can be customized globally, or on a per Action basis. 52 | ```java 53 | QuickActionView.make(this) 54 | .addActions(R.menu.actions) 55 | .setOnActionSelectedListener(mQuickActionListener) 56 | .setBackgroundColor(Color.RED) 57 | .setTextColor(Color.BLUE) 58 | .setTextSize(30) 59 | .setScrimColor(Color.parseColor("#99FFFFFF")) 60 | //etc 61 | .register(view); 62 | ``` 63 | 64 | # Configuring Action Items 65 | 66 | Use the `QuickActionConfig` builder to create custom configurations for each action item you create. 67 | ```java 68 | //Give one of the quick actions custom colors 69 | Action.Config actionConfig = new Action.Config() 70 | .setBackgroundColor(Color.BLUE) 71 | .setTextColor(Color.MAGENTA); 72 | 73 | QuickActionView.make(this) 74 | .addActions(R.menu.actions) 75 | //the custom Action.Cofig will only apply to the addToCart action 76 | .setActionConfig(actionConfig, R.id.action_add_to_cart) 77 | .register(findViewById(R.id.custom_parent)); 78 | ``` 79 | 80 | # Customizing Animations 81 | 82 | You can even customize the animation performed when the actions come into view and go out of view. `FadeAnimator` `PopAnimator` and `SlideFromCenterAnimator` are three pre-built animators, and all you need to do to create your own is implement `ActionsInAnimator`, `ActionsOutAnimator` 83 | and call `setActionsInAnimator` and `setActionsOutAnimator` respectively. 84 | 85 | # Listening for Events 86 | 87 | You can hook into the interesting events a QuickActionView has: 88 | ```java 89 | QuickActionView.make(this) 90 | .addActions(R.menu.actions) 91 | .setOnActionSelectedListener(mQuickActionListener) 92 | .setOnShowListener(mQuickActionShowListener) 93 | .setOnDismissListener(mQuickActionDismissListener) 94 | .setOnActionHoverChangedListener(mOnActionHoverChangedListener) 95 | .register(view); 96 | ``` 97 | 98 | See the sample for more detail. 99 | 100 | License 101 | -------- 102 | 103 | Copyright 2020 Commit 451 104 | 105 | Licensed under the Apache License, Version 2.0 (the "License"); 106 | you may not use this file except in compliance with the License. 107 | You may obtain a copy of the License at 108 | 109 | http://www.apache.org/licenses/LICENSE-2.0 110 | 111 | Unless required by applicable law or agreed to in writing, software 112 | distributed under the License is distributed on an "AS IS" BASIS, 113 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 114 | See the License for the specific language governing permissions and 115 | limitations under the License. 116 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | apply plugin: 'kotlin-android' 4 | 5 | android { 6 | compileSdkVersion 33 7 | 8 | defaultConfig { 9 | applicationId "com.commit451.quickactionview.sample" 10 | minSdkVersion 21 11 | targetSdkVersion 33 12 | versionCode 1 13 | versionName "1.0" 14 | } 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | lintOptions { 22 | abortOnError false 23 | } 24 | } 25 | 26 | dependencies { 27 | implementation 'androidx.appcompat:appcompat:1.5.1' 28 | implementation 'com.google.android.material:material:1.7.0' 29 | implementation 'androidx.recyclerview:recyclerview:1.2.1' 30 | 31 | implementation project(':quickactionview') 32 | } 33 | -------------------------------------------------------------------------------- /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 /Users/John/Library/Android/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/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/assets/fonts/RobotoCondensed-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Commit451/QuickActionView/72db4a0037f88bea7bb8f77d37d32f59c0c50365/app/src/main/assets/fonts/RobotoCondensed-Regular.ttf -------------------------------------------------------------------------------- /app/src/main/java/com/commit451/quickactionview/sample/Cheese.kt: -------------------------------------------------------------------------------- 1 | package com.commit451.quickactionview.sample 2 | 3 | /** 4 | * A fake model to show usage 5 | */ 6 | data class Cheese( 7 | val drawable: Int, 8 | val name: String 9 | ) 10 | -------------------------------------------------------------------------------- /app/src/main/java/com/commit451/quickactionview/sample/CheeseAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.commit451.quickactionview.sample 2 | 3 | import android.content.Context 4 | import com.google.android.material.snackbar.Snackbar 5 | import androidx.recyclerview.widget.RecyclerView 6 | import android.view.ViewGroup 7 | 8 | import com.commit451.quickactionview.Action 9 | import com.commit451.quickactionview.OnActionSelectedListener 10 | import com.commit451.quickactionview.QuickActionView 11 | 12 | /** 13 | * Adapter for the RecyclerView, which holds cheeses 14 | */ 15 | class CheeseAdapter(context: Context, private val listener: Listener) : RecyclerView.Adapter(), OnActionSelectedListener { 16 | 17 | private val values = mutableListOf() 18 | 19 | private val quickActionView: QuickActionView = QuickActionView.make(context) 20 | .addActions(R.menu.actions) 21 | .setOnActionSelectedListener(this) 22 | 23 | override fun invoke(action: Action, quickActionView: QuickActionView) { 24 | val view = quickActionView.longPressedView 25 | if (view != null) { 26 | val position = view.getTag(R.id.list_position) as Int 27 | val cheese = values[position] 28 | Snackbar.make(view, "Clicked on ${cheese.name} with action ${action.title}", Snackbar.LENGTH_SHORT) 29 | .show() 30 | } 31 | } 32 | 33 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CheeseViewHolder { 34 | val holder = CheeseViewHolder.newInstance(parent) 35 | holder.itemView.setOnClickListener { v -> 36 | val position = v.getTag(R.id.list_position) as Int 37 | val cheese = values[position] 38 | // Communicate to the activity that the item was clicked 39 | listener.onItemClicked(cheese) 40 | } 41 | quickActionView.register(holder.itemView) 42 | return holder 43 | } 44 | 45 | override fun onBindViewHolder(holder: CheeseViewHolder, position: Int) { 46 | val cheese = values[position] 47 | holder.bind(cheese) 48 | holder.itemView.setTag(R.id.list_position, position) 49 | holder.itemView.setTag(R.id.list_holder, holder) 50 | } 51 | 52 | override fun getItemCount(): Int { 53 | return values.size 54 | } 55 | 56 | fun setData(cheeses: Collection) { 57 | values.addAll(cheeses) 58 | notifyDataSetChanged() 59 | } 60 | 61 | interface Listener { 62 | fun onItemClicked(cheese: Cheese) 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /app/src/main/java/com/commit451/quickactionview/sample/CheeseViewHolder.kt: -------------------------------------------------------------------------------- 1 | package com.commit451.quickactionview.sample 2 | 3 | import android.view.LayoutInflater 4 | import android.view.View 5 | import android.view.ViewGroup 6 | import android.widget.ImageView 7 | import android.widget.TextView 8 | import androidx.recyclerview.widget.RecyclerView 9 | 10 | /** 11 | * The view holder related to each Cheese item 12 | */ 13 | class CheeseViewHolder(view: View) : RecyclerView.ViewHolder(view) { 14 | 15 | companion object { 16 | 17 | fun newInstance(parent: ViewGroup): CheeseViewHolder { 18 | val view = LayoutInflater.from(parent.context) 19 | .inflate(R.layout.item_cheese, parent, false) 20 | return CheeseViewHolder(view) 21 | } 22 | } 23 | 24 | private val image: ImageView = view.findViewById(R.id.image) 25 | private val title: TextView = view.findViewById(R.id.name) 26 | 27 | fun bind(cheese: Cheese) { 28 | image.setImageResource(cheese.drawable) 29 | title.text = cheese.name 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/commit451/quickactionview/sample/Cheeses.kt: -------------------------------------------------------------------------------- 1 | package com.commit451.quickactionview.sample 2 | 3 | import java.util.Random 4 | 5 | object Cheeses { 6 | 7 | private val RANDOM = Random() 8 | 9 | private fun randomCheeseDrawable(): Int { 10 | return when (RANDOM.nextInt(5)) { 11 | 0 -> R.drawable.cheese_1 12 | 1 -> R.drawable.cheese_2 13 | 2 -> R.drawable.cheese_3 14 | 3 -> R.drawable.cheese_4 15 | 4 -> R.drawable.cheese_5 16 | else -> R.drawable.cheese_1 17 | } 18 | } 19 | 20 | private val cheeseStrings = arrayOf("Abbaye de Belloc", "Abbaye du Mont des Cats", "Abertam", "Abondance", "Ackawi", "Acorn", "Adelost", "Affidelice au Chablis", "Afuega'l Pitu", "Airag", "Airedale", "Aisy Cendre", "Allgauer Emmentaler", "Alverca", "Ambert", "American Cheese", "Ami du Chambertin", "Anejo Enchilado", "Anneau du Vic-Bilh", "Anthoriro", "Appenzell", "Aragon", "Ardi Gasna", "Ardrahan", "Armenian String", "Aromes au Gene de Marc", "Asadero", "Asiago", "Aubisque Pyrenees", "Autun", "Avaxtskyr", "Baby Swiss", "Babybel", "Baguette Laonnaise", "Bakers", "Baladi", "Balaton", "Bandal", "Banon", "Barry's Bay Cheddar", "Basing", "Basket Cheese", "Bath Cheese", "Bavarian Bergkase", "Baylough", "Beaufort", "Beauvoorde", "Beenleigh Blue", "Beer Cheese", "Bel Paese", "Bergader", "Bergere Bleue", "Berkswell", "Beyaz Peynir", "Bierkase", "Bishop Kennedy", "Blarney", "Bleu d'Auvergne", "Bleu de Gex", "Bleu de Laqueuille", "Bleu de Septmoncel", "Bleu Des Causses", "Blue", "Blue Castello", "Blue Rathgore", "Blue Vein (Australian)", "Blue Vein Cheeses", "Bocconcini", "Bocconcini (Australian)", "Boeren Leidenkaas", "Bonchester", "Bosworth", "Bougon", "Boule Du Roves", "Boulette d'Avesnes", "Boursault", "Boursin", "Bouyssou", "Bra", "Braudostur", "Breakfast Cheese", "Brebis du Lavort", "Brebis du Lochois", "Brebis du Puyfaucon", "Bresse Bleu", "Brick", "Brie", "Brie de Meaux", "Brie de Melun", "Brillat-Savarin", "Brin", "Brin d' Amour", "Brin d'Amour", "Brinza (Burduf Brinza)", "Briquette de Brebis", "Briquette du Forez", "Broccio", "Broccio Demi-Affine", "Brousse du Rove", "Bruder Basil", "Brusselae Kaas (Fromage de Bruxelles)", "Bryndza", "Buchette d'Anjou", "Buffalo", "Burgos", "Butte", "Butterkase", "Button (Innes)", "Buxton Blue", "Cabecou", "Caboc", "Cabrales", "Cachaille", "Caciocavallo", "Caciotta", "Caerphilly", "Cairnsmore", "Calenzana", "Cambazola", "Camembert de Normandie", "Canadian Cheddar", "Canestrato", "Cantal", "Caprice des Dieux", "Capricorn Goat", "Capriole Banon", "Carre de l'Est", "Casciotta di Urbino", "Cashel Blue", "Castellano", "Castelleno", "Castelmagno", "Castelo Branco", "Castigliano", "Cathelain", "Celtic Promise", "Cendre d'Olivet", "Cerney", "Chabichou", "Chabichou du Poitou", "Chabis de Gatine", "Chaource", "Charolais", "Chaumes", "Cheddar", "Cheddar Clothbound", "Cheshire", "Chevres", "Chevrotin des Aravis", "Chontaleno", "Civray", "Coeur de Camembert au Calvados", "Coeur de Chevre", "Colby", "Cold Pack", "Comte", "Coolea", "Cooleney", "Coquetdale", "Corleggy", "Cornish Pepper", "Cotherstone", "Cotija", "Cottage Cheese", "Cottage Cheese (Australian)", "Cougar Gold", "Coulommiers", "Coverdale", "Crayeux de Roncq", "Cream Cheese", "Cream Havarti", "Crema Agria", "Crema Mexicana", "Creme Fraiche", "Crescenza", "Croghan", "Crottin de Chavignol", "Crottin du Chavignol", "Crowdie", "Crowley", "Cuajada", "Curd", "Cure Nantais", "Curworthy", "Cwmtawe Pecorino", "Cypress Grove Chevre", "Danablu (Danish Blue)", "Danbo", "Danish Fontina", "Daralagjazsky", "Dauphin", "Delice des Fiouves", "Denhany Dorset Drum", "Derby", "Dessertnyj Belyj", "Devon Blue", "Devon Garland", "Dolcelatte", "Doolin", "Doppelrhamstufel", "Dorset Blue Vinney", "Double Gloucester", "Double Worcester", "Dreux a la Feuille", "Dry Jack", "Duddleswell", "Dunbarra", "Dunlop", "Dunsyre Blue", "Duroblando", "Durrus", "Dutch Mimolette (Commissiekaas)", "Edam", "Edelpilz", "Emental Grand Cru", "Emlett", "Emmental", "Epoisses de Bourgogne", "Esbareich", "Esrom", "Etorki", "Evansdale Farmhouse Brie", "Evora De L'Alentejo", "Exmoor Blue", "Explorateur", "Feta", "Feta (Australian)", "Figue", "Filetta", "Fin-de-Siecle", "Finlandia Swiss", "Finn", "Fiore Sardo", "Fleur du Maquis", "Flor de Guia", "Flower Marie", "Folded", "Folded cheese with mint", "Fondant de Brebis", "Fontainebleau", "Fontal", "Fontina Val d'Aosta", "Formaggio di capra", "Fougerus", "Four Herb Gouda", "Fourme d' Ambert", "Fourme de Haute Loire", "Fourme de Montbrison", "Fresh Jack", "Fresh Mozzarella", "Fresh Ricotta", "Fresh Truffles", "Fribourgeois", "Friesekaas", "Friesian", "Friesla", "Frinault", "Fromage a Raclette", "Fromage Corse", "Fromage de Montagne de Savoie", "Fromage Frais", "Fruit Cream Cheese", "Frying Cheese", "Fynbo", "Gabriel", "Galette du Paludier", "Galette Lyonnaise", "Galloway Goat's Milk Gems", "Gammelost", "Gaperon a l'Ail", "Garrotxa", "Gastanberra", "Geitost", "Gippsland Blue", "Gjetost", "Gloucester", "Golden Cross", "Gorgonzola", "Gornyaltajski", "Gospel Green", "Gouda", "Goutu", "Gowrie", "Grabetto", "Graddost", "Grafton Village Cheddar", "Grana", "Grana Padano", "Grand Vatel", "Grataron d' Areches", "Gratte-Paille", "Graviera", "Greuilh", "Greve", "Gris de Lille", "Gruyere", "Gubbeen", "Guerbigny", "Halloumi", "Halloumy (Australian)", "Haloumi-Style Cheese", "Harbourne Blue", "Havarti", "Heidi Gruyere", "Hereford Hop", "Herrgardsost", "Herriot Farmhouse", "Herve", "Hipi Iti", "Hubbardston Blue Cow", "Hushallsost", "Iberico", "Idaho Goatster", "Idiazabal", "Il Boschetto al Tartufo", "Ile d'Yeu", "Isle of Mull", "Jarlsberg", "Jermi Tortes", "Jibneh Arabieh", "Jindi Brie", "Jubilee Blue", "Juustoleipa", "Kadchgall", "Kaseri", "Kashta", "Kefalotyri", "Kenafa", "Kernhem", "Kervella Affine", "Kikorangi", "King Island Cape Wickham Brie", "King River Gold", "Klosterkaese", "Knockalara", "Kugelkase", "L'Aveyronnais", "L'Ecir de l'Aubrac", "La Taupiniere", "La Vache Qui Rit", "Laguiole", "Lairobell", "Lajta", "Lanark Blue", "Lancashire", "Langres", "Lappi", "Laruns", "Lavistown", "Le Brin", "Le Fium Orbo", "Le Lacandou", "Le Roule", "Leafield", "Lebbene", "Leerdammer", "Leicester", "Leyden", "Limburger", "Lincolnshire Poacher", "Lingot Saint Bousquet d'Orb", "Liptauer", "Little Rydings", "Livarot", "Llanboidy", "Llanglofan Farmhouse", "Loch Arthur Farmhouse", "Loddiswell Avondale", "Longhorn", "Lou Palou", "Lou Pevre", "Lyonnais", "Maasdam", "Macconais", "Mahoe Aged Gouda", "Mahon", "Malvern", "Mamirolle", "Manchego", "Manouri", "Manur", "Marble Cheddar", "Marbled Cheeses", "Maredsous", "Margotin", "Maribo", "Maroilles", "Mascares", "Mascarpone", "Mascarpone (Australian)", "Mascarpone Torta", "Matocq", "Maytag Blue", "Meira", "Menallack Farmhouse", "Menonita", "Meredith Blue", "Mesost", "Metton (Cancoillotte)", "Meyer Vintage Gouda", "Mihalic Peynir", "Milleens", "Mimolette", "Mine-Gabhar", "Mini Baby Bells", "Mixte", "Molbo", "Monastery Cheeses", "Mondseer", "Mont D'or Lyonnais", "Montasio", "Monterey Jack", "Monterey Jack Dry", "Morbier", "Morbier Cru de Montagne", "Mothais a la Feuille", "Mozzarella", "Mozzarella (Australian)", "Mozzarella di Bufala", "Mozzarella Fresh, in water", "Mozzarella Rolls", "Munster", "Murol", "Mycella", "Myzithra", "Naboulsi", "Nantais", "Neufchatel", "Neufchatel (Australian)", "Niolo", "Nokkelost", "Northumberland", "Oaxaca", "Olde York", "Olivet au Foin", "Olivet Bleu", "Olivet Cendre", "Orkney Extra Mature Cheddar", "Orla", "Oschtjepka", "Ossau Fermier", "Ossau-Iraty", "Oszczypek", "Oxford Blue", "P'tit Berrichon", "Palet de Babligny", "Paneer", "Panela", "Pannerone", "Pant ys Gawn", "Parmesan (Parmigiano)", "Parmigiano Reggiano", "Pas de l'Escalette", "Passendale", "Pasteurized Processed", "Pate de Fromage", "Patefine Fort", "Pave d'Affinois", "Pave d'Auge", "Pave de Chirac", "Pave du Berry", "Pecorino", "Pecorino in Walnut Leaves", "Pecorino Romano", "Peekskill Pyramid", "Pelardon des Cevennes", "Pelardon des Corbieres", "Penamellera", "Penbryn", "Pencarreg", "Perail de Brebis", "Petit Morin", "Petit Pardou", "Petit-Suisse", "Picodon de Chevre", "Picos de Europa", "Piora", "Pithtviers au Foin", "Plateau de Herve", "Plymouth Cheese", "Podhalanski", "Poivre d'Ane", "Polkolbin", "Pont l'Eveque", "Port Nicholson", "Port-Salut", "Postel", "Pouligny-Saint-Pierre", "Pourly", "Prastost", "Pressato", "Prince-Jean", "Processed Cheddar", "Provolone", "Provolone (Australian)", "Pyengana Cheddar", "Pyramide", "Quark", "Quark (Australian)", "Quartirolo Lombardo", "Quatre-Vents", "Quercy Petit", "Queso Blanco", "Queso Blanco con Frutas --Pina y Mango", "Queso de Murcia", "Queso del Montsec", "Queso del Tietar", "Queso Fresco", "Queso Fresco (Adobera)", "Queso Iberico", "Queso Jalapeno", "Queso Majorero", "Queso Media Luna", "Queso Para Frier", "Queso Quesadilla", "Rabacal", "Raclette", "Ragusano", "Raschera", "Reblochon", "Red Leicester", "Regal de la Dombes", "Reggianito", "Remedou", "Requeson", "Richelieu", "Ricotta", "Ricotta (Australian)", "Ricotta Salata", "Ridder", "Rigotte", "Rocamadour", "Rollot", "Romano", "Romans Part Dieu", "Roncal", "Roquefort", "Roule", "Rouleau De Beaulieu", "Royalp Tilsit", "Rubens", "Rustinu", "Saaland Pfarr", "Saanenkaese", "Saga", "Sage Derby", "Sainte Maure", "Saint-Marcellin", "Saint-Nectaire", "Saint-Paulin", "Salers", "Samso", "San Simon", "Sancerre", "Sap Sago", "Sardo", "Sardo Egyptian", "Sbrinz", "Scamorza", "Schabzieger", "Schloss", "Selles sur Cher", "Selva", "Serat", "Seriously Strong Cheddar", "Serra da Estrela", "Sharpam", "Shelburne Cheddar", "Shropshire Blue", "Siraz", "Sirene", "Smoked Gouda", "Somerset Brie", "Sonoma Jack", "Sottocenare al Tartufo", "Soumaintrain", "Sourire Lozerien", "Spenwood", "Sraffordshire Organic", "St. Agur Blue Cheese", "Stilton", "Stinking Bishop", "String", "Sussex Slipcote", "Sveciaost", "Swaledale", "Sweet Style Swiss", "Swiss", "Syrian (Armenian String)", "Tala", "Taleggio", "Tamie", "Tasmania Highland Chevre Log", "Taupiniere", "Teifi", "Telemea", "Testouri", "Tete de Moine", "Tetilla", "Texas Goat Cheese", "Tibet", "Tillamook Cheddar", "Tilsit", "Timboon Brie", "Toma", "Tomme Brulee", "Tomme d'Abondance", "Tomme de Chevre", "Tomme de Romans", "Tomme de Savoie", "Tomme des Chouans", "Tommes", "Torta del Casar", "Toscanello", "Touree de L'Aubier", "Tourmalet", "Trappe (Veritable)", "Trois Cornes De Vendee", "Tronchon", "Trou du Cru", "Truffe", "Tupi", "Turunmaa", "Tymsboro", "Tyn Grug", "Tyning", "Ubriaco", "Ulloa", "Vacherin-Fribourgeois", "Valencay", "Vasterbottenost", "Venaco", "Vendomois", "Vieux Corse", "Vignotte", "Vulscombe", "Waimata Farmhouse Blue", "Washed Rind Cheese (Australian)", "Waterloo", "Weichkaese", "Wellington", "Wensleydale", "White Stilton", "Whitestone Farmhouse", "Wigmore", "Woodside Cabecou", "Xanadu", "Xynotyro", "Yarg Cornish", "Yarra Valley Pyramid", "Yorkshire Blue", "Zamorano", "Zanetti Grana Padano", "Zanetti Parmigiano Reggiano") 21 | 22 | private fun randomCheeseName(): String = cheeseStrings[RANDOM.nextInt(cheeseStrings.size - 1)] 23 | 24 | fun randomCheese() = Cheese(randomCheeseDrawable(), randomCheeseName()) 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/commit451/quickactionview/sample/CustomActionsInAnimator.kt: -------------------------------------------------------------------------------- 1 | package com.commit451.quickactionview.sample 2 | 3 | import android.graphics.Point 4 | import android.os.Build 5 | import android.view.View 6 | import android.view.ViewAnimationUtils 7 | import android.view.animation.LinearInterpolator 8 | 9 | import com.commit451.quickactionview.Action 10 | import com.commit451.quickactionview.ActionView 11 | import com.commit451.quickactionview.ActionsInAnimator 12 | import com.commit451.quickactionview.QuickActionView 13 | 14 | /** 15 | * Example of how to create a custom animations in animator 16 | */ 17 | class CustomActionsInAnimator(private val quickActionView: QuickActionView) : ActionsInAnimator { 18 | 19 | private val interpolator = LinearInterpolator() 20 | 21 | override fun animateActionIn(action: Action, index: Int, view: ActionView, center: Point) { 22 | view.animate() 23 | .alpha(1.0f) 24 | .setInterpolator(interpolator) 25 | .setDuration(200) 26 | } 27 | 28 | override fun animateIndicatorIn(indicator: View) { 29 | indicator.alpha = 0f 30 | indicator.animate() 31 | .alpha(1f) 32 | .setDuration(200) 33 | } 34 | 35 | override fun animateScrimIn(scrim: View) { 36 | val center = quickActionView.centerPoint 37 | if (Build.VERSION.SDK_INT >= 21 && center != null) { 38 | ViewAnimationUtils.createCircularReveal(scrim, center.x, center.y, 0f, Math.max(scrim.height, scrim.width).toFloat()) 39 | .start() 40 | } else { 41 | scrim.alpha = 0f 42 | scrim.animate() 43 | .alpha(1f) 44 | .setDuration(200) 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/src/main/java/com/commit451/quickactionview/sample/CustomActionsTitleAnimator.kt: -------------------------------------------------------------------------------- 1 | package com.commit451.quickactionview.sample 2 | 3 | import android.view.View 4 | import android.view.animation.OvershootInterpolator 5 | 6 | import com.commit451.quickactionview.Action 7 | import com.commit451.quickactionview.ActionsTitleInAnimator 8 | import com.commit451.quickactionview.ActionsTitleOutAnimator 9 | 10 | /** 11 | * Default animator which animates the action title in and out 12 | */ 13 | class CustomActionsTitleAnimator : ActionsTitleInAnimator, ActionsTitleOutAnimator { 14 | 15 | companion object { 16 | private const val DURATION = 200L //ms 17 | } 18 | 19 | override fun animateActionTitleIn(action: Action, index: Int, view: View) { 20 | view.alpha = 0.0f 21 | view.scaleX = 0.0f 22 | view.scaleY = 0.0f 23 | view.animate() 24 | .alpha(1.0f) 25 | .scaleX(1.0f) 26 | .scaleY(1.0f) 27 | .setInterpolator(OvershootInterpolator()) 28 | .setDuration(DURATION) 29 | } 30 | 31 | override fun animateActionTitleOut(action: Action, index: Int, view: View): Long { 32 | view.animate() 33 | .alpha(0.0f) 34 | .scaleX(0.0f) 35 | .scaleY(0.0f) 36 | .setDuration(DURATION) 37 | return DURATION 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/java/com/commit451/quickactionview/sample/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.commit451.quickactionview.sample 2 | 3 | import android.annotation.SuppressLint 4 | import android.graphics.Color 5 | import android.os.Bundle 6 | import android.util.Log 7 | import android.view.View 8 | import androidx.appcompat.app.AppCompatActivity 9 | import androidx.appcompat.widget.Toolbar 10 | import androidx.core.content.ContextCompat 11 | import com.commit451.quickactionview.Action 12 | import com.commit451.quickactionview.QuickActionView 13 | import com.commit451.quickactionview.animator.PopAnimator 14 | import com.google.android.material.snackbar.Snackbar 15 | 16 | /** 17 | * Shows general use of the QuickActionView 18 | */ 19 | class MainActivity : AppCompatActivity() { 20 | 21 | companion object { 22 | private const val TAG = "QuickActionView" 23 | } 24 | 25 | private lateinit var root: View 26 | 27 | override fun onCreate(savedInstanceState: Bundle?) { 28 | super.onCreate(savedInstanceState) 29 | setContentView(R.layout.activity_main) 30 | findViewById(R.id.buttonRecyclerview).setOnClickListener { 31 | startActivity( 32 | RecyclerViewActivity.newIntent(this@MainActivity) 33 | ) 34 | } 35 | val toolbar = findViewById(R.id.toolbar) 36 | val normalParent = findViewById(R.id.normalParent) 37 | val customParent = findViewById(R.id.customParent) 38 | root = findViewById(R.id.root) 39 | setSupportActionBar(toolbar) 40 | QuickActionView.make(this) 41 | .addActions(R.menu.actions) 42 | .setOnActionSelectedListener { action, _ -> onAction(action) } 43 | .setOnShowListener { Log.d(TAG, "onShow") } 44 | .setOnDismissListener { Log.d(TAG, "onDismiss") } 45 | .setOnActionHoverChangedListener { _, _, hovering -> Log.d(TAG, "onHover $hovering") } 46 | .register(normalParent) 47 | normalParent.setOnClickListener { 48 | Snackbar.make(root, "View was clicked", Snackbar.LENGTH_SHORT) 49 | .show() 50 | } 51 | 52 | @SuppressLint("ResourceType") 53 | val actionConfig = Action.Config(this) 54 | .setBackgroundColorStateList( 55 | ContextCompat.getColorStateList( 56 | this, 57 | R.drawable.sample_background_color 58 | )!! 59 | ) 60 | .setTextColor(Color.MAGENTA) 61 | 62 | val popAnimator = PopAnimator(true) 63 | val actionTitleAnimator = CustomActionsTitleAnimator() 64 | val qav = QuickActionView.make(this) 65 | .addActions(R.menu.actions_2) 66 | .setOnActionSelectedListener { action, _ -> onAction(action) } 67 | .setBackgroundColor(Color.RED) 68 | .setTextColor(Color.BLUE) 69 | .setTextSize(30) 70 | .setScrimColor(Color.parseColor("#99FFFFFF")) 71 | .setTextBackgroundDrawable(R.drawable.text_background) 72 | .setIndicatorDrawable( 73 | ContextCompat.getDrawable( 74 | this@MainActivity, 75 | R.drawable.indicator 76 | )!! 77 | ) 78 | .setActionConfig(actionConfig, R.id.action_add_to_cart) 79 | .setActionsOutAnimator(popAnimator) 80 | .setActionsTitleInAnimator(actionTitleAnimator) 81 | .setActionsTitleOutAnimator(actionTitleAnimator) 82 | .register(customParent) 83 | val customActionsInAnimator = CustomActionsInAnimator(qav) 84 | qav.setActionsInAnimator(customActionsInAnimator) 85 | } 86 | 87 | private fun onAction(action: Action) { 88 | Snackbar.make(root, action.title.toString() + " was chosen", Snackbar.LENGTH_SHORT) 89 | .show() 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /app/src/main/java/com/commit451/quickactionview/sample/RecyclerViewActivity.kt: -------------------------------------------------------------------------------- 1 | package com.commit451.quickactionview.sample 2 | 3 | import android.content.Context 4 | import android.content.Intent 5 | import android.os.Bundle 6 | import androidx.appcompat.app.AppCompatActivity 7 | import androidx.appcompat.widget.Toolbar 8 | import androidx.recyclerview.widget.RecyclerView 9 | import com.google.android.material.snackbar.Snackbar 10 | 11 | /** 12 | * Shows usage of the QuickActionView from within a RecyclerView 13 | */ 14 | class RecyclerViewActivity : AppCompatActivity() { 15 | 16 | companion object { 17 | fun newIntent(context: Context): Intent { 18 | return Intent(context, RecyclerViewActivity::class.java) 19 | } 20 | } 21 | 22 | private lateinit var adapter: CheeseAdapter 23 | 24 | override fun onCreate(savedInstanceState: Bundle?) { 25 | super.onCreate(savedInstanceState) 26 | setContentView(R.layout.activity_recyclerview) 27 | val toolbar = findViewById(R.id.toolbar) 28 | val recyclerView = findViewById(R.id.recyclerView) 29 | setSupportActionBar(toolbar) 30 | recyclerView.layoutManager = androidx.recyclerview.widget.GridLayoutManager(this, 2) 31 | adapter = CheeseAdapter(this, object : CheeseAdapter.Listener { 32 | override fun onItemClicked(cheese: Cheese) { 33 | Snackbar.make(recyclerView, cheese.name + " was clicked", Snackbar.LENGTH_SHORT) 34 | .show() 35 | } 36 | }) 37 | recyclerView.adapter = adapter 38 | 39 | loadCheeses() 40 | } 41 | 42 | private fun loadCheeses() { 43 | val cheeses = mutableListOf() 44 | for (i in 0..29) { 45 | cheeses.add(Cheeses.randomCheese()) 46 | } 47 | adapter.setData(cheeses) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-nodpi/cheese_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Commit451/QuickActionView/72db4a0037f88bea7bb8f77d37d32f59c0c50365/app/src/main/res/drawable-nodpi/cheese_1.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable-nodpi/cheese_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Commit451/QuickActionView/72db4a0037f88bea7bb8f77d37d32f59c0c50365/app/src/main/res/drawable-nodpi/cheese_2.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable-nodpi/cheese_3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Commit451/QuickActionView/72db4a0037f88bea7bb8f77d37d32f59c0c50365/app/src/main/res/drawable-nodpi/cheese_3.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable-nodpi/cheese_4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Commit451/QuickActionView/72db4a0037f88bea7bb8f77d37d32f59c0c50365/app/src/main/res/drawable-nodpi/cheese_4.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable-nodpi/cheese_5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Commit451/QuickActionView/72db4a0037f88bea7bb8f77d37d32f59c0c50365/app/src/main/res/drawable-nodpi/cheese_5.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_favorite_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_shopping_basket_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_shopping_basket_dark_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_thumb_up_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/indicator.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/sample_background_color.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/sample_changing_icon.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/text_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 15 | 21 | 22 | 23 | 24 | 29 | 30 | 38 | 39 | 48 | 49 |