Skip to content

Commit

Permalink
测试依赖问题
Browse files Browse the repository at this point in the history
  • Loading branch information
luohaolun committed Jul 1, 2019
1 parent 48a1d69 commit 6665ef8
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .idea/vcs.xml

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

4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
8 changes: 8 additions & 0 deletions app/src/main/java/lhl/kotlinextends/Toast.kt
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)
}
36 changes: 36 additions & 0 deletions app/src/main/java/lhl/kotlinextends/View.kt
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
}
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
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
1 change: 1 addition & 0 deletions test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
26 changes: 19 additions & 7 deletions test/src/main/java/k/lhl/test/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

}
Expand Down
17 changes: 17 additions & 0 deletions test/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,21 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:text="TextView"
app:layout_constraintBottom_toTopOf="@+id/btnClick"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />


</android.support.constraint.ConstraintLayout>

0 comments on commit 6665ef8

Please sign in to comment.