👏 The Medium's Clapping Effect developed in Android

Last update: May 12, 2022

👏 MediumClap-Android

Download Build status Android Arsenal Say Thanks! Twitter

Built with ❤︎ by Wajahat Karim and contributors

A Custom Floating Action Button (FAB) library like clapping effect on Medium

📄 How-To Article

✔️ Changelog

Changes exist in the releases tab.

💻 Installation

Add this in your app's build.gradle file:

dependencies {
  implementation 'com.wajahatkarim3.clapfab:clapfab:1.0.6'
}

Or add ClapFab as a new dependency inside your pom.xml

<dependency>
  <groupId>com.wajahatkarim3.clapfab</groupId>
  <artifactId>clapfab</artifactId>
  <version>1.0.6</version>
  <type>pom</type>
</dependency>

Usage

<com.wajahatkarim3.clapfab.ClapFAB
        android:id="@+id/clapFAB"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginTop="8dp"
        app:cf_count_circle_color="@color/colorAccent"
        app:cf_count_text_color="@color/white_color"
        app:cf_default_icon="@drawable/ic_star_border_black_24dp"
        app:cf_default_icon_color="@color/colorAccent"
        app:cf_dots_1_color="@android:color/holo_green_dark"
        app:cf_dots_2_color="@color/colorAccent"
        app:cf_filled_icon="@drawable/ic_star_black_24dp"
        app:cf_filled_icon_color="@color/colorAccent"
        app:cf_max_clap_count="20"
        app:cf_clap_count="10"                           
        app:cf_format_clap_count="true"
        app:cf_long_press_enabled="false"
        app:cf_long_press_clap_interval="300"/>

🎨 Customization and Attributes

All customizable attributes for ClapFab

Attribute Name Default Value Description
app:cf_default_icon @drawable/ic_clap_hands_outline The default icon of the ClapFab button
app:cf_filled_icon @drawable/ic_clap_hands_filled The filled icon after clapping of the ClapFab button
app:cf_default_icon_color @color/colorClapIcon The color of default icon of the ClapFab button
app:cf_filled_icon_color @color/colorClapIcon The filled color of icon after clapping of the ClapFab button
app:cf_max_clap_count 50 The maximum count of clapping of the ClapFab button
app:cf_count_circle_color @color/colorClapIcon The color of count's circle background
app:cf_count_text_color @android:color/white The color of count's circle text
app:cf_dots_1_color @color/dotsColor1 The color of particle's dots 1
app:cf_dots_2_color @color/dotsColor2 The color of particle's dots 2
app:cf_clap_count 0 The default clap count
app:cf_format_clap_count true True, if the formatter for clap count is enabled. Formatter will convert 1000 to 1.0K etc.
app:cf_long_press_enabled true The flag to turn on/off the long press auto-clap ability. Default is true.
app:cf_long_press_clap_interval 300 The interval to automatically clap on long press in milliseconds. Default is 300ms

Clap Listener

ClapFAB clapFAB = (ClapFAB) findViewById(R.id.clapFAB);
clapFAB.setClapListener(new ClapFAB.OnClapListener() {
            @Override
            public void onFabClapped(@NotNull ClapFAB clapFab, int count, boolean isMaxReached) {
                // count is the current count of the clapping
                // isMaxReached is true when button has already reached the maximum count 
                // and is not being clapped anymore. Otherwise its false
            }
        });

📃 Libraries Used

💥 Achievements

💰 Donations

This project needs you! If you would like to support this project's further development, the creator of this project or the continuous maintenance of this project, feel free to donate. Your donation is highly appreciated (and I love food, coffee and beer). Thank you!

PayPal

  • Donate $5: Thank's for creating this project, here's a tea (or some juice) for you!
  • Donate $10: Wow, I am stunned. Let me take you to the movies!
  • Donate $15: I really appreciate your work, let's grab some lunch!
  • Donate $25: That's some awesome stuff you did right there, dinner is on me!
  • Donate $50: I really really want to support this project, great job!
  • Donate $100: You are the man! This project saved me hours (if not days) of struggle and hard work, simply awesome!
  • Donate $2799: Go buddy, buy Macbook Pro for yourself!

Of course, you can also choose what you want to donate, all donations are awesome!

👨 Developed By

Wajahat Karim

👍 How to Contribute

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

📃 License

Copyright 2018 Wajahat Karim

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

GitHub

