use of cn.hadcn.keyboard.emoticon.EmoticonSetBean in project ChatKeyboard by CPPAlien.
the class ChatKeyboardLayout method initEmoticonsDB.
public static void initEmoticonsDB(final Context context, final boolean isShowEmoji, final List<EmoticonEntity> emoticonEntities) {
new Thread(new Runnable() {
@Override
public void run() {
EmoticonDBHelper emoticonDbHelper = EmoticonHandler.getInstance(context).getEmoticonDbHelper();
if (isShowEmoji) {
List<EmoticonBean> emojiArray = Utils.parseData(DefEmoticons.emojiArray, EmoticonBean.FACE_TYPE_NORMAL, EmoticonBase.Scheme.DRAWABLE);
EmoticonSetBean emojiEmoticonSetBean = new EmoticonSetBean("emoji", 3, 7);
emojiEmoticonSetBean.setIconUri("drawable://icon_emoji");
emojiEmoticonSetBean.setItemPadding(25);
emojiEmoticonSetBean.setVerticalSpacing(10);
emojiEmoticonSetBean.setShowDelBtn(true);
emojiEmoticonSetBean.setEmoticonList(emojiArray);
emoticonDbHelper.insertEmoticonSet(emojiEmoticonSetBean);
}
List<EmoticonSetBean> emoticonSetBeans = new ArrayList<>();
for (EmoticonEntity entity : emoticonEntities) {
try {
EmoticonSetBean bean = Utils.ParseEmoticons(context, entity.getPath(), entity.getScheme());
emoticonSetBeans.add(bean);
} catch (IOException e) {
HadLog.e(String.format("read %s config.xml error", entity.getPath()), e);
} catch (XmlPullParserException e) {
HadLog.e(String.format("parse %s config.xml error", entity.getPath()), e);
}
}
for (EmoticonSetBean setBean : emoticonSetBeans) {
emoticonDbHelper.insertEmoticonSet(setBean);
}
emoticonDbHelper.cleanup();
if (emoticonSetBeans.size() == emoticonEntities.size()) {
Utils.setIsInitDb(context, true);
}
}
}).start();
}
Aggregations