Search in sources :

Example 6 with EmoticonSetBean

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();
}
Also used : EmoticonBean(cn.hadcn.keyboard.emoticon.EmoticonBean) ArrayList(java.util.ArrayList) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) IOException(java.io.IOException) EmoticonDBHelper(cn.hadcn.keyboard.emoticon.db.EmoticonDBHelper) EmoticonSetBean(cn.hadcn.keyboard.emoticon.EmoticonSetBean)

Aggregations

EmoticonSetBean (cn.hadcn.keyboard.emoticon.EmoticonSetBean)6 EmoticonBean (cn.hadcn.keyboard.emoticon.EmoticonBean)4 ArrayList (java.util.ArrayList)4 EmoticonDBHelper (cn.hadcn.keyboard.emoticon.db.EmoticonDBHelper)2 IOException (java.io.IOException)2 Cursor (android.database.Cursor)1 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1 SQLiteException (android.database.sqlite.SQLiteException)1 Paint (android.graphics.Paint)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 View (android.view.View)1 GridView (android.widget.GridView)1 HorizontalScrollView (android.widget.HorizontalScrollView)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 RelativeLayout (android.widget.RelativeLayout)1 EmoticonsKeyboardBuilder (cn.hadcn.keyboard.emoticon.util.EmoticonsKeyboardBuilder)1 InputStream (java.io.InputStream)1 XmlPullParser (org.xmlpull.v1.XmlPullParser)1 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)1