-
Notifications
You must be signed in to change notification settings - Fork 5
ANDROID-16934 -- (II) Remove databinding related code #479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: ANDROID-16934/base-remove-databinding
Are you sure you want to change the base?
Changes from all commits
b526100
50a33f0
ccd6fad
2ea4064
33ca40d
3304cc5
85a6de1
1014011
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -15,97 +15,13 @@ import androidx.annotation.ColorInt | |||||||
| import androidx.annotation.LayoutRes | ||||||||
| import androidx.annotation.StringRes | ||||||||
| import androidx.core.graphics.drawable.toDrawable | ||||||||
| import androidx.databinding.BindingMethod | ||||||||
| import androidx.databinding.BindingMethods | ||||||||
| import com.telefonica.mistica.R | ||||||||
| import com.telefonica.mistica.util.children | ||||||||
| import com.telefonica.mistica.util.convertDpToPx | ||||||||
| import com.telefonica.mistica.util.getMisticaThemeDrawable | ||||||||
| import com.telefonica.mistica.util.getThemeColor | ||||||||
| import com.telefonica.mistica.util.setTextAndVisibility | ||||||||
|
|
||||||||
| @BindingMethods( | ||||||||
| BindingMethod( | ||||||||
| type = HeaderView::class, | ||||||||
| attribute = "headerInverse", | ||||||||
| method = "setInverse" | ||||||||
| ), | ||||||||
| BindingMethod( | ||||||||
| type = HeaderView::class, | ||||||||
| attribute = "headerHasTopPadding", | ||||||||
| method = "setHasTopPadding" | ||||||||
| ), | ||||||||
| BindingMethod( | ||||||||
| type = HeaderView::class, | ||||||||
| attribute = "headerFirstPretitle", | ||||||||
| method = "setFirstPretitle" | ||||||||
| ), | ||||||||
| BindingMethod( | ||||||||
| type = HeaderView::class, | ||||||||
| attribute = "headerFirstPretitleHasSecondaryColor", | ||||||||
| method = "setFirstPretitleHasSecondaryColor" | ||||||||
| ), | ||||||||
| BindingMethod( | ||||||||
| type = HeaderView::class, | ||||||||
| attribute = "headerTitle", | ||||||||
| method = "setTitle" | ||||||||
| ), | ||||||||
| BindingMethod( | ||||||||
| type = HeaderView::class, | ||||||||
| attribute = "headerSecondPretitle", | ||||||||
| method = "setSecondPretitle" | ||||||||
| ), | ||||||||
| BindingMethod( | ||||||||
| type = HeaderView::class, | ||||||||
| attribute = "headerSecondPretitleHasSecondaryColor", | ||||||||
| method = "setSecondPretitleHasSecondaryColor" | ||||||||
| ), | ||||||||
| BindingMethod( | ||||||||
| type = HeaderView::class, | ||||||||
| attribute = "headerNumeral", | ||||||||
| method = "setNumeral" | ||||||||
| ), | ||||||||
| BindingMethod( | ||||||||
| type = HeaderView::class, | ||||||||
| attribute = "headerNumeralHasErrorColor", | ||||||||
| method = "setNumeralHasDangerColor" | ||||||||
| ), | ||||||||
| BindingMethod( | ||||||||
| type = HeaderView::class, | ||||||||
| attribute = "headerActionButtonText", | ||||||||
| method = "setActionButtonText" | ||||||||
| ), | ||||||||
| BindingMethod( | ||||||||
| type = HeaderView::class, | ||||||||
| attribute = "headerSecondaryActionButtonText", | ||||||||
| method = "setSecondaryActionButtonText" | ||||||||
| ), | ||||||||
| BindingMethod( | ||||||||
| type = HeaderView::class, | ||||||||
| attribute = "headerActionButtonOnClick", | ||||||||
| method = "setActionButtonOnClick" | ||||||||
| ), | ||||||||
| BindingMethod( | ||||||||
| type = HeaderView::class, | ||||||||
| attribute = "headerSecondaryActionButtonOnClick", | ||||||||
| method = "setSecondaryActionButtonOnClick" | ||||||||
| ), | ||||||||
| BindingMethod( | ||||||||
| type = HeaderView::class, | ||||||||
| attribute = "headerSubtitle", | ||||||||
| method = "setHeaderSubtitle" | ||||||||
| ), | ||||||||
| BindingMethod( | ||||||||
| type = HeaderView::class, | ||||||||
| attribute = "headerSubtitleHasSecondaryColor", | ||||||||
| method = "setSubtitleHasSecondaryColor" | ||||||||
| ), | ||||||||
| BindingMethod( | ||||||||
| type = HeaderView::class, | ||||||||
| attribute = "bottomLayout", | ||||||||
| method = "setBottomLayout" | ||||||||
| ), | ||||||||
| ) | ||||||||
| class HeaderView @JvmOverloads constructor( | ||||||||
| context: Context, | ||||||||
| attrs: AttributeSet? = null, | ||||||||
|
|
@@ -319,6 +235,36 @@ class HeaderView @JvmOverloads constructor( | |||||||
| configureTextsColors() | ||||||||
| } | ||||||||
|
|
||||||||
| fun setHeaderFirstPretitle(@StringRes textRes: Int?) = setFirstPretitle(textRes) | ||||||||
| fun setHeaderTitle(text: CharSequence?) = setTitle(text) | ||||||||
|
|
||||||||
| fun setHeaderInverse(value: Boolean) = setInverse(value) | ||||||||
| fun setHeaderHasTopPadding(value: Boolean) = setHasTopPadding(value) | ||||||||
|
|
||||||||
| fun setHeaderFirstPretitle(text: CharSequence?) = setFirstPretitle(text) | ||||||||
| fun setHeaderFirstPretitleHasSecondaryColor(value: Boolean) = | ||||||||
| setFirstPretitleHasSecondaryColor(value) | ||||||||
|
|
||||||||
| fun setHeaderSecondPretitle(text: CharSequence?) = setSecondPretitle(text) | ||||||||
| fun setHeaderSecondPretitleHasSecondaryColor(value: Boolean) = | ||||||||
| setSecondPretitleHasSecondaryColor(value) | ||||||||
|
|
||||||||
| fun setHeaderNumeral(text: CharSequence?) = setNumeral(text) | ||||||||
| fun setHeaderNumeralHasErrorColor(value: Boolean) = setNumeralHasDangerColor(value) | ||||||||
|
|
||||||||
| fun setHeaderSubtitle(text: CharSequence?) = setSubtitle(text) | ||||||||
| fun setHeaderSubtitleHasSecondaryColor(value: Boolean) = setSubtitleHasSecondaryColor(value) | ||||||||
|
|
||||||||
| fun setHeaderActionButtonText(text: CharSequence?) = setActionButtonText(text) | ||||||||
| fun setHeaderSecondaryActionButtonText(text: CharSequence?) = setSecondaryActionButtonText(text) | ||||||||
|
||||||||
| fun setHeaderSecondaryActionButtonText(text: CharSequence?) = setSecondaryActionButtonText(text) | |
| fun setHeaderSecondaryActionButtonText(text: CharSequence?) = | |
| setSecondaryActionButtonText(text) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,36 +7,12 @@ import android.text.method.MovementMethod | |
| import android.util.AttributeSet | ||
| import android.view.LayoutInflater | ||
| import android.widget.CompoundButton | ||
| import androidx.annotation.StringRes | ||
| import androidx.appcompat.widget.AppCompatCheckBox | ||
| import androidx.databinding.BindingAdapter | ||
| import androidx.databinding.BindingMethod | ||
| import androidx.databinding.BindingMethods | ||
| import androidx.databinding.InverseBindingListener | ||
| import androidx.databinding.InverseBindingMethod | ||
| import androidx.databinding.InverseBindingMethods | ||
| import com.google.android.material.textfield.TextInputLayout | ||
| import com.telefonica.mistica.R | ||
| import com.telefonica.mistica.util.getThemeColor | ||
|
|
||
| @BindingMethods( | ||
| BindingMethod( | ||
| type = CheckBoxInput::class, | ||
| attribute = "inputCheckText", | ||
| method = "setText" | ||
| ), | ||
| BindingMethod( | ||
| type = CheckBoxInput::class, | ||
| attribute = "inputChecked", | ||
| method = "setChecked" | ||
| ) | ||
| ) | ||
| @InverseBindingMethods( | ||
| InverseBindingMethod( | ||
| type = CheckBoxInput::class, | ||
| attribute = "inputChecked", | ||
| method = "isChecked" | ||
| ) | ||
| ) | ||
| class CheckBoxInput @JvmOverloads constructor( | ||
| context: Context, | ||
| attrs: AttributeSet? = null, | ||
|
|
@@ -102,6 +78,28 @@ class CheckBoxInput @JvmOverloads constructor( | |
| checkBox.buttonTintList = ColorStateList(states, colors) | ||
| } | ||
|
|
||
| fun setInputError(@StringRes errorRes: Int?) { | ||
| if (errorRes == null) { | ||
| error = null | ||
| setErrorEnabled(false) | ||
| } else { | ||
| error = context.getString(errorRes) | ||
| setErrorEnabled(true) | ||
| } | ||
| } | ||
|
Comment on lines
+81
to
+89
|
||
|
|
||
| fun setInputEnabled(enabled: Boolean) { | ||
| isEnabled = enabled | ||
| } | ||
|
|
||
| fun setInputCheckText(text: CharSequence?) { | ||
| setText(text) | ||
| } | ||
|
|
||
| fun getInputCheckText(): CharSequence? { | ||
| return getText() | ||
| } | ||
|
Comment on lines
+95
to
+101
|
||
|
|
||
| fun setChecked(checked: Boolean) { | ||
| checkBox.isChecked = checked | ||
| } | ||
|
|
@@ -131,14 +129,4 @@ class CheckBoxInput @JvmOverloads constructor( | |
| super.setEnabled(enabled) | ||
| checkBox.isEnabled = enabled | ||
| } | ||
|
|
||
| companion object { | ||
| @BindingAdapter( | ||
| value = ["inputCheckedAttrChanged"] | ||
| ) | ||
| @JvmStatic | ||
| fun setCheckWatcher(input: CheckBoxInput, listener: InverseBindingListener) { | ||
| input.setOnCheckedChangeListener(CompoundButton.OnCheckedChangeListener { _, _ -> listener.onChange() }) | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate method definition for setHeaderFirstPretitle. Line 238 accepts @stringres Int? while line 244 accepts CharSequence?. This creates a naming collision that will cause compilation errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently these methods do not launch any compilation errors due to signature is different.