in litho-widget/src/main/java/com/facebook/litho/widget/TextInputSpec.java [565:716]
static boolean shouldUpdate(
@Prop(optional = true, resType = ResType.STRING) Diff<CharSequence> initialText,
@Prop(optional = true, resType = ResType.STRING) Diff<CharSequence> hint,
@Prop(optional = true, resType = ResType.DRAWABLE) Diff<Drawable> inputBackground,
@Prop(optional = true, resType = ResType.DIMEN_OFFSET) Diff<Float> shadowRadius,
@Prop(optional = true, resType = ResType.DIMEN_OFFSET) Diff<Float> shadowDx,
@Prop(optional = true, resType = ResType.DIMEN_OFFSET) Diff<Float> shadowDy,
@Prop(optional = true, resType = ResType.COLOR) Diff<Integer> shadowColor,
@Prop(optional = true) Diff<ColorStateList> textColorStateList,
@Prop(optional = true) Diff<ColorStateList> hintColorStateList,
@Prop(optional = true, resType = ResType.COLOR) Diff<Integer> highlightColor,
@Prop(optional = true, resType = ResType.DIMEN_TEXT) Diff<Integer> textSize,
@Prop(optional = true) Diff<Typeface> typeface,
@Prop(optional = true) Diff<Integer> textAlignment,
@Prop(optional = true) Diff<Integer> gravity,
@Prop(optional = true) Diff<Boolean> editable,
@Prop(optional = true) Diff<Integer> inputType,
@Prop(optional = true) Diff<Integer> rawInputType,
@Prop(optional = true) Diff<Integer> imeOptions,
@Prop(optional = true, varArg = "inputFilter") Diff<List<InputFilter>> inputFilters,
@Prop(optional = true) Diff<TextUtils.TruncateAt> ellipsize,
@Prop(optional = true) Diff<Boolean> multiline,
@Prop(optional = true) Diff<Integer> minLines,
@Prop(optional = true) Diff<Integer> maxLines,
@Prop(optional = true) Diff<Integer> cursorDrawableRes,
@Prop(optional = true) Diff<MovementMethod> movementMethod,
@Prop(optional = true, resType = ResType.STRING) Diff<CharSequence> error,
@Prop(optional = true) Diff<KeyListener> keyListener,
@State Diff<Integer> measureSeqNumber,
@State Diff<AtomicReference<EditTextWithEventHandlers>> mountedView,
@State Diff<AtomicReference<CharSequence>> savedText) {
if (!ObjectsCompat.equals(measureSeqNumber.getPrevious(), measureSeqNumber.getNext())) {
return true;
}
if (!ObjectsCompat.equals(initialText.getPrevious(), initialText.getNext())) {
return true;
}
if (!ObjectsCompat.equals(hint.getPrevious(), hint.getNext())) {
return true;
}
if (!ObjectsCompat.equals(shadowRadius.getPrevious(), shadowRadius.getNext())) {
return true;
}
if (!ObjectsCompat.equals(shadowDx.getPrevious(), shadowDx.getNext())) {
return true;
}
if (!ObjectsCompat.equals(shadowDy.getPrevious(), shadowDy.getNext())) {
return true;
}
if (!ObjectsCompat.equals(shadowColor.getPrevious(), shadowColor.getNext())) {
return true;
}
if (!ObjectsCompat.equals(textColorStateList.getPrevious(), textColorStateList.getNext())) {
return true;
}
if (!ObjectsCompat.equals(hintColorStateList.getPrevious(), hintColorStateList.getNext())) {
return true;
}
if (!ObjectsCompat.equals(highlightColor.getPrevious(), highlightColor.getNext())) {
return true;
}
if (!ObjectsCompat.equals(textSize.getPrevious(), textSize.getNext())) {
return true;
}
if (!ObjectsCompat.equals(typeface.getPrevious(), typeface.getNext())) {
return true;
}
if (!ObjectsCompat.equals(textAlignment.getPrevious(), textAlignment.getNext())) {
return true;
}
if (!ObjectsCompat.equals(gravity.getPrevious(), gravity.getNext())) {
return true;
}
if (!ObjectsCompat.equals(editable.getPrevious(), editable.getNext())) {
return true;
}
if (!ObjectsCompat.equals(inputType.getPrevious(), inputType.getNext())) {
return true;
}
if (!ObjectsCompat.equals(rawInputType.getPrevious(), rawInputType.getNext())) {
return true;
}
if (!ObjectsCompat.equals(keyListener.getPrevious(), keyListener.getNext())) {
return true;
}
if (!ObjectsCompat.equals(imeOptions.getPrevious(), imeOptions.getNext())) {
return true;
}
if (!equalInputFilters(inputFilters.getPrevious(), inputFilters.getNext())) {
return true;
}
if (!ObjectsCompat.equals(ellipsize.getPrevious(), ellipsize.getNext())) {
return true;
}
if (!ObjectsCompat.equals(multiline.getPrevious(), multiline.getNext())) {
return true;
}
// Minimum and maximum line count should only get checked if multiline is set
if (multiline.getNext()) {
if (!ObjectsCompat.equals(minLines.getPrevious(), minLines.getNext())) {
return true;
}
if (!ObjectsCompat.equals(maxLines.getPrevious(), maxLines.getNext())) {
return true;
}
}
if (!ObjectsCompat.equals(cursorDrawableRes.getPrevious(), cursorDrawableRes.getNext())) {
return true;
}
if (!ObjectsCompat.equals(movementMethod.getPrevious(), movementMethod.getNext())) {
return true;
}
if (!ObjectsCompat.equals(error.getPrevious(), error.getNext())) {
return true;
}
// Note, these are purposefully just comparing the containers, not the contents!
if (mountedView.getPrevious() != mountedView.getNext()) {
return true;
}
if (savedText.getPrevious() != savedText.getNext()) {
return true;
}
// Save the nastiest for last: trying to diff drawables.
Drawable previousBackground = inputBackground.getPrevious();
Drawable nextBackground = inputBackground.getNext();
if (previousBackground == null && nextBackground != null) {
return true;
} else if (previousBackground != null && nextBackground == null) {
return true;
} else if (previousBackground != null && nextBackground != null) {
if (previousBackground instanceof ColorDrawable && nextBackground instanceof ColorDrawable) {
// This doesn't account for tint list/mode (no way to get that information)
// and doesn't account for color filter (fine since ColorDrawable ignores it anyway).
ColorDrawable prevColor = (ColorDrawable) previousBackground;
ColorDrawable nextColor = (ColorDrawable) nextBackground;
if (prevColor.getColor() != nextColor.getColor()) {
return true;
}
} else {
// The best we can do here is compare getConstantState. This can result in spurious updates;
// they might be different objects representing the same drawable. But it's the best we can
// do without actually comparing bitmaps (which is too expensive).
if (!ObjectsCompat.equals(
previousBackground.getConstantState(), nextBackground.getConstantState())) {
return true;
}
}
}
return false;
}