From 6665ef8bf8924359a9eb494f0e67d54075e2246b Mon Sep 17 00:00:00 2001
From: luohaolun <506503279@qq.com>
Date: Mon, 1 Jul 2019 11:11:56 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=BE=9D=E8=B5=96=E9=97=AE?=
=?UTF-8?q?=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.idea/vcs.xml | 2 +-
app/build.gradle | 4 +--
app/src/main/java/lhl/kotlinextends/Toast.kt | 8 +++++
app/src/main/java/lhl/kotlinextends/View.kt | 36 +++++++++++++++++++
build.gradle | 4 +--
gradle/wrapper/gradle-wrapper.properties | 4 +--
test/build.gradle | 1 +
test/src/main/java/k/lhl/test/MainActivity.kt | 26 ++++++++++----
test/src/main/res/layout/activity_main.xml | 17 +++++++++
9 files changed, 88 insertions(+), 14 deletions(-)
create mode 100644 app/src/main/java/lhl/kotlinextends/Toast.kt
create mode 100644 app/src/main/java/lhl/kotlinextends/View.kt
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index 94a25f7..35eb1dd 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index 711edb1..1263f4a 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -23,6 +23,6 @@ android {
}
dependencies {
- implementation fileTree(dir: 'libs', include: ['*.jar'])
- implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
+ implementation 'com.blankj:utilcode:1.23.7'
}
diff --git a/app/src/main/java/lhl/kotlinextends/Toast.kt b/app/src/main/java/lhl/kotlinextends/Toast.kt
new file mode 100644
index 0000000..7270b64
--- /dev/null
+++ b/app/src/main/java/lhl/kotlinextends/Toast.kt
@@ -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)
+}
\ No newline at end of file
diff --git a/app/src/main/java/lhl/kotlinextends/View.kt b/app/src/main/java/lhl/kotlinextends/View.kt
new file mode 100644
index 0000000..8ac131a
--- /dev/null
+++ b/app/src/main/java/lhl/kotlinextends/View.kt
@@ -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
+ }
diff --git a/build.gradle b/build.gradle
index adf4e04..750708d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,13 +1,13 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
- ext.kotlin_version = '1.2.50'
+ ext.kotlin_version = '1.3.40'
repositories {
google()
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.1.4'
+ classpath 'com.android.tools.build:gradle:3.4.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 4b82acb..53ed3e0 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -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
diff --git a/test/build.gradle b/test/build.gradle
index ca2f196..80e0c1e 100644
--- a/test/build.gradle
+++ b/test/build.gradle
@@ -34,5 +34,6 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
+// implementation 'com.blankj:utilcode:1.23.7'
implementation project(':app')
}
diff --git a/test/src/main/java/k/lhl/test/MainActivity.kt b/test/src/main/java/k/lhl/test/MainActivity.kt
index 0e2f084..c567fba 100644
--- a/test/src/main/java/k/lhl/test/MainActivity.kt
+++ b/test/src/main/java/k/lhl/test/MainActivity.kt
@@ -3,19 +3,31 @@ package k.lhl.test
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_main.*
-import lhl.kotlinextends.e
-import lhl.kotlinextends.v
+import lhl.kotlinextends.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
- btnClick.setOnClickListener {
- 123456.e()
- Thread {
- "abcdef".v()
- }.start()
+ btnClick.click {
+// 123456.e()
+// Thread {
+// "abcdef".v()
+// }.start()
+// textView.visible = !textView.visible
+
+
+// ToastUtils.setMsgColor(resources.getColor(R.color.colorAccent))
+// ToastUtils.setBgResource()
+ "哈哈哈".e()
+
+
+ }
+
+ btnClick.longClick {
+ "哈哈哈".e()
+ true
}
}
diff --git a/test/src/main/res/layout/activity_main.xml b/test/src/main/res/layout/activity_main.xml
index e070934..b2dfb28 100644
--- a/test/src/main/res/layout/activity_main.xml
+++ b/test/src/main/res/layout/activity_main.xml
@@ -16,4 +16,21 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
+
+
+
\ No newline at end of file