From 34ff307062d2ee3f42178b560bbfd5694b6023d5 Mon Sep 17 00:00:00 2001
From: zhujiang521 <57114034@qq.com>
Date: Wed, 29 Apr 2020 09:16:28 +0800
Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E4=B8=8A=E4=BA=86=E8=AF=84=E8=AE=BA?=
=?UTF-8?q?=E5=8C=BA=E5=A4=A7=E5=AE=B6=E6=8F=90=E5=88=B0=E7=9A=84=E6=89=A9?=
=?UTF-8?q?=E5=B1=95=E5=87=BD=E6=95=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../zj/it/bhne/androidaop/Main2Activity.java | 3 ++
.../zj/it/bhne/androidaop/MainActivity.kt | 15 +++++++-
.../java/zj/it/bhne/androidaop/OnClick.kt | 36 +++++++++++++++++++
app/src/main/res/layout/activity_main.xml | 13 +++++++
app/src/main/res/layout/activity_main2.xml | 8 +++++
.../com/zj/singclick/SingleClickAspect.java | 4 +--
.../src/main/java/com/zj/test/TestActivity.kt | 1 +
test/src/main/java/com/zj/test/reified.kt | 19 ++++++++++
8 files changed, 96 insertions(+), 3 deletions(-)
create mode 100644 app/src/main/java/zj/it/bhne/androidaop/OnClick.kt
create mode 100644 test/src/main/java/com/zj/test/reified.kt
diff --git a/app/src/main/java/zj/it/bhne/androidaop/Main2Activity.java b/app/src/main/java/zj/it/bhne/androidaop/Main2Activity.java
index f7e3ebb..5718841 100644
--- a/app/src/main/java/zj/it/bhne/androidaop/Main2Activity.java
+++ b/app/src/main/java/zj/it/bhne/androidaop/Main2Activity.java
@@ -59,4 +59,7 @@ public void btnAop(View view) {
Log.e(TAG, "btnAop");
}
+ public void btnKotlin(View view) {
+ startActivity(new Intent(this,MainActivity.class));
+ }
}
diff --git a/app/src/main/java/zj/it/bhne/androidaop/MainActivity.kt b/app/src/main/java/zj/it/bhne/androidaop/MainActivity.kt
index ae1b043..168c30d 100644
--- a/app/src/main/java/zj/it/bhne/androidaop/MainActivity.kt
+++ b/app/src/main/java/zj/it/bhne/androidaop/MainActivity.kt
@@ -16,6 +16,19 @@ class MainActivity : AppCompatActivity() ,View.OnClickListener{
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
btnClick.setOnClickListener(this)
+ initView()
+ }
+
+ private fun initView() {
+ btnKuoZhan.setSafeListener {
+ ToastUtils.showShort("222")
+ Log.e("kuozhan","wwww")
+ }
+
+ btnKuoZhanClick.click {
+ ToastUtils.showShort("ss")
+ Log.e("kuozhan","呵呵呵")
+ }
}
@@ -25,7 +38,7 @@ class MainActivity : AppCompatActivity() ,View.OnClickListener{
when(v.id){
R.id.btnClick->{
ToastUtils.showShort("哈哈哈")
- Log.e("刘佩希","wwww")
+ Log.e("ee","wwww")
}
}
}
diff --git a/app/src/main/java/zj/it/bhne/androidaop/OnClick.kt b/app/src/main/java/zj/it/bhne/androidaop/OnClick.kt
new file mode 100644
index 0000000..94e6b2a
--- /dev/null
+++ b/app/src/main/java/zj/it/bhne/androidaop/OnClick.kt
@@ -0,0 +1,36 @@
+package zj.it.bhne.androidaop
+
+import android.view.View
+
+/**
+ * 版权:渤海新能 版权所有
+ * @author zhujiang
+ * 版本:1.5
+ * 创建日期:2020/4/29
+ * 描述:AndroidAOP
+ *
+ */
+
+inline fun View.setSafeListener(crossinline action:()->Unit){
+ var lastClick=0L
+ setOnClickListener {
+ val gap = System.currentTimeMillis() - lastClick
+ lastClick=System.currentTimeMillis()
+ if(gap<1500) return@setOnClickListener
+ action.invoke()
+ }
+}
+
+
+var _viewClickFlag = false
+var _clickRunnable = Runnable { _viewClickFlag = false }
+fun View.click(action: (view: View) -> Unit) {
+ setOnClickListener {
+ if (!_viewClickFlag) {
+ _viewClickFlag = true
+ action(it)
+ }
+ removeCallbacks(_clickRunnable)
+ postDelayed(_clickRunnable, 1000)
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 4396ef3..9ef186b 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -2,6 +2,7 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main2.xml b/app/src/main/res/layout/activity_main2.xml
index 4c5fefc..b199f98 100644
--- a/app/src/main/res/layout/activity_main2.xml
+++ b/app/src/main/res/layout/activity_main2.xml
@@ -12,6 +12,14 @@
android:layout_gravity="center"
android:onClick="btnDialog"/>
+
+