提交 caf06550 编写于 作者: 门心叼龙's avatar 门心叼龙

update test

......@@ -6,6 +6,9 @@
<JetCodeStyleSettings>
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</JetCodeStyleSettings>
<MarkdownNavigatorCodeStyleSettings>
<option name="RIGHT_MARGIN" value="72" />
</MarkdownNavigatorCodeStyleSettings>
<codeStyleSettings language="XML">
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
......
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="JDK" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
</project>
\ No newline at end of file
......@@ -13,6 +13,8 @@ android {
versionCode 1
versionName "1.0"
//multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
......@@ -34,6 +36,11 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
<<<<<<< HEAD
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3'
=======
//implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
//implementation 'com.android.support:multidex:1.0.3'
>>>>>>> b05ec5ba2cfc1b8b505b985998da925f5f6b8f5f
implementation project(':lib_common')
}
......@@ -8,7 +8,8 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
......
......@@ -5,6 +5,11 @@ import android.os.Bundle
import android.util.Log
import android.view.View
import com.fly.tour.common.util.ToastUtil
<<<<<<< HEAD
=======
import com.fly.tour.test.dsl.addTextChangeListenerClosure
import com.fly.tour.test.dsl.addTextChangeListenerDsl
>>>>>>> b05ec5ba2cfc1b8b505b985998da925f5f6b8f5f
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
......@@ -12,11 +17,18 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
class MainActivity : AppCompatActivity() {
<<<<<<< HEAD
val TAG = "MYTAG"
=======
//var TAG = MainActivity::class.simpleName
var TAG = "MYTAG"
>>>>>>> b05ec5ba2cfc1b8b505b985998da925f5f6b8f5f
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
<<<<<<< HEAD
//testOnClick()
//testThread()
//test1
......@@ -41,6 +53,8 @@ class MainActivity : AppCompatActivity() {
}
private fun testOnClick() {
=======
>>>>>>> b05ec5ba2cfc1b8b505b985998da925f5f6b8f5f
btn.setOnClickListener { v -> ToastUtil.showToast("ok") }
btn.setOnClickListener() { v -> ToastUtil.showToast("ok") }
btn.setOnClickListener({ v -> ToastUtil.showToast("ok") })
......@@ -51,6 +65,34 @@ class MainActivity : AppCompatActivity() {
}
})
// txtContent.addTextChangedListener(object : TextWatcher {
// override fun afterTextChanged(s: Editable?) {
// Log.v(TAG,"afterTextChanged ${s.toString()}")
// }
//
// override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
// Log.v(TAG, "beforeTextChanged s: $s, start: $start, count: $count, after: $after")
// }
//
// override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
// Log.v(TAG, "onTextChanged s: $s, start: $start, before: $before, count: $count")
// }
//
// })
// txtContent.addTextChangedListener(object: MyTextWatcher() {
// override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
// Log.v(TAG,"$s:$before:$count")
// }
// })
// txtContent.addTextChangeListenerClosure(onTextChanged = { s, start, before, count ->
// Log.v(TAG,"s:$s")
// })
txtContent.addTextChangeListenerDsl {
onTextChanged{
s,start,before,count -> Log.v(TAG,"s value:$s")
}
}
}
}
package com.fly.tour.test
import android.app.Application
/**
* Description: <MyApplication><br>
* Author: mxdl<br>
* Date: 2020/2/28<br>
* Version: V1.0.0<br>
* Update: <br>
*/
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
}
}
\ No newline at end of file
package com.fly.tour.test.dsl
import android.text.Editable
import android.text.TextWatcher
/**
* Description: <MyTextWatcher><br>
* Author: mxdl<br>
* Date: 2020/2/28<br>
* Version: V1.0.0<br>
* Update: <br>
*/
open class MyTextWatcher: TextWatcher{
override fun afterTextChanged(s: Editable?) {
}
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
}
}
\ No newline at end of file
package com.fly.tour.test.dsl
import android.text.Editable
import android.text.TextWatcher
import android.widget.TextView
/**
* Description: <MyUtils><br>
* Author: mxdl<br>
* Date: 2020/2/28<br>
* Version: V1.0.0<br>
* Update: <br>
*/
inline fun TextView.addTextChangeListenerClosure(
crossinline afterTextChanged: (Editable?) -> Unit = {},
crossinline beforeTextChanged:(CharSequence?,Int,Int,Int) -> Unit = {s,start,count,after ->},
crossinline onTextChanged:(CharSequence?, Int, Int, Int) -> Unit = { s, start, before, count ->}){
var listener = object:TextWatcher{
override fun afterTextChanged(s: Editable?) {
afterTextChanged.invoke(s)
}
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
beforeTextChanged.invoke(s,start,count,after)
}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
onTextChanged.invoke(s,start,before,count)
}
}
this.addTextChangedListener(listener)
}
fun TextView.addTextChangeListenerDsl(listener:TextChangeListenerDsl.()->Unit){
var mListener = TextChangeListenerDsl()
//mListener.listener()
mListener.apply(listener)
this.addTextChangedListener(mListener)
}
\ No newline at end of file
package com.fly.tour.test.dsl
import android.text.Editable
import android.text.TextWatcher
/**
* Description: <TextChangeListenerDsl><br>
* Author: mxdl<br>
* Date: 2020/2/28<br>
* Version: V1.0.0<br>
* Update: <br>
*/
class TextChangeListenerDsl : TextWatcher {
var afterTextChanged: ((Editable?) -> Unit)? = null
var beforeTextChanged: ((CharSequence?, Int, Int, Int) -> Unit)? = null
var onTextChanged: ((CharSequence?, Int, Int, Int) -> Unit)? = null
fun afterTextChanged(method: (Editable?) -> Unit) {
afterTextChanged = method
}
fun beforeTextChanged(method: (CharSequence?, Int, Int, Int) -> Unit) {
beforeTextChanged = method
}
fun onTextChanged(method: (CharSequence?, Int, Int, Int) -> Unit) {
beforeTextChanged = method
}
override fun afterTextChanged(s: Editable?) {
afterTextChanged?.invoke(s)
}
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
beforeTextChanged?.invoke(s, start, count, after)
}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
onTextChanged?.invoke(s, start, before, count)
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<EditText
android:id="@+id/txtContent"
android:layout_width="match_parent"
android:layout_height="60dp"
/>
<Button
android:id="@+id/btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册