All Projects → SmartDengg → Click Debounce

SmartDengg / Click Debounce

Licence: mit
Using ASM to handle Android's click debounce, specially a quick double click.

Programming Languages

java
68154 projects - #9 most used programming language
groovy
2714 projects

Projects that are alternatives of or similar to Click Debounce

Laziertracker
本项目通过Android字节码插桩插件实现Android端无埋点(或自动埋点),并且支持根据配置文件实现业务数据的自动采集。
Stars: ✭ 485 (+177.14%)
Mutual labels:  gradle, gradle-plugin, asm, aop
Jaop
jaop is a gradle plugin base on javassist&asm for android aop
Stars: ✭ 115 (-34.29%)
Mutual labels:  gradle-plugin, asm, aop
Bytex
ByteX is a bytecode plugin platform based on Android Gradle Transform API and ASM. 字节码插件开发平台
Stars: ✭ 2,140 (+1122.86%)
Mutual labels:  gradle, gradle-plugin, asm
Koala
从 Java 字节码到 ASM 实践
Stars: ✭ 103 (-41.14%)
Mutual labels:  gradle-plugin, asm, aop
Hunter
A fast, incremental, concurrent framework to develop compile plugin for android project to manipulate bytecode
Stars: ✭ 999 (+470.86%)
Mutual labels:  gradle, gradle-plugin, asm
Androidautotrack
Android Asm 插桩 教学
Stars: ✭ 378 (+116%)
Mutual labels:  gradle, gradle-plugin, asm
Let
Annotation based simple API flavored with AOP to handle new Android runtime permission model
Stars: ✭ 532 (+204%)
Mutual labels:  gradle, gradle-plugin, aop
Androidanimationexercise
Android 动画各种实现,包括帧动画、补间动画和属性动画的总结分享
Stars: ✭ 1,254 (+616.57%)
Mutual labels:  gradle, gradle-plugin, asm
Godot
Keep track of how much time you spend on Gradle builds
Stars: ✭ 113 (-35.43%)
Mutual labels:  gradle, gradle-plugin
Okbuck
OkBuck is a gradle plugin that lets developers utilize the Buck build system on a gradle project.
Stars: ✭ 1,513 (+764.57%)
Mutual labels:  gradle, gradle-plugin
Clojurephant
Clojure and Clojurescript support for Gradle
Stars: ✭ 118 (-32.57%)
Mutual labels:  gradle, gradle-plugin
Audiovideocodec
一款视频录像机,支持AudioRecord录音、MediaCodec输出AAC、MediaMuxer合成音频视频并输出mp4,支持自动对焦、屏幕亮度调节、录制视频时长监听、手势缩放调整焦距等
Stars: ✭ 113 (-35.43%)
Mutual labels:  gradle-plugin, aop
Gradle Build Properties Plugin
Keep your secrets secret. External build properties support for your Gradle scripts.
Stars: ✭ 110 (-37.14%)
Mutual labels:  gradle, gradle-plugin
Jenkins Pipeline Shared Libraries Gradle Plugin
Gradle plugin to help with build and test of Jenkins Pipeline Shared Libraries (see https://jenkins.io/doc/book/pipeline/shared-libraries/)
Stars: ✭ 103 (-41.14%)
Mutual labels:  gradle, gradle-plugin
Jib
🏗 Build container images for your Java applications.
Stars: ✭ 11,370 (+6397.14%)
Mutual labels:  gradle, gradle-plugin
Reckon
Infer a project's version from your Git repository.
Stars: ✭ 124 (-29.14%)
Mutual labels:  gradle, gradle-plugin
Gradle Eclipse Aar Plugin
Gradle plugin to use Android AAR libraries on Eclipse.
Stars: ✭ 127 (-27.43%)
Mutual labels:  gradle, gradle-plugin
Kotlin Gradle Plugin Template
🐘 A template to let you started with custom Gradle Plugins + Kotlin in a few seconds
Stars: ✭ 141 (-19.43%)
Mutual labels:  gradle, gradle-plugin
Gson Plugin
辅助 Gson 库的 gradle 插件,防止 Json 数据解析类型异常。
Stars: ✭ 133 (-24%)
Mutual labels:  gradle, gradle-plugin
Gradle Pitest Plugin
Gradle plugin for PIT Mutation Testing
Stars: ✭ 144 (-17.71%)
Mutual labels:  gradle, gradle-plugin
README.md

click-debounce

Support incremental compilation! Support parallel compilation! Faster compilation speed, and shorter compilation time.

It is a gradle plugin that uses bytecode weaving technology to solve the click jitter problem of Android applications.

For example, a normal onClick method without any debounce plan, multiple quick clicks may trigger multiple Activity starts:

  @Override public void onClick(View v) {
    startActivity(new Intent(MainActivity.this, SecondActivity.class));
  }

modify the bytecode at compile time to:

  @Debounced
  public void onClick(View var1) {
    if (DebouncedPredictor.shouldDoClick(var1)) {
      startActivity(new Intent(this, SecondActivity.class));
    }
  }

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.

I also wrote a BLOG to share my ideas to solve the click jitter.

Note: This repository is just a gradle plugin, responsible for bytecode weaving work. Android runtime library please move here.

Requirements

  • JDK 1.7 +
  • Gradle 3.0.0 +

To build

$ git clone [email protected]:SmartDengg/asm-clickdebounce.git
$ cd asm-clickdebounce/
$ ./gradlew build

Getting Started

Step 1. Add the JitPack repository and the plugin to your buildscript:

buildscript {

    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
    dependencies {
        ...
        classpath 'com.github.SmartDengg.click-debounce:click-debounce-gradle-plugin:2.0.0'
    }
}

Step 2. Apply it in your module:

Supports com.android.application, com.android.library and com.android.feature.

apply plugin: 'smartdengg.clickdebounce'
// or apply plugin: 'clickdebounce'

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 list.

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:

debounce {
  // enable log
  loggable = true
  // java bytecode descriptor: [class: [methods]]
  exclusion = ["com/smartdengg/clickdebounce/ClickProxy": ['onClick(Landroid/view/View;)V',
                                                           'onItemClick(Landroid/widget/AdapterView;Landroid/view/View;IJ)V']]
}

Step 4 (Optional). Set the debounce window time in your Java code(default is 300 milliseconds):

DebouncedPredictor.FROZEN_WINDOW_MILLIS = 400L

Artifact

We output some log files to help developers better understand the build information. These file path is located in buildDir/outputs/debounce/logs//, as follows:

.
+-- app (apply this AGP)
|   +-- build
|       +-- generated
|       +-- intermediates
|       +-- outputs
|           +-- debounce
|               +-- logs
|                   +-- debug
|                       +-- files.txt
|                       +-- classes.txt
+-- build.gradle
+-- gradle.properties
+-- gradlew
+-- gradlew.bat
+-- settings.gradle

  • files.txt :Record the class files consumed by this build,it can help you better understand this build.
  • classes.txt :Record information about the classes and methods woven in this build.

How it works

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.

Support

R8 / ProGuard (Not Required)

Pure bytecode weaving without any reflections. No Proguard rules are required.

Bugs and Feedback

For bugs, feature requests, and discussion please use GitHub Issues. Or send email to [email protected].

Found this project useful

❤️ Hope this article can help you. Support by clicking the ⭐️, or share it with people around you. ❤️

About me

email : [email protected]

blog : 小鄧子

weibo : -小鄧子-

License

See the LICENSE file for license rights and limitations (MIT).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].