private void checkAttributeSet(AttributeSet attrs) { if (attrs != null) { TypedArray a = getContext().getTheme().obtainStyledAttributes( attrs, R.styleable.CardMultilineWidget, 0, 0); try { mShouldShowPostalCode = a.getBoolean(R.styleable.CardMultilineWidget_shouldShowPostalCode, false); } finally { a.recycle(); } } }
private void initErrorMessages() { mCardNumberEditText.setErrorMessage(getContext().getString(R.string.invalid_card_number)); mExpiryDateEditText.setErrorMessage(getContext().getString(R.string.invalid_expiry_year)); mCvcEditText.setErrorMessage(getContext().getString(R.string.invalid_cvc)); mPostalCodeEditText.setErrorMessage(getContext().getString(R.string.invalid_zip)); }
private void updateDrawable(@DrawableRes int iconResourceId, boolean needsTint) { final Drawable icon = ContextCompat.getDrawable(getContext(), iconResourceId); Drawable[] drawables = mCardNumberEditText.getCompoundDrawables(); Drawable original = drawables[0]; if (original == null) { return; } Rect copyBounds = new Rect(); original.copyBounds(copyBounds); int iconPadding = mCardNumberEditText.getCompoundDrawablePadding(); if (!mHasAdjustedDrawable) { copyBounds.top = copyBounds.top - getDynamicBufferInPixels(); copyBounds.bottom = copyBounds.bottom - getDynamicBufferInPixels(); mHasAdjustedDrawable = true; } icon.setBounds(copyBounds); Drawable compatIcon = DrawableCompat.wrap(icon); if (needsTint) { DrawableCompat.setTint(compatIcon.mutate(), mTintColorInt); } mCardNumberEditText.setCompoundDrawablePadding(iconPadding); mCardNumberEditText.setCompoundDrawables(compatIcon, null, null, null); }
private void initView(AttributeSet attrs) { setOrientation(VERTICAL); inflate(getContext(), R.layout.card_multiline_widget, this);