Skip to content

Commit

Permalink
FIX: value change listener is not mandatory
Browse files Browse the repository at this point in the history
  • Loading branch information
Zdeněk Balák committed May 3, 2019
1 parent 699eee6 commit bc6de9b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>?,
private val valueChangeListener: ValueCallback<String>? = null,
formValidators: MutableList<FormValidator<String>> = ArrayList()) : FormElementValidatable<String>(formValidators) {

constructor(hint: String?,
text: String? = null,
valueChangeListener: ValueCallback<String>?,
formValidators: MutableList<FormValidator<String>> = ArrayList()) : this(hint, null, text, valueChangeListener, formValidators)

constructor(hintRes: Int?,
text: String? = null,
valueChangeListener: ValueCallback<String>?,
formValidators: MutableList<FormValidator<String>> = ArrayList()) : this(null, hintRes, text, valueChangeListener, formValidators)


var editText: TextInputEditText? = null
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<DateTime>?,
private val valueChangeListener: ValueCallback<DateTime>? = null,
private var value: DateTime? = null,
private var sdf: SimpleDateFormat = SimpleDateFormat("dd.MM.yyyy - HH:mm", Locale.getDefault()),
formValidators: MutableList<FormValidator<DateTime>> = ArrayList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>?,
private val valueChangeListener: ValueCallback<String>? = null,
formValidators: MutableList<FormValidator<String>> = ArrayList(),
private val groupComponent: Int = R.layout.form_group_item_inline,
private val headerComponent: Int = R.layout.form_inline_label,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<String>?,
private val valueChangeListener: ValueCallback<String>? = null,
private val numberOfLines: Int = 3,
private val maxLength: Int? = null,
formValidators: MutableList<FormValidator<String>> = ArrayList(),
Expand Down

0 comments on commit bc6de9b

Please sign in to comment.