-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
9 changed files
with
88 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,8 @@ | ||
package lhl.kotlinextends | ||
|
||
import com.blankj.utilcode.util.ToastUtils | ||
import com.blankj.utilcode.util.Utils | ||
|
||
fun String.toast(){ | ||
ToastUtils.showShort(this) | ||
} |
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 lhl.kotlinextends | ||
|
||
import android.view.View | ||
|
||
|
||
private var lastClickTime: Long = 0 | ||
fun isFastDoubleClick(): Boolean { | ||
val time = System.currentTimeMillis() | ||
if (time - lastClickTime < 500) { | ||
return true | ||
} | ||
lastClickTime = time | ||
return false | ||
} | ||
|
||
open class SingleClick(private val listener: (View?) -> Unit) : View.OnClickListener { | ||
override fun onClick(v: View?) { | ||
if (!isFastDoubleClick()) | ||
listener.invoke(v) | ||
} | ||
} | ||
|
||
fun View.click(listener: (View?) -> Unit) { | ||
setOnClickListener(SingleClick(listener)) | ||
} | ||
|
||
fun View.longClick(listener: (View?) -> Boolean) { | ||
isLongClickable = true | ||
setOnLongClickListener(listener) | ||
} | ||
|
||
var View.visible: Boolean | ||
get() = this.visibility == View.VISIBLE | ||
set(value) { | ||
this.visibility = if (value) View.VISIBLE else View.GONE | ||
} |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Thu Dec 27 16:26:56 CST 2018 | ||
#Mon Jul 01 09:29:24 CST 2019 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip |
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