Skip to content

Commit

Permalink
V3.0.0首次提交
Browse files Browse the repository at this point in the history
  • Loading branch information
liys666666 committed Nov 23, 2019
1 parent e3578e7 commit 7544262
Show file tree
Hide file tree
Showing 33 changed files with 646 additions and 612 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 42 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
# DoubleClick
V2.0 的使用方法:
V3.0 的使用方法:

简书: https://www.jianshu.com/p/df0ef3866cc1
CSDN: https://blog.csdn.net/qq_33199629/article/details/101563232

**简单介绍:**
**1.导入:**
```
//项目根目录下,build.gradle
buildscript {
...
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:2.0.0' //添加
}
}
allprojects {
repositories {
...
Expand All @@ -16,23 +22,26 @@ allprojects {
```
```
//app目录下build.gradle
apply plugin: 'android-aspectjx' //添加
dependencies {
implementation 'com.github.liys666666:DoubleClick:V2.0.6' //添加
}
```
如果不需要额外处理的话, 到这里就结束了, 同一个按钮点击, 默认最小间隔时间是500毫秒.

**2.添加自定义属性:**
```
public class AppApplication extends Application{
@Override
public void onCreate() {
super.onCreate();
// ViewDoubleHelper.init(this); //默认时间:1秒
// ViewDoubleHelper.init(this, 500); //自定义点击间隔时间(单位:毫秒)
ViewDoubleHelper.init(this, 1000, UnifiedDoubleClick.class); //自定义点击间隔时间(单位:毫秒)
//单独设置, 不同的AnnotationClass可叠加(V2.0.5版本后可用)
ViewDoubleHelper.addAnnotationClass(UnifiedDoubleClick2.class);
DoubleClickHelper
.getInstance()
.delayTime(500) //间隔时间
.addAnnotationClass(UnifiedDoubleClick.class) //自定义属性, 可叠加
.addAnnotationClass(UnifiedDoubleClick2.class);
}
}
```
Expand Down Expand Up @@ -60,43 +69,48 @@ public interface UnifiedDoubleClick{ //用户自定义接口
}
```


```
public class LoginClickListener extends BaseClickListener{
public class LoginClickListener implements IOnClickListener {
public static boolean isLogin = false; //模拟是否登陆
public static boolean isLogin = false;
@Override
public boolean isNext(View v) {
//判断登录逻辑 (onClick前执行)
return isLogin; //true继续执行onClick, false不再执行
//判断登录逻辑
if(!isLogin){
LogUtil.d("未登录");
Toast.makeText(v.getContext(), "未登录", Toast.LENGTH_SHORT).show();
}
return isLogin;
}
@Override
public void after(View view) {
//onClick后 执行
//执行click后
}
}
```

**扩展---可调用方法**
```
//hook单个view(子View不会跟着变化) 例如: Recyclerview使用的话, itemView是不起作用的
ViewDoubleHelper.hookView(View view, long delayTime);
hook单个view(所有子View会跟着一起变化) 例如: Recyclerview使用的话, itemView以及子控件全部有用
ViewDoubleHelper.hookChildViews(View view, long delayTime);
//重新hook当前Activity
ViewDoubleHelper.hookActivity();
DoubleClickHelper.openAll(); //开启
DoubleClickHelper.closeAll(); //关闭
//如果你有更好的实现方法, 也可以自己实现
ViewDoubleHelper.addIViewDoubleClick(IViewDoubleClick iViewDoubleClick);
//(可选)用hook方式处理单个view, 时间会和上面的时间叠加, 一般是处理: Activity只有个别按钮需要doubleClick
DoubleClickHelper.hookView(View view, long delayTime);
```


# 三.历史版本:
**V3.0.0:**
使用AOP的方式处理, 使用方式和2.0基本一样, 比2.0的方式性能更好.



**V2.0.6:**
* 修复:
* ViewDoubleHelper.hookChildViews() 不起作用
Expand All @@ -120,6 +134,7 @@ ViewDoubleHelper.addIViewDoubleClick(IViewDoubleClick iViewDoubleClick);
* 2. 是否屏蔽hook、单个View处理, 自定义拦截器,全部使用接口注解处理.
* 3. 单个View处理、自定义拦截器,兼容Fragment.

[V2.0版本](https://github.com/liys666666/DoubleClick/blob/master/README2.0.6.md)
[V1.0版本](https://github.com/liys666666/DoubleClick/blob/master/README1.0.4.md)

* 如果框架中存在不足或者有什么建议, 欢迎指出, 我这边会尽快处理, 让框架更完善, 希望这个框架能帮助更多人, 如果觉得好用, 欢迎star.
Expand Down
126 changes: 126 additions & 0 deletions README2.0.6.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# DoubleClick
V2.0 的使用方法:

简书: https://www.jianshu.com/p/df0ef3866cc1
CSDN: https://blog.csdn.net/qq_33199629/article/details/101563232

**简单介绍:**
```
//项目根目录下,build.gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' } //添加
}
}
```
```
//app目录下build.gradle
dependencies {
implementation 'com.github.liys666666:DoubleClick:V2.0.6' //添加
}
```
```
public class AppApplication extends Application{
@Override
public void onCreate() {
super.onCreate();
// ViewDoubleHelper.init(this); //默认时间:1秒
// ViewDoubleHelper.init(this, 500); //自定义点击间隔时间(单位:毫秒)
ViewDoubleHelper.init(this, 1000, UnifiedDoubleClick.class); //自定义点击间隔时间(单位:毫秒)
//单独设置, 不同的AnnotationClass可叠加(V2.0.5版本后可用)
ViewDoubleHelper.addAnnotationClass(UnifiedDoubleClick2.class);
}
}
```

```
public interface UnifiedDoubleClick{ //用户自定义接口
// >>>>>>>>>>>>>>>>>>>屏蔽DoubleClick的Activity>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// @ACancelActivity(activitys = {
// MainActivity.class,
// })
// void cancelActivity();
// >>>>>>>>>>>>>>>>>>>单个view处理>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@AAddDoubleClick(activity = MainActivity.class,
addIds = {R.id.btn1, R.id.btn2},
times = {0, 2000}) //点击的间隔时间
void mainActivity();
// >>>>>>>>>>>>>>>>>插入自定义clickListener>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@AClickListener(activity = MainActivity.class,
lisenner = LoginClickListener.class, //自定义clickListener
ids = {R.id.btn2})
void interceptMain();
}
```

```
public class LoginClickListener extends BaseClickListener{
public static boolean isLogin = false; //模拟是否登陆
@Override
public boolean isNext(View v) {
//判断登录逻辑 (onClick前执行)
return isLogin; //true继续执行onClick, false不再执行
}
@Override
public void after(View view) {
//onClick后 执行
}
}
```

**扩展---可调用方法**
```
//hook单个view(子View不会跟着变化) 例如: Recyclerview使用的话, itemView是不起作用的
ViewDoubleHelper.hookView(View view, long delayTime);
hook单个view(所有子View会跟着一起变化) 例如: Recyclerview使用的话, itemView以及子控件全部有用
ViewDoubleHelper.hookChildViews(View view, long delayTime);
//重新hook当前Activity
ViewDoubleHelper.hookActivity();
//如果你有更好的实现方法, 也可以自己实现
ViewDoubleHelper.addIViewDoubleClick(IViewDoubleClick iHookView);
```


# 三.历史版本:
**V2.0.6:**
* 修复:
* ViewDoubleHelper.hookChildViews() 不起作用
* ViewDoubleHelper.hookActivity()在onResume()前 调用不起作用.

**V2.0.5:**
* 优化: 问题描述:原来的注解只能在Application初始化时传一个类进去;
* 问题1: 如果注解使用过多, 所有的注解都写在一个类里面, 不好管理.
* 问题2: 在组件化架构中, 有个id无法在Application中获取.
* 解决办法: 使用新增方法 ViewDoubleHelper.addAnnotationClass(annotationClass); 可设置多个

**V2.0.4:**
* 修复: 动态加载View不起作用(包括自定义View, Fragment, RecyclerView中不起作用等等)。

**V2.0.2:**
* 1. 修复兼容问题:注解android9.0不起作用.
* 2. 手动重新hookActivity

**V2.0.1:**
* 1. 完全不需要在具体的Activity和Fragment加代码.
* 2. 是否屏蔽hook、单个View处理, 自定义拦截器,全部使用接口注解处理.
* 3. 单个View处理、自定义拦截器,兼容Fragment.

[V1.0版本](https://github.com/liys666666/DoubleClick/blob/master/README1.0.4.md)

* 如果框架中存在不足或者有什么建议, 欢迎指出, 我这边会尽快处理, 让框架更完善, 希望这个框架能帮助更多人, 如果觉得好用, 欢迎star.

1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply plugin: 'com.android.application'
apply plugin: 'android-aspectjx'

android {
compileSdkVersion 28
Expand Down
13 changes: 6 additions & 7 deletions app/src/main/java/com/liys/doubleclickdemo/AppApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import android.app.Application;

import com.liys.doubleclicklibrary.helper.ViewDoubleHelper;
import com.liys.doubleclicklibrary.DoubleClickHelper;

/**
* @Description:
Expand All @@ -19,11 +19,10 @@ public class AppApplication extends Application{
public void onCreate() {
super.onCreate();

// ViewDoubleHelper.init(this); //默认时间:1秒
ViewDoubleHelper.init(this, 2000); //自定义间隔时间(单位:毫秒)
// ViewDoubleHelper.init(this, 1000, UnifiedDoubleClick.class);

ViewDoubleHelper.addAnnotationClass(UnifiedDoubleClick.class);
ViewDoubleHelper.addAnnotationClass(UnifiedDoubleClick2.class);
DoubleClickHelper
.getInstance()
.delayTime(500) //间隔时间
.addAnnotationClass(UnifiedDoubleClick.class)
.addAnnotationClass(UnifiedDoubleClick2.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
import android.view.View;
import android.widget.Toast;

import com.liys.doubleclicklibrary.listener.BaseClickListener;
import com.liys.doubleclicklibrary.listener.IOnClickListener;


/**
* @Description:
* @Author: liys
* @CreateDate: 2019/8/22 15:52
* @UpdateUser: 更新者
* @UpdateDate: 2019/8/22 15:52
* @UpdateDate: 2019/11/23 22:52
* @UpdateRemark: 更新说明
* @Version: 1.0
*/
public class LoginClickListener extends BaseClickListener {
public class LoginClickListener implements IOnClickListener {

public static boolean isLogin = false;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.liys.doubleclickdemo;

import com.liys.doubleclickdemo.fragment.MainActivity2;
import com.liys.doubleclicklibrary.click.annotation.AAddDoubleClick;
import com.liys.doubleclicklibrary.click.annotation.AClickListener;
import com.liys.doubleclicklibrary.annotation.AAddDoubleClick;
import com.liys.doubleclicklibrary.annotation.AClickListener;

/**
* @Description: 统一处理 DoubleClick
Expand All @@ -26,7 +26,7 @@ public interface UnifiedDoubleClick{
// >>>>>>>>>>>>>>>>>>>单个view处理>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// @AAddDoubleClick(activity = MainActivity.class,
// addIds = {R.id.btn1, R.id.btn2},
// times = {2000, 2000})
// times = {2000, 0})
// void mainActivity();


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.liys.doubleclickdemo;

import com.liys.doubleclicklibrary.click.annotation.ACancelActivity;
import com.liys.doubleclicklibrary.annotation.ACancelActivity;

/**
* @Description: 统一处理 DoubleClick
Expand Down
Loading

0 comments on commit 7544262

Please sign in to comment.