From bc6de9b579463c23cfc91a9f641bc6d1454b31bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zden=C4=9Bk=20Bal=C3=A1k?= Date: Fri, 3 May 2019 13:47:05 +0200 Subject: [PATCH] FIX: value change listener is not mandatory --- .../element/EditTextElement.kt | 18 ++---------------- .../element/LabelDateTimeElement.kt | 2 +- .../element/LabelInputElement.kt | 2 +- .../element/TextAreaElement.kt | 4 ++-- 4 files changed, 6 insertions(+), 20 deletions(-) diff --git a/formbuilderlibrary/src/main/java/cz/qase/android/formbuilderlibrary/element/EditTextElement.kt b/formbuilderlibrary/src/main/java/cz/qase/android/formbuilderlibrary/element/EditTextElement.kt index 44f1f79..5fa6b67 100644 --- a/formbuilderlibrary/src/main/java/cz/qase/android/formbuilderlibrary/element/EditTextElement.kt +++ b/formbuilderlibrary/src/main/java/cz/qase/android/formbuilderlibrary/element/EditTextElement.kt @@ -16,20 +16,10 @@ import cz.qase.android.formbuilderlibrary.validator.FormValidator open class EditTextElement( protected val hint: String?, - protected val hintRes: Int?, protected val text: String? = null, - private val valueChangeListener: ValueCallback?, + private val valueChangeListener: ValueCallback? = null, formValidators: MutableList> = ArrayList()) : FormElementValidatable(formValidators) { - constructor(hint: String?, - text: String? = null, - valueChangeListener: ValueCallback?, - formValidators: MutableList> = ArrayList()) : this(hint, null, text, valueChangeListener, formValidators) - - constructor(hintRes: Int?, - text: String? = null, - valueChangeListener: ValueCallback?, - formValidators: MutableList> = ArrayList()) : this(null, hintRes, text, valueChangeListener, formValidators) var editText: TextInputEditText? = null @@ -43,11 +33,7 @@ open class EditTextElement( editText = TextInputEditText(context) editText?.setTextColorResourceId(context, formStyleBundle.secondaryTextColor) textInputLayout?.addView(editText) - textInputLayout?.hint = if (hintRes != null) { - context.resources.getString(hintRes) - } else { - hint - } + textInputLayout?.hint = hint editText?.setText(text) editText?.addTextChangedListener(object : TextWatcher { override fun afterTextChanged(s: Editable) { diff --git a/formbuilderlibrary/src/main/java/cz/qase/android/formbuilderlibrary/element/LabelDateTimeElement.kt b/formbuilderlibrary/src/main/java/cz/qase/android/formbuilderlibrary/element/LabelDateTimeElement.kt index 3f1bd0c..0325852 100644 --- a/formbuilderlibrary/src/main/java/cz/qase/android/formbuilderlibrary/element/LabelDateTimeElement.kt +++ b/formbuilderlibrary/src/main/java/cz/qase/android/formbuilderlibrary/element/LabelDateTimeElement.kt @@ -24,7 +24,7 @@ import java.util.Locale class LabelDateTimeElement(private val label: String, private var hint: String, private var supportFragmentManager: FragmentManager, - private val valueChangeListener: ValueCallback?, + private val valueChangeListener: ValueCallback? = null, private var value: DateTime? = null, private var sdf: SimpleDateFormat = SimpleDateFormat("dd.MM.yyyy - HH:mm", Locale.getDefault()), formValidators: MutableList> = ArrayList(), diff --git a/formbuilderlibrary/src/main/java/cz/qase/android/formbuilderlibrary/element/LabelInputElement.kt b/formbuilderlibrary/src/main/java/cz/qase/android/formbuilderlibrary/element/LabelInputElement.kt index 3b4bf3f..ca612cf 100644 --- a/formbuilderlibrary/src/main/java/cz/qase/android/formbuilderlibrary/element/LabelInputElement.kt +++ b/formbuilderlibrary/src/main/java/cz/qase/android/formbuilderlibrary/element/LabelInputElement.kt @@ -22,7 +22,7 @@ import cz.qase.android.formbuilderlibrary.validator.FormValidator class LabelInputElement(private val label: String, private val hint: String, private val value: String? = null, - private val valueChangeListener: ValueCallback?, + private val valueChangeListener: ValueCallback? = null, formValidators: MutableList> = ArrayList(), private val groupComponent: Int = R.layout.form_group_item_inline, private val headerComponent: Int = R.layout.form_inline_label, diff --git a/formbuilderlibrary/src/main/java/cz/qase/android/formbuilderlibrary/element/TextAreaElement.kt b/formbuilderlibrary/src/main/java/cz/qase/android/formbuilderlibrary/element/TextAreaElement.kt index c259248..a747a7d 100644 --- a/formbuilderlibrary/src/main/java/cz/qase/android/formbuilderlibrary/element/TextAreaElement.kt +++ b/formbuilderlibrary/src/main/java/cz/qase/android/formbuilderlibrary/element/TextAreaElement.kt @@ -4,6 +4,7 @@ import android.content.Context import android.support.design.widget.TextInputEditText import android.support.design.widget.TextInputLayout import android.text.Editable +import android.text.InputFilter import android.text.TextWatcher import android.view.LayoutInflater import android.view.View @@ -17,13 +18,12 @@ import cz.qase.android.formbuilderlibrary.common.setTextColorResourceId import cz.qase.android.formbuilderlibrary.element.generic.FormElementValidatable import cz.qase.android.formbuilderlibrary.element.generic.ValueCallback import cz.qase.android.formbuilderlibrary.validator.FormValidator -import android.text.InputFilter class TextAreaElement( private val title: String, private val hint: String?, private var value: String? = null, - private val valueChangeListener: ValueCallback?, + private val valueChangeListener: ValueCallback? = null, private val numberOfLines: Int = 3, private val maxLength: Int? = null, formValidators: MutableList> = ArrayList(),