From 146ff03ae0b620a7672a72971f134908533ba303 Mon Sep 17 00:00:00 2001 From: Shiburagi Date: Tue, 6 Oct 2020 17:08:20 +0800 Subject: [PATCH] convert to kotlin --- app/src/main/res/layout/activity_main.xml | 38 +++++++++---------- .../infideap/blockedittext/BlockEditText.kt | 10 ++--- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 852175c..fa6064e 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -18,17 +18,6 @@ android:layout_width="wrap_content" android:layout_height="16dp" /> - - - - - + + + + + app:cardIconSize="48dp" + app:cardPrefix="Mastercard|Visa" + app:defaultLength="4" + app:editTextBackground="@drawable/selector_edittext_round_border" + app:hint="Unshift Block" + app:inputType="Integer" + app:numberOfBlock="4" + app:shiftPosition="false" /> diff --git a/blockedittext/src/main/java/com/infideap/blockedittext/BlockEditText.kt b/blockedittext/src/main/java/com/infideap/blockedittext/BlockEditText.kt index 0a2f9d6..c88585f 100644 --- a/blockedittext/src/main/java/com/infideap/blockedittext/BlockEditText.kt +++ b/blockedittext/src/main/java/com/infideap/blockedittext/BlockEditText.kt @@ -136,7 +136,7 @@ class BlockEditText : FrameLayout { inputType ) shiftPosition = a.getBoolean( - R.styleable.BlockEditText_bet_showCardIcon, + R.styleable.BlockEditText_showCardIcon, true ) isShowCardIcon = a.getBoolean( @@ -144,7 +144,7 @@ class BlockEditText : FrameLayout { true ) editTextStyle = a.getResourceId( - R.styleable.BlockEditText_bet_style, -1 + R.styleable.BlockEditText_style, -1 ) val cardPrefix = a.getInt( R.styleable.BlockEditText_cardPrefix, @@ -161,7 +161,7 @@ class BlockEditText : FrameLayout { } setHintTextAppearance(hintTextAppearance) shiftPosition = a.getBoolean( - R.styleable.BlockEditText_bet_shiftPosition, + R.styleable.BlockEditText_shiftPosition, true ) initLayout() @@ -383,8 +383,8 @@ class BlockEditText : FrameLayout { } } - private fun setEdiTextBackground(editText: AEditText?, drawable: Drawable) { - ViewCompat.setBackground(editText!!, drawable.constantState!!.newDrawable()) + private fun setEdiTextBackground(editText: AEditText?, drawable: Drawable?) { + ViewCompat.setBackground(editText!!, drawable?.constantState?.newDrawable()) } fun setLengthAt(index: Int, length: Int) {