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;
}
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);
}
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);
}
}
}
};
}
Aggregations