Search in sources :

Example 1 with EmoticonBean

use of cn.hadcn.keyboard.emoticon.EmoticonBean in project ChatKeyboard by CPPAlien.

the class Utils method parseData.

public static List<EmoticonBean> parseData(String[] arry, long eventType, EmoticonBase.Scheme scheme) {
    try {
        ArrayList<EmoticonBean> emojis = new ArrayList<>();
        for (int i = 0; i < arry.length; i++) {
            if (!TextUtils.isEmpty(arry[i])) {
                String temp = arry[i].trim();
                String[] text = temp.split(",");
                if (text.length == 2) {
                    String fileName;
                    if (scheme == EmoticonBase.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];
                    EmoticonBean bean = new EmoticonBean(eventType, fileName, content, content);
                    emojis.add(bean);
                }
            }
        }
        return emojis;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Also used : EmoticonBean(cn.hadcn.keyboard.emoticon.EmoticonBean) ArrayList(java.util.ArrayList) Paint(android.graphics.Paint) IOException(java.io.IOException) XmlPullParserException(org.xmlpull.v1.XmlPullParserException)

Example 2 with EmoticonBean

use of cn.hadcn.keyboard.emoticon.EmoticonBean in project ChatKeyboard by CPPAlien.

the class EmoticonDBHelper method insertEmoticonSet.

public synchronized long insertEmoticonSet(EmoticonSetBean bean) {
    SQLiteDatabase db = mOpenDbHelper.getWritableDatabase();
    long result = -1;
    if (bean == null || db == null || TextUtils.isEmpty(bean.getName())) {
        return result;
    }
    ContentValues values = new ContentValues();
    values.put(TableColumns.EmoticonSetColumns.NAME, bean.getName());
    values.put(TableColumns.EmoticonSetColumns.LINE, bean.getLine());
    values.put(TableColumns.EmoticonSetColumns.ROW, bean.getRow());
    values.put(TableColumns.EmoticonSetColumns.ICON_URI, bean.getIconUri());
    values.put(TableColumns.EmoticonSetColumns.IS_SHOWN_NAME, bean.isShownName());
    values.put(TableColumns.EmoticonSetColumns.IS_SHOW_DEL_BTN, bean.isShowDelBtn() ? 1 : 0);
    values.put(TableColumns.EmoticonSetColumns.ITEM_PADDING, bean.getItemPadding());
    values.put(TableColumns.EmoticonSetColumns.HORIZONTAL_SPACING, bean.getHorizontalSpacing());
    values.put(TableColumns.EmoticonSetColumns.VERTICAL_SPACING, bean.getVerticalSpacing());
    result = db.insert(TABLE_NAME_EMOTICONSET, null, values);
    List<EmoticonBean> emoticonList = bean.getEmoticonList();
    if (emoticonList != null) {
        String emoticonSetName = bean.getName();
        ContentValues[] contentValues = new ContentValues[emoticonList.size()];
        for (int i = 0; i < emoticonList.size(); i++) {
            contentValues[i] = createEmoticonSetContentValues(emoticonList.get(i), emoticonSetName);
        }
        insertEmoticonBeans(contentValues);
    }
    return result;
}
Also used : ContentValues(android.content.ContentValues) EmoticonBean(cn.hadcn.keyboard.emoticon.EmoticonBean) SQLiteDatabase(android.database.sqlite.SQLiteDatabase)

Example 3 with EmoticonBean

use of cn.hadcn.keyboard.emoticon.EmoticonBean in project ChatKeyboard by CPPAlien.

the class EmoticonDBHelper method queryEmoticonBean.

public synchronized EmoticonBean queryEmoticonBean(String contentStr) {
    SQLiteDatabase db = mOpenDbHelper.getReadableDatabase();
    String sql = "select * from " + TABLE_NAME_EMOTICONS + " where " + TableColumns.EmoticonColumns.TAG + " = '" + contentStr + "'";
    Cursor cursor = db.rawQuery(sql, null);
    if (cursor.getCount() > 0) {
        cursor.moveToFirst();
        long eventType = cursor.getLong(cursor.getColumnIndex(TableColumns.EmoticonColumns.EVENT_TYPE));
        String tag = cursor.getString(cursor.getColumnIndex(TableColumns.EmoticonColumns.TAG));
        String iconUri = cursor.getString(cursor.getColumnIndex(TableColumns.EmoticonColumns.ICON_URI));
        String name = cursor.getString(cursor.getColumnIndex(TableColumns.EmoticonColumns.NAME));
        return new EmoticonBean(eventType, iconUri, tag, name);
    }
    cursor.close();
    return null;
}
Also used : EmoticonBean(cn.hadcn.keyboard.emoticon.EmoticonBean) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Cursor(android.database.Cursor)

Example 4 with EmoticonBean

use of cn.hadcn.keyboard.emoticon.EmoticonBean in project ChatKeyboard by CPPAlien.

the class EmoticonDBHelper method queryEmoticonSet.

public synchronized ArrayList<EmoticonSetBean> queryEmoticonSet(String sql) {
    SQLiteDatabase db = mOpenDbHelper.getReadableDatabase();
    Cursor cursor = null;
    try {
        cursor = db.rawQuery(sql, null);
        int count = cursor.getCount();
        ArrayList<EmoticonSetBean> beanList = new ArrayList<EmoticonSetBean>();
        if (count > 0) {
            cursor.moveToFirst();
            for (int i = 0; i < count; i++) {
                String name = cursor.getString(cursor.getColumnIndex(TableColumns.EmoticonSetColumns.NAME));
                int line = cursor.getInt(cursor.getColumnIndex(TableColumns.EmoticonSetColumns.LINE));
                int row = cursor.getInt(cursor.getColumnIndex(TableColumns.EmoticonSetColumns.ROW));
                String iconUri = cursor.getString(cursor.getColumnIndex(TableColumns.EmoticonSetColumns.ICON_URI));
                boolean isshowdelbtn = cursor.getInt(cursor.getColumnIndex(TableColumns.EmoticonSetColumns.IS_SHOW_DEL_BTN)) == 1;
                int itempadding = cursor.getInt(cursor.getColumnIndex(TableColumns.EmoticonSetColumns.ITEM_PADDING));
                int horizontalspacing = cursor.getInt(cursor.getColumnIndex(TableColumns.EmoticonSetColumns.HORIZONTAL_SPACING));
                int verticalSpacing = cursor.getInt(cursor.getColumnIndex(TableColumns.EmoticonSetColumns.VERTICAL_SPACING));
                boolean isShownName = cursor.getInt(cursor.getColumnIndex(TableColumns.EmoticonSetColumns.IS_SHOWN_NAME)) == 1;
                ArrayList<EmoticonBean> emoticonList = null;
                if (!TextUtils.isEmpty(name)) {
                    String sqlGetEmoticonBean = "select * from " + TABLE_NAME_EMOTICONS + " where " + TableColumns.EmoticonColumns.EMOTICON_SET_NAME + " = '" + name + "'";
                    emoticonList = queryEmoticonBeanList(sqlGetEmoticonBean);
                }
                int pageCount = 0;
                if (emoticonList != null) {
                    int del = isshowdelbtn ? 1 : 0;
                    int everyPageMaxSum = row * line - del;
                    pageCount = (int) Math.ceil((double) emoticonList.size() / everyPageMaxSum);
                }
                EmoticonSetBean bean = new EmoticonSetBean(name, line, row, iconUri, isshowdelbtn, isShownName, itempadding, horizontalspacing, verticalSpacing, emoticonList);
                beanList.add(bean);
                cursor.moveToNext();
            }
            return beanList;
        }
    } catch (SQLiteException e) {
        Log.e(TAG, "query failed", e);
    } finally {
        if (cursor != null)
            cursor.close();
    }
    return null;
}
Also used : EmoticonBean(cn.hadcn.keyboard.emoticon.EmoticonBean) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor) SQLiteException(android.database.sqlite.SQLiteException) EmoticonSetBean(cn.hadcn.keyboard.emoticon.EmoticonSetBean)

Example 5 with EmoticonBean

use of cn.hadcn.keyboard.emoticon.EmoticonBean in project ChatKeyboard by CPPAlien.

the class EmoticonDBHelper method queryEmoticonBeanList.

public synchronized ArrayList<EmoticonBean> queryEmoticonBeanList(String sql) {
    SQLiteDatabase db = mOpenDbHelper.getReadableDatabase();
    Cursor cursor = db.rawQuery(sql, null);
    int count = cursor.getCount();
    ArrayList<EmoticonBean> beanList = new ArrayList<>();
    if (count > 0) {
        cursor.moveToFirst();
        for (int i = 0; i < count; i++) {
            long eventType = cursor.getLong(cursor.getColumnIndex(TableColumns.EmoticonColumns.EVENT_TYPE));
            String tag = cursor.getString(cursor.getColumnIndex(TableColumns.EmoticonColumns.TAG));
            String name = cursor.getString(cursor.getColumnIndex(TableColumns.EmoticonColumns.NAME));
            String iconUri = cursor.getString(cursor.getColumnIndex(TableColumns.EmoticonColumns.ICON_URI));
            EmoticonBean bean = new EmoticonBean(eventType, iconUri, tag, name);
            beanList.add(bean);
            cursor.moveToNext();
        }
    }
    cursor.close();
    return beanList;
}
Also used : EmoticonBean(cn.hadcn.keyboard.emoticon.EmoticonBean) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor)

Aggregations

EmoticonBean (cn.hadcn.keyboard.emoticon.EmoticonBean)12 ArrayList (java.util.ArrayList)6 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)4 EmoticonSetBean (cn.hadcn.keyboard.emoticon.EmoticonSetBean)4 Cursor (android.database.Cursor)3 IOException (java.io.IOException)3 Paint (android.graphics.Paint)2 LinearLayout (android.widget.LinearLayout)2 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)2 ContentValues (android.content.ContentValues)1 SQLiteException (android.database.sqlite.SQLiteException)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Drawable (android.graphics.drawable.Drawable)1 Editable (android.text.Editable)1 KeyEvent (android.view.KeyEvent)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 AbsListView (android.widget.AbsListView)1 GridView (android.widget.GridView)1 ImageView (android.widget.ImageView)1