EmojiTextViewHelper
public final class EmojiTextViewHelper
Utility class to enhance custom TextView widgets with EmojiCompat.
public class MyEmojiTextView extends TextView { public MyEmojiTextView(Context context) { super(context); init(); } // .. private void init() { getEmojiTextViewHelper().updateTransformationMethod(); } @Override public void setFilters(InputFilter[] filters) { super.setFilters(getEmojiTextViewHelper().getFilters(filters)); } @Override public void setAllCaps(boolean allCaps) { super.setAllCaps(allCaps); getEmojiTextViewHelper().setAllCaps(allCaps); } private EmojiTextViewHelper getEmojiTextViewHelper() { if (mEmojiTextViewHelper == null) { mEmojiTextViewHelper = new EmojiTextViewHelper(this); } return mEmojiTextViewHelper; } }
Summary
Public constructors |
|---|
EmojiTextViewHelper(@NonNull TextView textView)Default constructor. |
Public methods |
|
|---|---|
@NonNull InputFilter[] |
getFilters(@NonNull InputFilter[] filters)Appends EmojiCompat InputFilters to the widget InputFilters. |
void |
setAllCaps(boolean allCaps)Call when allCaps is set on TextView. |
void |
Updates widget's TransformationMethod so that the transformed text can be processed. |
@Nullable TransformationMethod |
wrapTransformationMethod(Returns transformation method that can update the transformed text to display emojis. |
Public constructors
Public methods
getFilters
public @NonNull InputFilter[] getFilters(@NonNull InputFilter[] filters)
Appends EmojiCompat InputFilters to the widget InputFilters. Should be called by setFilters to update the InputFilters. When used on devices running API 18 or below, this method returns filters that is given as a parameter.
| Parameters | |
|---|---|
@NonNull InputFilter[] filters |
InputFilter array passed to |
| Returns | |
|---|---|
@NonNull InputFilter[] |
same copy if the array already contains EmojiCompat InputFilter. A new array copy if not. |
setAllCaps
public void setAllCaps(boolean allCaps)
Call when allCaps is set on TextView. When used on devices running API 18 or below, this method does nothing.
| Parameters | |
|---|---|
boolean allCaps |
allCaps parameter passed to |
updateTransformationMethod
public void updateTransformationMethod()
Updates widget's TransformationMethod so that the transformed text can be processed. Should be called in the widget constructor. When used on devices running API 18 or below, this method does nothing.
| See also | |
|---|---|
wrapTransformationMethod |
wrapTransformationMethod
public @Nullable TransformationMethod wrapTransformationMethod(
@Nullable TransformationMethod transformationMethod
)
Returns transformation method that can update the transformed text to display emojis. When used on devices running API 18 or below, this method returns transformationMethod that is given as a parameter.
| Parameters | |
|---|---|
@Nullable TransformationMethod transformationMethod |
instance to be wrapped |