liuzhenxing1118 4 ماه پیش
والد
کامیت
7b91e29683

+ 20 - 11
app/src/main/java/com/xplora/xpchat/manager/DataManager.java

@@ -66,17 +66,26 @@ public class DataManager {
     }
 
     public void initEmoji() {
-        String jsonFile = ResUtils.getJSONFile("emoji.json");
-        //Json的解析类对象
-        JsonParser parser = new JsonParser();
-        //将JSON的String 转成一个JsonArray对象
-        JsonArray jsonArray = parser.parse(jsonFile).getAsJsonArray();
-        Gson gson = new Gson();
-        //加强for循环遍历JsonArray
-        for (JsonElement user : jsonArray) {
-            //使用GSON,直接转成Bean对象
-            EmojiBean bean = gson.fromJson(user, EmojiBean.class);
-            mEmojiList.add(bean);
+        if (true) {
+            for (int i = 1001; i <= 1018; i++) {
+                EmojiBean bean = new EmojiBean();
+                bean.id = "emo_" + String.valueOf(i);
+                bean.keyword = bean.id;
+                mEmojiList.add(bean);
+            }
+        } else {
+            String jsonFile = ResUtils.getJSONFile("emoji.json");
+            //Json的解析类对象
+            JsonParser parser = new JsonParser();
+            //将JSON的String 转成一个JsonArray对象
+            JsonArray jsonArray = parser.parse(jsonFile).getAsJsonArray();
+            Gson gson = new Gson();
+            //加强for循环遍历JsonArray
+            for (JsonElement user : jsonArray) {
+                //使用GSON,直接转成Bean对象
+                EmojiBean bean = gson.fromJson(user, EmojiBean.class);
+                mEmojiList.add(bean);
+            }
         }
         Log.d(TAG, "initEmoji: " + mEmojiList.size());
     }

+ 0 - 24
app/src/main/java/com/xplora/xpchat/manager/DatabaseUtils.java

@@ -126,30 +126,6 @@ public class DatabaseUtils {
         return arrayList;
     }
 
-    @SuppressLint("Range")
-    public List<EmojiBean> loadEmoji() {
-        ArrayList<EmojiBean> arrayList = new ArrayList<>();
-        //数据库
-        Uri uri = Uri.parse(MetaData.DB_EMOJI);
-        Cursor cursor = ChatApplication.getsContext().getContentResolver().query(uri, null, null, null, null);
-        if (cursor == null)
-            return arrayList;
-        if (!cursor.moveToFirst()) {
-            cursor.close();
-            return arrayList;
-        }
-        do {
-            EmojiBean bean = new EmojiBean();
-            bean.id = cursor.getString(cursor.getColumnIndex("id"));
-            bean.keyword = cursor.getString(cursor.getColumnIndex("keyword"));
-            bean.url = cursor.getString(cursor.getColumnIndex("url"));
-            bean.path = cursor.getString(cursor.getColumnIndex("path"));
-            arrayList.add(bean);
-        } while (cursor.moveToNext());
-        cursor.close();
-        return arrayList;
-    }
-
     @SuppressLint("Range")
     public ArrayList<MessageBean> loadNewMessages(int chatType, String chatId) {
         if (Macros.DEBUG) {

+ 1 - 2
app/src/main/java/com/xplora/xpchat/model/EmojiBean.java

@@ -1,8 +1,7 @@
 package com.xplora.xpchat.model;
 
 public class EmojiBean extends BaseBean {
-    //服务器下载
-    public String id = ""; //服务器id
+    public String id = "";
     public String keyword = "";
     public String url = "";
     public String path = "";