Search in sources :

Example 11 with EmoticonEntity

use of sj.keyboard.data.EmoticonEntity in project XhsEmoticonsKeyboard by w446108264.

the class ParseDataUtils method ParseXhsData.

public static ArrayList<EmoticonEntity> ParseXhsData(String[] arry, ImageBase.Scheme scheme) {
    try {
        ArrayList<EmoticonEntity> emojis = new ArrayList<>();
        for (int i = 0; i < arry.length; i++) {
            if (!TextUtils.isEmpty(arry[i])) {
                String temp = arry[i].trim().toString();
                String[] text = temp.split(",");
                if (text != null && text.length == 2) {
                    String fileName;
                    if (scheme == ImageBase.Scheme.DRAWABLE) {
                        if (text[0].contains(".")) {
                            fileName = scheme.toUri(text[0].substring(0, text[0].lastIndexOf(".")));
                        } else {
                            fileName = scheme.toUri(text[0]);
                        }
                    } else {
                        fileName = scheme.toUri(text[0]);
                    }
                    String content = text[1];
                    EmoticonEntity bean = new EmoticonEntity(fileName, content);
                    emojis.add(bean);
                }
            }
        }
        return emojis;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) EmoticonEntity(sj.keyboard.data.EmoticonEntity) IOException(java.io.IOException)

Example 12 with EmoticonEntity

use of sj.keyboard.data.EmoticonEntity in project XhsEmoticonsKeyboard by w446108264.

the class XmlUtil method ParserXml.

public EmoticonPageSetEntity<EmoticonEntity> ParserXml(String filePath, InputStream inStream) {
    String arrayParentKey = "EmoticonBean";
    boolean isChildCheck = false;
    EmoticonPageSetEntity.Builder<EmoticonEntity> emoticonPageSetEntity = new EmoticonPageSetEntity.Builder<>();
    ArrayList<EmoticonEntity> emoticonList = new ArrayList<>();
    emoticonPageSetEntity.setEmoticonList(emoticonList);
    EmoticonEntity emoticonBeanTemp = null;
    if (null != inStream) {
        XmlPullParser pullParser = Xml.newPullParser();
        try {
            pullParser.setInput(inStream, "UTF-8");
            int event = pullParser.getEventType();
            while (event != XmlPullParser.END_DOCUMENT) {
                switch(event) {
                    case XmlPullParser.START_DOCUMENT:
                        break;
                    case XmlPullParser.START_TAG:
                        String skeyName = pullParser.getName();
                        /**
                             * EmoticonBeans data
                             */
                        if (isChildCheck && emoticonBeanTemp != null) {
                            if (skeyName.equals("eventType")) {
                                try {
                                    String value = pullParser.nextText();
                                    emoticonBeanTemp.setEventType(Integer.parseInt(value));
                                } catch (NumberFormatException e) {
                                }
                            } else if (skeyName.equals("iconUri")) {
                                String value = pullParser.nextText();
                                emoticonBeanTemp.setIconUri("file://" + filePath + "/" + value);
                            } else if (skeyName.equals("content")) {
                                String value = pullParser.nextText();
                                emoticonBeanTemp.setContent(value);
                            }
                        } else /**
                             * EmoticonSet data
                             */
                        {
                            try {
                                if (skeyName.equals("name")) {
                                    String value = pullParser.nextText();
                                    emoticonPageSetEntity.setSetName(value);
                                } else if (skeyName.equals("line")) {
                                    String value = pullParser.nextText();
                                    emoticonPageSetEntity.setLine(Integer.parseInt(value));
                                } else if (skeyName.equals("row")) {
                                    String value = pullParser.nextText();
                                    emoticonPageSetEntity.setRow(Integer.parseInt(value));
                                } else if (skeyName.equals("iconUri")) {
                                    String value = pullParser.nextText();
                                    emoticonPageSetEntity.setIconUri(value);
                                } else if (skeyName.equals("isShowDelBtn")) {
                                    String value = pullParser.nextText();
                                    EmoticonPageEntity.DelBtnStatus delBtnStatus;
                                    if (Integer.parseInt(value) == 1) {
                                        delBtnStatus = EmoticonPageEntity.DelBtnStatus.FOLLOW;
                                    } else if (Integer.parseInt(value) == 2) {
                                        delBtnStatus = EmoticonPageEntity.DelBtnStatus.LAST;
                                    } else {
                                        delBtnStatus = EmoticonPageEntity.DelBtnStatus.GONE;
                                    }
                                    emoticonPageSetEntity.setShowDelBtn(delBtnStatus);
                                }
                            } catch (NumberFormatException e) {
                                e.printStackTrace();
                            }
                        }
                        if (skeyName.equals(arrayParentKey)) {
                            isChildCheck = true;
                            emoticonBeanTemp = new EmoticonEntity();
                        }
                        break;
                    case XmlPullParser.END_TAG:
                        String ekeyName = pullParser.getName();
                        if (isChildCheck && ekeyName.equals(arrayParentKey)) {
                            isChildCheck = false;
                            emoticonList.add(emoticonBeanTemp);
                        }
                        break;
                    default:
                        break;
                }
                event = pullParser.next();
            }
            return new EmoticonPageSetEntity(emoticonPageSetEntity);
        } catch (XmlPullParserException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return new EmoticonPageSetEntity(emoticonPageSetEntity);
}
Also used : EmoticonEntity(sj.keyboard.data.EmoticonEntity) ArrayList(java.util.ArrayList) XmlPullParser(org.xmlpull.v1.XmlPullParser) EmoticonPageEntity(sj.keyboard.data.EmoticonPageEntity) IOException(java.io.IOException) EmoticonPageSetEntity(sj.keyboard.data.EmoticonPageSetEntity) XmlPullParserException(org.xmlpull.v1.XmlPullParserException)

Example 13 with EmoticonEntity

use of sj.keyboard.data.EmoticonEntity in project XhsEmoticonsKeyboard by w446108264.

the class QqUtils method getCommonEmoticonClickListener.

public static EmoticonClickListener getCommonEmoticonClickListener(final EditText editText) {
    return new EmoticonClickListener() {

        @Override
        public void onEmoticonClick(Object o, int actionType, boolean isDelBtn) {
            if (isDelBtn) {
                QqUtils.delClick(editText);
            } else {
                if (o == null) {
                    return;
                }
                if (actionType == Constants.EMOTICON_CLICK_TEXT) {
                    String content = null;
                    if (o instanceof EmojiBean) {
                        content = ((EmojiBean) o).emoji;
                    } else if (o instanceof EmoticonEntity) {
                        content = ((EmoticonEntity) o).getContent();
                    }
                    if (TextUtils.isEmpty(content)) {
                        return;
                    }
                    int index = editText.getSelectionStart();
                    Editable editable = editText.getText();
                    editable.insert(index, content);
                }
            }
        }
    };
}
Also used : EmoticonClickListener(sj.keyboard.interfaces.EmoticonClickListener) EmojiBean(com.sj.emoji.EmojiBean) EmoticonEntity(sj.keyboard.data.EmoticonEntity) Editable(android.text.Editable)

Aggregations

EmoticonEntity (sj.keyboard.data.EmoticonEntity)13 IOException (java.io.IOException)7 View (android.view.View)5 TextView (android.widget.TextView)4 ArrayList (java.util.ArrayList)4 EmoticonPageSetEntity (sj.keyboard.data.EmoticonPageSetEntity)3 Editable (android.text.Editable)2 SpannableStringBuilder (android.text.SpannableStringBuilder)2 ViewGroup (android.view.ViewGroup)2 EmojiBean (com.sj.emoji.EmojiBean)2 EmoticonClickListener (sj.keyboard.interfaces.EmoticonClickListener)2 EmoticonDisplayListener (sj.keyboard.interfaces.EmoticonDisplayListener)2 EmoticonPageView (sj.keyboard.widget.EmoticonPageView)2 ImageView (android.widget.ImageView)1 BigEmoticonsAdapter (com.xhsemoticonskeyboard.common.adapter.emoticonadapter.BigEmoticonsAdapter)1 BigEmoticonsAndTitleAdapter (com.xhsemoticonskeyboard.common.adapter.emoticonadapter.BigEmoticonsAndTitleAdapter)1 SimpleAppsGridView (com.xhsemoticonskeyboard.common.widget.SimpleAppsGridView)1 BufferedReader (java.io.BufferedReader)1 InputStreamReader (java.io.InputStreamReader)1 HashMap (java.util.HashMap)1