/** {@inheritDoc} */ public override void onHttpStatusOK(QQHttpResponse response) { JSONObject json = new JSONObject(response.getResponseString()); int retcode = json.getInt("retcode"); QQStore store = getContext().getStore(); if (retcode == 0) { // 处理好友列表 JSONObject results = json.getJSONObject("result"); // 获取JSON列表信息 JSONArray jsonCategories = results.getJSONArray("categories"); // 获取JSON好友基本信息列表 flag/uin/categories JSONArray jsonFriends = results.getJSONArray("friends"); // face/flag/nick/uin JSONArray jsonInfo = results.getJSONArray("info"); // uin/markname/ JSONArray jsonMarknames = results.getJSONArray("marknames"); // vip_level/u/is_vip JSONArray jsonVipinfo = results.getJSONArray("vipinfo"); // 默认好友列表 QQCategory c = new QQCategory(); c.setIndex(0); c.setName("我的好友"); c.setSort(0); store.addCategory(c); // 初始化好友列表 for (int i = 0; i < jsonCategories.length(); i++) { JSONObject jsonCategory = jsonCategories.getJSONObject(i); QQCategory qqc = new QQCategory(); qqc.setIndex(jsonCategory.getInt("index")); qqc.setName(jsonCategory.getString("name")); qqc.setSort(jsonCategory.getInt("sort")); store.addCategory(qqc); } // 处理好友基本信息列表 flag/uin/categories for (int i = 0; i < jsonFriends.length(); i++) { QQBuddy buddy = new QQBuddy(); JSONObject jsonFriend = jsonFriends.getJSONObject(i); long uin = jsonFriend.getLong("uin"); buddy.setUin(uin); buddy.setStatus(QQStatus.OFFLINE); // 添加到列表中 int category = jsonFriend.getInt("categories"); QQCategory qqCategory = store.getCategoryByIndex(category); buddy.setCategory(qqCategory); qqCategory.getBuddyList().Add(buddy); // 记录引用 store.addBuddy(buddy); } // face/flag/nick/uin for (int i = 0; i < jsonInfo.length(); i++) { JSONObject info = jsonInfo.getJSONObject(i); long uin = info.getLong("uin"); QQBuddy buddy = store.getBuddyByUin(uin); buddy.setNickname(info.getString("nick")); } // uin/markname for (int i = 0; i < jsonMarknames.length(); i++) { JSONObject jsonMarkname = jsonMarknames.getJSONObject(i); long uin = jsonMarkname.getLong("uin"); QQBuddy buddy = store.getBuddyByUin(uin); if(buddy != null){ buddy.setMarkname(jsonMarkname.getString("markname")); } } // vip_level/u/is_vip for (int i = 0; i < jsonVipinfo.length(); i++) { JSONObject vipInfo = jsonVipinfo.getJSONObject(i); long uin = vipInfo.getLong("u"); QQBuddy buddy = store.getBuddyByUin(uin); buddy.setVipLevel(vipInfo.getInt("vip_level")); int isVip = vipInfo.getInt("is_vip"); if(isVip != 0) { buddy.setVip(true); } else { buddy.setVip(false); } } notifyActionEvent(QQActionEvent.Type.EVT_OK, store.getCategoryList()); } else { notifyActionEvent(QQActionEvent.Type.EVT_ERROR, null); } }
/** * <p>deleteCategory.</p> * * @param category a {@link iqq.im.bean.QQCategory} object. */ public void deleteCategory(QQCategory category) { categoryDictionary.Remove(category.getIndex()); }
/** * <p>addCategory.</p> * * @param category a {@link iqq.im.bean.QQCategory} object. */ public void addCategory(QQCategory category) { categoryDictionary.Add(category.getIndex(), category); }
/** * <p>Setter for the field <code>category</code>.</p> * * @param category a {@link iqq.im.bean.QQCategory} object. */ public void setCategory(QQCategory category) { this.category = category; }