{"id":15056571,"url":"https://github.com/smartdengg/click-debounce","last_synced_at":"2025-10-06T07:17:58.864Z","repository":{"id":161581254,"uuid":"126971489","full_name":"SmartDengg/click-debounce","owner":"SmartDengg","description":"Using ASM to handle Android's click debounce, specially a quick double click.","archived":false,"fork":false,"pushed_at":"2021-04-19T14:07:36.000Z","size":342,"stargazers_count":191,"open_issues_count":2,"forks_count":17,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-08-22T03:50:23.092Z","etag":null,"topics":["android","aop","aop-plugin","asm","asm-clickdebounce","gradle","gradle-android-plugin","gradle-plugin","gradleplugin","groovy"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SmartDengg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-27T10:43:15.000Z","updated_at":"2025-04-21T22:32:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"d845b2bc-d3a2-4aeb-a252-2fe7d68fd1a6","html_url":"https://github.com/SmartDengg/click-debounce","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/SmartDengg/click-debounce","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmartDengg%2Fclick-debounce","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmartDengg%2Fclick-debounce/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmartDengg%2Fclick-debounce/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmartDengg%2Fclick-debounce/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SmartDengg","download_url":"https://codeload.github.com/SmartDengg/click-debounce/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmartDengg%2Fclick-debounce/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278572921,"owners_count":26008909,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","aop","aop-plugin","asm","asm-clickdebounce","gradle","gradle-android-plugin","gradle-plugin","gradleplugin","groovy"],"created_at":"2024-09-24T21:53:34.101Z","updated_at":"2025-10-06T07:17:58.818Z","avatar_url":"https://github.com/SmartDengg.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"| README.md |\n|:---|\n\n# click-debounce\n\n[![](https://jitpack.io/v/SmartDengg/asm-clickdebounce.svg)](https://jitpack.io/#SmartDengg/asm-clickdebounce)\n\n**Support incremental compilation! Support parallel compilation! Faster compilation speed, and shorter compilation time.**\n\nIt is a gradle plugin that uses bytecode weaving technology to solve the click jitter problem of Android applications.\n\nFor example, a normal `onClick` method without any debounce plan, multiple quick clicks may trigger multiple Activity starts:\n\n```java\n  @Override public void onClick(View v) {\n    startActivity(new Intent(MainActivity.this, SecondActivity.class));\n  }\n```\n\nmodify the bytecode at compile time to:\n\n```java\n  @Debounced\n  public void onClick(View var1) {\n    if (DebouncedPredictor.shouldDoClick(var1)) {\n      startActivity(new Intent(this, SecondActivity.class));\n    }\n  }\n```\n\n The `@Debounced` annotation indicates that the method has been debounced. The `shouldDoClick(View)` method will determine which are the jitters and which are the correct clicks.\n\nI also wrote a **[BLOG](https://www.jianshu.com/p/28751130c038)** to share my ideas to solve the click jitter.\n\n*Note: This repository is just a gradle plugin, responsible for bytecode weaving work. Android runtime library please move [here](https://github.com/SmartDengg/asm-clickdebounce-runtime).*\n\n\n## Requirements\n\n- JDK 1.7 +\n- Gradle 4.0.0 +\n\n## To build\n\n```bash\n\n$ git clone git@github.com:SmartDengg/asm-clickdebounce.git\n$ cd asm-clickdebounce/\n$ ./gradlew build\n\n```\n\n## Getting Started\n\n**Step 1**. Add the JitPack repository and the plugin to your buildscript:\n\n```groovy\n\nbuildscript {\n\n    repositories {\n        ...\n        maven { url 'https://jitpack.io' }\n    }\n    dependencies {\n        ...\n        classpath 'com.github.SmartDengg.click-debounce:click-debounce-gradle-plugin:2.1.0'\n    }\n}\n\n```\n\n**Step 2**. Apply it in your module:\n\nSupports `com.android.application`, `com.android.library` and `com.android.feature`.\n\n```groovy\n\napply plugin: 'smartdengg.clickdebounce'\n// or apply plugin: 'clickdebounce'\n\n```\n\n**Step 3 (Optional)**. By adding the following code to your `build.gradle` to enable printe the beautiful log or add an exclusive list to indicate which methods do not need to be debounced. By default, the log is not printed, and process all the methods in the [support](#jump) list.\n\n**It is not recommended to manually add @Debounce annotations to methods, you should use the **exclusive** feature that which methods should not be debounced, as follows:**\n\n```groovy\n\ndebounce {\n  // enable log\n  loggable = true\n  // java bytecode descriptor: [class: [methods]]\n  exclusion = [\"com/smartdengg/clickdebounce/ClickProxy\": ['onClick(Landroid/view/View;)V',\n                                                           'onItemClick(Landroid/widget/AdapterView;Landroid/view/View;IJ)V']]\n}\n\n```\n\n\n**Step 4 (Optional)**. Set the debounce window time in your Java code(default is 300 milliseconds):\n\n```java\n\nDebouncedPredictor.FROZEN_WINDOW_MILLIS = 400L\n\n```\n\n## Artifact\n\nWe output some log files to help developers better understand the build information.\nThese file path is located in **buildDir/outputs/debounce/logs/\u003cvariant\u003e/**, as follows:\n\n\n```\n.\n+-- app (apply this AGP)\n|   +-- build\n|       +-- generated\n|       +-- intermediates\n|       +-- outputs\n|           +-- debounce\n|               +-- logs\n|                   +-- debug\n|                       +-- files.txt\n|                       +-- classes.txt\n+-- build.gradle\n+-- gradle.properties\n+-- gradlew\n+-- gradlew.bat\n+-- settings.gradle\n\n```\n\n- **files.txt** ：Record the class files consumed by this build，it can help you better understand this build.\n- **classes.txt** ：Record information about the classes and methods woven in this build.\n\n\n## How it works\n\n**Will not intercept the touch event delivery, only intercepted in the callback of the click event, so that it will not be passed to the business logic.**\n\n![](art/clickdebounce.png)\n\n## \u003cspan id=\"jump\"\u003eSupport\u003c/span\u003e\n\n- [x] [View.OnClickListener](https://developer.android.com/reference/android/view/View.OnClickListener)\n- [x] [AdapterView.OnItemClickListener](https://developer.android.com/reference/android/widget/AdapterView.OnItemClickListener)\n\n## R8 / ProGuard (Not Required)\n\nPure bytecode weaving without any reflections. No Proguard rules are required.\n\n## Bugs and Feedback\n\nFor bugs, feature requests, and discussion please use [GitHub Issues](https://github.com/SmartDengg/asm-clickdebounce/issues). Or send email to hi4joker@gmail.com.\n\n\n## Found this project useful\n\n\u003cp align=\"center\"\u003e:heart: Hope this article can help you. Support by clicking the :star:, or share it with people around you. :heart:  \u003c/p\u003e\n\n\n## About me\n\nemail : hi4joker@gmail.com\n\nblog  : [小鄧子](https://www.jianshu.com/u/df40282480b4)\n\nweibo : [-小鄧子-](https://weibo.com/5367097592/profile?topnav=1\u0026wvr=6)\n\n\n## License\n\nSee the [LICENSE](LICENSE) file for license rights and limitations (MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartdengg%2Fclick-debounce","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmartdengg%2Fclick-debounce","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartdengg%2Fclick-debounce/lists"}