From c43692766c8d31ca09e0104b3d28d1cb2dbffd13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?fevzi=20=C3=B6m=C3=BCr=20tekin?= Date: Thu, 18 Jun 2020 12:57:56 +0300 Subject: [PATCH] fixed runtime error. Close #4 --- .idea/codeStyles/Project.xml | 109 ++++++++++++++++++ .idea/gradle.xml | 2 + .idea/jarRepositories.xml | 30 +++++ .idea/misc.xml | 2 +- .../com/fevziomurtekin/payview/Payview.kt | 34 +++--- 5 files changed, 160 insertions(+), 17 deletions(-) create mode 100644 .idea/jarRepositories.xml diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index 455250f..9624886 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -6,6 +6,115 @@ + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 56baa32..e950e4f 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -1,8 +1,10 @@ + - + diff --git a/payview/src/main/java/com/fevziomurtekin/payview/Payview.kt b/payview/src/main/java/com/fevziomurtekin/payview/Payview.kt index 807988e..0efbc84 100644 --- a/payview/src/main/java/com/fevziomurtekin/payview/Payview.kt +++ b/payview/src/main/java/com/fevziomurtekin/payview/Payview.kt @@ -382,22 +382,24 @@ class Payview : NestedScrollView, View.OnFocusChangeListener { private fun checkCardType(cardNo: String?){ when(cardNo?.substring(0,1).toString().toInt()){ 3->{ - when(cardNo?.substring(0,2)?.toInt()){ - in 30..38->{ - cardType = CardType.DINNERSCLUB - iv_card_type.setImageResource(R.drawable.ic_dinners) - } - 35->{ - cardType = CardType.JCB - iv_card_type.setImageResource(R.drawable.ic_jcb) - } - 37->{ - cardType = CardType.AMERICANEXPRESS - iv_card_type.setImageResource(R.drawable.ic_american_express) - } - else->{ - cardType = CardType.UNDEFINED - iv_card_type.setImageResource(R.drawable.ic_warning) + if(cardNo?.length!! > 2) { + when (cardNo?.substring(0, 2)?.toInt()) { + in 30..38 -> { + cardType = CardType.DINNERSCLUB + iv_card_type.setImageResource(R.drawable.ic_dinners) + } + 35 -> { + cardType = CardType.JCB + iv_card_type.setImageResource(R.drawable.ic_jcb) + } + 37 -> { + cardType = CardType.AMERICANEXPRESS + iv_card_type.setImageResource(R.drawable.ic_american_express) + } + else -> { + cardType = CardType.UNDEFINED + iv_card_type.setImageResource(R.drawable.ic_warning) + } } } }