Set Span with custom Emoji
robertfernanV opened this issue · comments
Hello, I'm using google translate. If i create emoji custom sdcard i show it and then erase that emoji the emojicon EmojiconTextView does not resize well
This is my construct of EmojiSpan
public EmojiconSpan(Context context,int routeSd, int size, int aligment, int textSize, int isSd, int isDonw){
super(aligment);
mContext= context;
mWidth = mHeight = mSize = size;
mTextSize = textSize;
mResourceId =routeSd;
misSd = isSd;
isDownload = isDonw;
}
This is my code to create the span
text.setSpan(new EmojiconSpan(context,Integer.parseInt(row.getCodeEmoji()),emojiSize,emojiAlignment,textSize,1,1)
,0,comparar.length(),Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
This is my code to getDrawable
```
public Drawable getDrawable() {
if (mDrawable == null) {
try {
if((misSd>0)&&(isDownload==0)){
DataEmojiHelper dataEmojiHelper = new DataEmojiHelper(mContext);
Emojicon row = dataEmojiHelper.getEmojiByCodeEmojiTemp(mResourceId);
mDrawable = Drawable.createFromPath(String.valueOf(row.getRouteEmoji()));
}
if((misSd>0)&&(isDownload>0)){
DataEmojiHelper dataEmojiHelper = new DataEmojiHelper(mContext);
Emojicon row = dataEmojiHelper.getEmojiByCodeEmoji(mResourceId);
mDrawable = Drawable.createFromPath(String.valueOf(row.getRouteEmoji()));
}
if((misSd==-1)&&(isDownload==0)){
if(mResourceId!=-999){
mDrawable = mContext.getResources().getDrawable(mResourceId);
}else{
mDrawable = mContext.getResources().getDrawable(R.drawable.emojicon_download);
}
}
mHeight = mSize;
mWidth = mHeight * mDrawable.getIntrinsicWidth() / mDrawable.getIntrinsicHeight();
mTop = Math.max((mTextSize - mHeight) / 2, 0);
mDrawable.setBounds(0, mTop, mWidth, mTop + mHeight);
} catch (Exception e) {
// swallow
}
}
return mDrawable;
}
thanks for your help