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