https://github.com/wajahatkarim3/MediumClap-Android
Comments
  • 1. Remove Bottom Space

    Is it possible to remove extra space from the bottom? I want to set Clap Fab at the bottom-end, just like normal FAB. But it leaves so to much space at the bottom.

    I have just checked that in clap_fab_layout file, parent layout(RelativeLayout) height is set as "match_parent". Can it be set to "wrap_content"?

    Reviewed by Dhaval2404 at 2018-10-01 05:20
  • 2. Not able to set Clap Count

    I am trying to set a default value for clap count when i enter an activity. I saw a attribute named app:cf_format_clap_count="false" in the sample app but i didn't find it. Can you help me out.

    Reviewed by poonam-parth-zz at 2018-10-11 13:28
  • 3. Error inflating class com.wajahatkarim3.clapfab.ClapFAB

    android.view.InflateException: Binary XML file line #144: Binary XML file line #144: Error inflating class com.wajahatkarim3.clapfab.ClapFAB Caused by: android.view.InflateException: Binary XML file line #144: Error inflating class com.wajahatkarim3.clapfab.ClapFAB Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance0(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:334) at android.view.LayoutInflater.createView(LayoutInflater.java:647) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730) at android.view.LayoutInflater.rInflate(LayoutInflater.java:863) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.rInflate(LayoutInflater.java:866) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.rInflate(LayoutInflater.java:866) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.inflate(LayoutInflater.java:515) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) at com.firebase.ui.database.FirebaseRecyclerAdapter.onCreateViewHolder(FirebaseRecyclerAdapter.java:142) at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6685) at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5869) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5752) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5748) at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2232) at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1559) at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1519) at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:614) at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3812) at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3529) at android.support.v7.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1767) at android.support.v7.widget.RecyclerView$1.run(RecyclerView.java:356) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911) at android.view.Choreographer.doCallbacks(Choreographer.java:723) at android.view.Choreographer.doFrame(Choreographer.java:655) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897) at android.os.Handler.handleCallback(Handler.java:789) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6944) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374) Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/jvm/internal/Intrinsics; at com.wajahatkarim3.clapfab.ClapFAB.(Unknown Source:2) at com.wajahatkarim3.clapfab.ClapFAB.(ClapFAB.kt:29) at com.wajahatkarim3.clapfab.ClapFAB.(Unknown Source:6) at java.lang.reflect.Constructor.newInstance0(Native Method)  at java.lang.reflect.Constructor.newInstance(Constructor.java:334)  at android.view.LayoutInflater.createView(LayoutInflater.java:647)  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)  at android.view.LayoutInflater.inflate(LayoutInflater.java:515)  at android.view.LayoutInflater.inflate(LayoutInflater.java:423)  at com.firebase.ui.database.FirebaseRecyclerAdapter.onCreateViewHolder(FirebaseRecyclerAdapter.java:142)  at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6685)  at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5869)  at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5752)  at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5748)  at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2232)  at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1559)  at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1519)  at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:614)  at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3812)  at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3529)  at android.support.v7.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1767)  at android.support.v7.widget.RecyclerView$1.run(RecyclerView.java:356)  at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)  at android.view.Choreographer.doCallbacks(Choreographer.java:723)  at android.view.Choreographer.doFrame(Choreographer.java:655)  at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)  at android.os.Handler.handleCallback(Handler.java:789)  at android.os.Handler.dispatchMessage(Handler.java:98)  at android.os.Looper.loop(Looper.java:164)  at android.app.ActivityThread.main(ActivityThread.java:6944)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)  Caused by: java.lang.ClassNotFoundException: Didn't find class "kotlin.jvm.internal.Intrinsics" on path: DexPathList[[zip file "/data/app/com.example.haran.agritec-kbenzmn95J2zIA32GnOgSg==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.haran.agritec-kbenzmn95J2zIA32GnOgSg==/lib/arm64, /system/lib64, /system/vendor/lib64]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93) at java.lang.ClassLoader.loadClass(ClassLoader.java:379) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) ... 40 more

    Reviewed by haran19 at 2019-01-24 12:20
  • 4. Min sdk issue

    I usually develop apps that support a min sdk of android 19 or more. but with this library , i am getting this error :

    Manifest merger failed : uses-sdk:minSdkVersion 19 cannot be smaller than version 21 declared in library [com.wajahatkarim3.clapfab:clapfab:1.0.0] /home/ansh/.gradle/caches/transforms-1/files-1.1/clapfab-1.0.0.aar/cef15d991f4d09309c4549797c3b0b68/AndroidManifest.xml as the library might be using APIs not available in 19
    	Suggestion: use a compatible library with a minSdk of at most 19,
    		or increase this project's minSdk version to at least 21,
    		or use tools:overrideLibrary="com.wajahatkarim3.clapfab" to force usage (may lead to runtime failures)
    
    

    Can you please look into it and provide a backward compatible solution, if possible?

    Reviewed by root-ansh at 2018-08-08 12:19
  • 5. misc: dismiss kotlin.reflect and clean the code

    • Dismissed using kotlin.reflect since it was just used for getting the class name
    • Removed unused import statements
    • Use @JvmOverloads to make the constructor looks more easier.

    Hi @wajahatkarim3 Thanks for your this great and helpful View. Currently I cannot use your View since you are using kotlin.reflec that I don't want to use. I made some changes you can totally off for that and I wish you can consider to merge it and deploy it. I will like to use it :)

    Reviewed by lekaha at 2018-07-13 00:54
  • 6. Fixes issue #19 of adding long press clap feature

    This pull request fixes issue #19 of adding long press clap feature. Two new attributes has been added in the ClapFAB for long press clap feature.

    app:cf_long_press_enabled="false"
    app:cf_long_press_clap_interval="300"
    
    Reviewed by wajahatkarim3 at 2018-11-05 12:17
  • 7. Added option to set default clap count and format clap count

    Change Log:

    • Added option to set default clap count. It will be very helpful to set clap count from the rest API response.
    To set clap count from xml:
        app:cf_clap_count="10"
    To set clap count programatically:
         clapFAB.setClapCount(10)
    
    • Added option to format clap count(Will be helpful when count increase beyond 999). Formatter will be enabled by default.
    To enable/disable formatter:
        app:cf_format_clap_count="true"
        app:cf_format_clap_count="false"
    
    Reviewed by Dhaval2404 at 2018-10-04 12:38
  • 8. Decrease size of ClapFAB to set margins

    Adds some code to decrease the size of ClapFAB from match_parent to 200dp. This allows to set custom margins on ClapFAB in layouts. Also, it fixes issue #10 almost.

    Reviewed by wajahatkarim3 at 2018-10-01 12:21
  • 9. Take last count value

    Hi, amazing library.

    I have a usecase where I need to send count value to the server but I dont want to it on every click. Is there any way so that if user clicks rapidly it should wait for lets say 1000 milliseconds after last click then hit the api?

    Thanks.

    Reviewed by Shrikant-B at 2020-11-27 09:29
  • 10. InflateException

    android.view.InflateException: Binary XML file line #21: Binary XML file line #21: Error inflating class com.wajahatkarim3.clapfab.ClapFAB Caused by: android.view.InflateException: Binary XML file line #21: Error inflating class com.wajahatkarim3.clapfab.ClapFAB Caused by: java.lang.reflect.InvocationTargetException

    Reviewed by vyapariapp at 2019-01-26 15:53
  • 11. Facing crash

    I am trying to use the library and facing this crash. Any reason why?

    Process: com.sharesmile.share, PID: 4231 java.lang.NoClassDefFoundError: Failed resolution of: Lcom/github/florent37/viewanimator/ViewAnimator; at com.wajahatkarim3.clapfab.ClapFAB.fabScaleUpAnimation(ClapFAB.kt:337) at com.wajahatkarim3.clapfab.ClapFAB.playActualFabAnim(ClapFAB.kt:308) at com.wajahatkarim3.clapfab.ClapFAB.access$playActualFabAnim(ClapFAB.kt:28) at com.wajahatkarim3.clapfab.ClapFAB$init$$inlined$let$lambda$1.onClick(ClapFAB.kt:155) at android.view.View.performClick(View.java:6294) at android.view.View$PerformClick.run(View.java:24774) at android.os.Handler.handleCallback(Handler.java:790) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6501) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.github.florent37.viewanimator.ViewAnimator" on path: DexPathList[[zip file "/data/app/com.sharesmile.share-Mvi7Cz-U1RVPpWEjgqZdAw==/base.apk"],nativeLibraryDirectories=[/data/app/com.sharesmile.share-Mvi7Cz-U1RVPpWEjgqZdAw==/lib/arm64, /system/lib64, /vendor/lib64]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125) at java.lang.ClassLoader.loadClass(ClassLoader.java:379) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) at com.wajahatkarim3.clapfab.ClapFAB.fabScaleUpAnimation(ClapFAB.kt:337)  at com.wajahatkarim3.clapfab.ClapFAB.playActualFabAnim(ClapFAB.kt:308)  at com.wajahatkarim3.clapfab.ClapFAB.access$playActualFabAnim(ClapFAB.kt:28)  at com.wajahatkarim3.clapfab.ClapFAB$init$$inlined$let$lambda$1.onClick(ClapFAB.kt:155)  at android.view.View.performClick(View.java:6294)  at android.view.View$PerformClick.run(View.java:24774)  at android.os.Handler.handleCallback(Handler.java:790)  at android.os.Handler.dispatchMessage(Handler.java:99)  at android.os.Looper.loop(Looper.java:164)  at android.app.ActivityThread.main(ActivityThread.java:6501)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 

    Reviewed by parthanjaria at 2019-01-12 06:49
