Skip to content

Commit

Permalink
add on number change event to provide raw text
Browse files Browse the repository at this point in the history
update module version
  • Loading branch information
sma6871 committed Feb 25, 2020
1 parent 574c41b commit a33ba72
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions cardentry/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
19 changes: 19 additions & 0 deletions cardentry/src/main/java/com/sma6871/cardentry/CardEntry.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a33ba72

Please sign in to comment.