feat:房间-公聊文本消息支持emoji
This commit is contained in:
@@ -21,6 +21,8 @@ import java.util.ArrayList;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import kotlin.jvm.functions.Function1;
|
||||
|
||||
public class MoonUtil {
|
||||
private static final float DEF_SCALE = 0.6f;
|
||||
private static final float SMALL_SCALE = 0.45F;
|
||||
@@ -99,7 +101,7 @@ public class MoonUtil {
|
||||
return mSpannableString;
|
||||
}
|
||||
|
||||
public static void replaceEmoticons(Context context, String value, SpannableStringBuilder builder) {
|
||||
public static void replaceEmoticons(Context context, String value, SpannableStringBuilder builder, Function1<Drawable,ImageSpan> imageSpanFactory) {
|
||||
if (TextUtils.isEmpty(value)) {
|
||||
value = "";
|
||||
}
|
||||
@@ -109,9 +111,10 @@ public class MoonUtil {
|
||||
int start = matcher.start();
|
||||
int end = matcher.end();
|
||||
String emot = value.substring(start, end);
|
||||
Drawable d = getEmotDrawable(context, emot, DEF_SCALE);
|
||||
Drawable d = getEmotDrawable(context, emot, SMALL_SCALE);
|
||||
if (d != null) {
|
||||
ImageSpan span = new ImageSpan(d, ImageSpan.ALIGN_BOTTOM);
|
||||
ImageSpan span = imageSpanFactory.invoke(d);
|
||||
// ImageSpan span = new ImageSpan(d, ImageSpan.ALIGN_BOTTOM);
|
||||
builder.setSpan(span, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user