Android Circular Progress Button
Android Circular Progress Button

?? Before using this library, read information below ?? This library is not more supported. If you want to add new feature or fix a bug, grab source

Jun 21, 2022
Android Buttons With Built-in Progress Meters.
Android Buttons With Built-in Progress Meters.

Description Android Buttons With Built-in Progress Meters. Wiki Home Screenshots User Guide Integration The lib is available on Maven Central, you can

Jun 22, 2022
Circle button widget for Android

DEPRECATED This library is deprecated and no new development is taking place. Consider using a FAB(Floating action button) instead. E.g. the Android D

Jun 22, 2022
FButton - a flat button library for Android
FButton - a flat button library for Android

FButton FButton is a custom Button of Android with "Flat UI" concept. FButton's design get inspiration from designmono. This library is very small and

Jun 20, 2022
Android button which moves in eight direction.
Android button which moves in eight direction.

Moving Button Android button which moves in eight direction. Preview Sample Demo You can download demo movie file here : demo.mov It's also on Youtube

Feb 15, 2022
Button for android with animations for transition and error states.
Button for android with animations for transition and error states.

Transition Button Android Preview Expand animation: Shake animation: Installation Gradle dependencies { implementation 'com.royrodriguez:transitionbu

Jun 15, 2022
AwesomeSwitch is a replacement for the standard Switch(View) android offers, and it offers much more customization than the standard switch component.
AwesomeSwitch is a replacement for the standard Switch(View) android offers, and it offers much more customization than the standard switch component.

AwesomeSwitch AwesomeSwitch is a replacement for the standard Switch(View) android offers, and it offers much more customization than the standard swi

Jun 2, 2022
[] Android floating action button
[] Android floating action button

DEPRECATED Use the FloatingActionButton from the support library instead. FloatingActionButton Description Android floating action button which reacts

Jun 8, 2022
Floating Action Button for Android based on Material Design specification
Floating Action Button for Android based on Material Design specification

FloatingActionButton Yet another library for drawing Material Design promoted actions. Features Support for normal 56dp and mini 40dp buttons. Customi

Jun 22, 2022
Bootstrap style widgets for Android, with Glyph Icons
Bootstrap style widgets for Android, with Glyph Icons

Android-Bootstrap Android Bootstrap is an Android library which provides custom views styled according to the Twitter Bootstrap Specification. This al

Jun 15, 2022
ToggleButton Widget For Android Dev
ToggleButton Widget For Android Dev

ToggleButton ToggleButton Widget For Android Developers @Deprecated !!!项目已经停止维护,新项目移至https://github.com/zcweng/SwitchButton !!! How To Use xml

Jun 15, 2022
Icons, Borders, Radius ... for Android buttons
Icons, Borders, Radius ... for Android buttons

⚠️ This library was made years ago when it wasn't that easy to customize Android buttons like today. I highly recommend you to use Material Design but

Jun 9, 2022
Android Floating ActionButton with a progress indicator ring
Android Floating ActionButton with a progress indicator ring

FabProgress Android Circular floating action button with intergrated progress indicator ring As per material design docs Demo: Demo apk HOW TO ADD TO

Jun 5, 2022
[] An Android library for an expandable button menu
[] An Android library for an expandable button menu

ExpandableButtonMenu ExpandableButtonMenu is an Android library which implements an expandable button that can be used as a substitute of a fixed size

Aug 16, 2021
SwitchButton 是 Android 上的一个开关按钮控件 【Deprecated】【Stop maintenance】
SwitchButton 是 Android 上的一个开关按钮控件 【Deprecated】【Stop maintenance】

SwitchButton 【Deprecated】【Stop maintenance】停止维护了,推荐使用:https://github.com/zcweng/SwitchButton SwitchButton 是 Android 上的一个开关按钮控件 示例 APP 扫描二维码或点我下载 特性 支持

Feb 18, 2022
This is a UI lib for Android. Effects like shining.
This is a UI lib for Android. Effects like shining.

ShineButton This is a UI lib for Android. Effects like shining. Usage shineButton = (ShineButton) findViewById(R.id.shine_button); shineButton.init(

Jun 21, 2022
A lightweight iOS switch view style for Android
A lightweight iOS switch view style for Android

iOS-SwitchView A lightweight iOS switch view style for Android Usage Add SwitchView into xml layout <vn.luongvo.widget.iosswitchview.SwitchView an

Jun 20, 2022
SegmentedController is an Android UI library for using customizable RadioGroup with RadioButtons.
SegmentedController is an Android UI library for using customizable RadioGroup with RadioButtons.

SegmentedController is an Android UI library for using customizable RadioGroup with RadioButtons.

Jan 1, 2022
Android library providing an implementation of the Material Design Floating Action Button Speed Dial.
Android library providing an implementation of the Material Design Floating Action Button Speed Dial.

Android library providing an implementation of the Material Design Floating Action Button Speed Dial.

Apr 21, 2022