public static Spannable filterFromResource(Context context,Spannable spannable,int fontSize,String headName,EmojiDisplayListener emojiDisplayListener){
  if (spannable == null) {
    return null;
  }
  Matcher m=getMatcher(spannable.toString());
  if (m != null) {
    while (m.find()) {
      String emojiHex=Integer.toHexString(Character.codePointAt(m.group(),0));
      if (emojiDisplayListener == null) {
        Drawable drawable=getDrawable(context,headName + emojiHex);
        if (drawable != null) {
          int itemHeight;
          int itemWidth;
          if (fontSize == WRAP_DRAWABLE) {
            itemHeight=drawable.getIntrinsicHeight();
            itemWidth=drawable.getIntrinsicWidth();
          }
 else {
            itemHeight=fontSize;
            itemWidth=fontSize;
          }
          drawable.setBounds(0,0,itemHeight,itemWidth);
          EmojiSpan imageSpan=new EmojiSpan(drawable);
          spannable.setSpan(imageSpan,m.start(),m.end(),Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
        }
      }
 else {
        emojiDisplayListener.onEmojiDisplay(context,spannable,headName + emojiHex,fontSize,m.start(),m.end());
      }
    }
  }
  return spannable;
}

public static Spannable filterFromResource ( Context context , Spannable spannable , int fontSize , String headName , EmojiDisplayListener emojiDisplayListener ) { if ( spannable == null ) { return null ; } Matcher m = getMatcher ( spannable . toString ( ) ) ; if ( m != null ) { while ( m . find ( ) ) { String emojiHex = Integer . toHexString ( Character . codePointAt ( m . group ( ) , 0 ) ) ; if ( emojiDisplayListener == null ) { Drawable drawable = getDrawable ( context , headName + emojiHex ) ; if ( drawable != null ) { int itemHeight ; int itemWidth ; if ( fontSize == WRAP_DRAWABLE ) { itemHeight = drawable . getIntrinsicHeight ( ) ; itemWidth = drawable . getIntrinsicWidth ( ) ; } else { itemHeight = fontSize ; itemWidth = fontSize ; } drawable . setBounds ( 0 , 0 , itemHeight , itemWidth ) ; EmojiSpan imageSpan = new EmojiSpan ( drawable ) ; spannable . setSpan ( imageSpan , m . start ( ) , m . end ( ) , Spannable . SPAN_INCLUSIVE_EXCLUSIVE ) ; } } else { emojiDisplayListener . onEmojiDisplay ( context , spannable , headName + emojiHex , fontSize , m . start ( ) , m . end ( ) ) ; } } } return spannable ; }
load emoji from resource
