-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a1316b8
commit 34ff307
Showing
8 changed files
with
96 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.zj.test | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
|
||
/** | ||
* 版权:渤海新能 版权所有 | ||
* @author zhujiang | ||
* 版本:1.5 | ||
* 创建日期:2020/4/27 | ||
* 描述:AndroidAOP | ||
* | ||
*/ | ||
|
||
inline fun <reified T> startActivity(context: Context,block: Intent.() -> Unit){ | ||
val intent = Intent(context, T::class.java) | ||
intent.block() | ||
context.startActivity(intent) | ||
} |