prevent early callback death

android is so dumb.

Fixes #3255
Closes #3260
// FREEBIE
This commit is contained in:
Jake McGinty 2015-05-26 15:10:45 -07:00 committed by Moxie Marlinspike
parent 624c7dbf9d
commit 1a7c4a2869
2 changed files with 8 additions and 2 deletions

View File

@ -1,11 +1,14 @@
package org.thoughtcrime.securesms.components.emoji;
import android.content.Context;
import android.graphics.drawable.Drawable.Callback;
import android.support.v7.widget.AppCompatEditText;
import android.util.AttributeSet;
public class EmojiEditText extends AppCompatEditText {
private final Callback callback = new PostInvalidateCallback(this);
public EmojiEditText(Context context) {
super(context);
}
@ -31,7 +34,7 @@ public class EmojiEditText extends AppCompatEditText {
final char[] chars = Character.toChars(codePoint);
final CharSequence text = EmojiProvider.getInstance(getContext()).emojify(new String(chars),
EmojiProvider.EMOJI_SMALL,
new PostInvalidateCallback(this));
callback);
getText().replace(Math.min(start, end), Math.max(start, end), text);
setSelection(end + chars.length);

View File

@ -1,10 +1,13 @@
package org.thoughtcrime.securesms.components.emoji;
import android.content.Context;
import android.graphics.drawable.Drawable.Callback;
import android.support.v7.widget.AppCompatTextView;
import android.util.AttributeSet;
public class EmojiTextView extends AppCompatTextView {
private final Callback callback = new PostInvalidateCallback(this);
public EmojiTextView(Context context) {
super(context);
}
@ -20,7 +23,7 @@ public class EmojiTextView extends AppCompatTextView {
@Override public void setText(CharSequence text, BufferType type) {
super.setText(EmojiProvider.getInstance(getContext()).emojify(text,
EmojiProvider.EMOJI_SMALL,
new PostInvalidateCallback(this)),
callback),
BufferType.SPANNABLE);
}
}