From a33ba7266a3aaca594bfccd65803c884832cbbdc Mon Sep 17 00:00:00 2001 From: sma6871 Date: Tue, 25 Feb 2020 12:48:03 +0330 Subject: [PATCH] add on number change event to provide raw text update module version --- build.gradle | 2 +- cardentry/build.gradle | 4 ++-- .../java/com/sma6871/cardentry/CardEntry.kt | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 7f3e2d1..1760d08 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.6.0-rc03' + classpath 'com.android.tools.build:gradle:3.6.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong diff --git a/cardentry/build.gradle b/cardentry/build.gradle index 96e8cf5..180c464 100644 --- a/cardentry/build.gradle +++ b/cardentry/build.gradle @@ -9,8 +9,8 @@ android { defaultConfig { minSdkVersion 14 targetSdkVersion 29 - versionCode 1 - versionName "1.0" + versionCode 6 + versionName "0.6" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles 'consumer-rules.pro' diff --git a/cardentry/src/main/java/com/sma6871/cardentry/CardEntry.kt b/cardentry/src/main/java/com/sma6871/cardentry/CardEntry.kt index 4ea8bb7..538f3a8 100644 --- a/cardentry/src/main/java/com/sma6871/cardentry/CardEntry.kt +++ b/cardentry/src/main/java/com/sma6871/cardentry/CardEntry.kt @@ -100,6 +100,25 @@ class CardEntry : AppCompatEditText { }) } + /** + * Call this method to get raw text (without spaces) + * */ + fun onNumberChange(onChange: (number: String) -> Unit) { + addTextChangedListener(object : TextWatcher { + override fun afterTextChanged(s: Editable) { + if (oldText != rawText) + onChange(rawText) + } + + override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) { + } + + override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { + + } + + }) + } constructor(context: Context) : super(context) { init(context, null)