PageRenderTime 3200ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/QingTingFanBianYi/src/fm/qingting/qtradio/social/UserProfile.java

https://gitlab.com/qt-prometheus/qt-prometheus
Java | 493 lines | 460 code | 29 blank | 4 comment | 184 complexity | e3184da9e4cfa60a2af6bfaca33dc128 MD5 | raw file
  1. package fm.qingting.qtradio.social;
  2. import com.alibaba.fastjson.JSONArray;
  3. import com.alibaba.fastjson.JSONObject;
  4. import fm.qingting.framework.data.IResultRecvHandler;
  5. import fm.qingting.framework.data.IResultToken;
  6. import fm.qingting.framework.data.Result;
  7. import fm.qingting.qtradio.im.IMAgent;
  8. import fm.qingting.qtradio.im.IMContacts;
  9. import fm.qingting.qtradio.im.IMDataLoadWrapper;
  10. import fm.qingting.qtradio.im.info.GroupInfo;
  11. import fm.qingting.qtradio.model.InfoManager;
  12. import fm.qingting.qtradio.model.Node;
  13. import fm.qingting.qtradio.model.RootNode;
  14. import fm.qingting.qtradio.model.RootNode.IInfoUpdateEventListener;
  15. import fm.qingting.qtradio.model.SharedCfg;
  16. import fm.qingting.qtradio.room.SnsInfo;
  17. import fm.qingting.qtradio.room.UserInfo;
  18. import java.util.ArrayList;
  19. import java.util.HashMap;
  20. import java.util.List;
  21. import java.util.Map;
  22. public class UserProfile
  23. implements IResultRecvHandler
  24. {
  25. public List<Node> lstFavNodes;
  26. private List<UserInfo> lstFollowers;
  27. private List<UserInfo> lstFollowings;
  28. private List<GroupInfo> lstGroups;
  29. private int mFollowerCnt;
  30. private int mFollowingCnt;
  31. private UserInfo mUserInfo;
  32. private String mUserKey = "";
  33. private void addGroup(GroupInfo paramGroupInfo)
  34. {
  35. if (paramGroupInfo == null)
  36. return;
  37. if (this.lstGroups == null)
  38. this.lstGroups = new ArrayList();
  39. int i = 0;
  40. while (true)
  41. {
  42. if (i >= this.lstGroups.size())
  43. break label71;
  44. if (((GroupInfo)this.lstGroups.get(i)).groupId.equalsIgnoreCase(paramGroupInfo.groupId))
  45. break;
  46. i += 1;
  47. }
  48. label71: this.lstGroups.add(paramGroupInfo);
  49. }
  50. private UserInfo parseUserInfo(JSONObject paramJSONObject)
  51. {
  52. if (paramJSONObject != null)
  53. {
  54. UserInfo localUserInfo = new UserInfo();
  55. localUserInfo.userKey = paramJSONObject.getString("userid");
  56. localUserInfo.snsInfo.sns_avatar = paramJSONObject.getString("avatar");
  57. localUserInfo.snsInfo.sns_name = paramJSONObject.getString("username");
  58. localUserInfo.snsInfo.signature = paramJSONObject.getString("signature");
  59. localUserInfo.snsInfo.age = paramJSONObject.getIntValue("age");
  60. localUserInfo.snsInfo.sns_gender = paramJSONObject.getString("gender");
  61. String str = paramJSONObject.getString("is_blocked");
  62. if ((str != null) && (!str.equalsIgnoreCase("")))
  63. if (Integer.valueOf(str).intValue() != 0)
  64. break label155;
  65. label155: for (localUserInfo.isBlocked = false; ; localUserInfo.isBlocked = true)
  66. {
  67. paramJSONObject = paramJSONObject.getString("level");
  68. if ((paramJSONObject != null) && (!paramJSONObject.equalsIgnoreCase("")))
  69. localUserInfo.level = Integer.valueOf(paramJSONObject).intValue();
  70. return localUserInfo;
  71. }
  72. }
  73. return null;
  74. }
  75. public void clearAll()
  76. {
  77. if (this.lstFollowers != null)
  78. this.lstFollowers.clear();
  79. if (this.lstFollowings != null)
  80. this.lstFollowings.clear();
  81. if (this.lstGroups != null)
  82. this.lstGroups.clear();
  83. this.mFollowerCnt = 0;
  84. this.mFollowingCnt = 0;
  85. }
  86. public void followGroup(String paramString)
  87. {
  88. if ((paramString != null) && (this.mUserKey != null) && (!this.mUserKey.equalsIgnoreCase("")))
  89. IMDataLoadWrapper.addGroup(this.mUserKey, paramString, this);
  90. GroupInfo localGroupInfo = IMAgent.getInstance().getGroupInfo(paramString);
  91. if (localGroupInfo == null)
  92. IMAgent.getInstance().loadGroupInfo(paramString, null);
  93. while (true)
  94. {
  95. if ((this.lstGroups != null) && (localGroupInfo != null))
  96. this.lstGroups.add(localGroupInfo);
  97. return;
  98. IMContacts.getInstance().addWatchContacts(localGroupInfo);
  99. }
  100. }
  101. public void followUser(UserInfo paramUserInfo)
  102. {
  103. if (paramUserInfo == null);
  104. do
  105. {
  106. return;
  107. if ((paramUserInfo.userKey != null) && (this.mUserKey != null) && (!this.mUserKey.equalsIgnoreCase("")))
  108. IMDataLoadWrapper.followUser(this.mUserKey, paramUserInfo.userKey, this);
  109. IMContacts.getInstance().addWatchContacts(paramUserInfo);
  110. }
  111. while ((this.lstFollowings == null) || (paramUserInfo == null));
  112. this.lstFollowings.add(paramUserInfo);
  113. }
  114. public int getContactsCnt()
  115. {
  116. int i = 0;
  117. if (this.lstFollowers != null)
  118. i = 0 + this.lstFollowers.size();
  119. int j = i;
  120. if (this.lstFollowings != null)
  121. j = i + this.lstFollowings.size();
  122. return j;
  123. }
  124. public int getFollowerCnt()
  125. {
  126. if (this.lstFollowers == null)
  127. return 0;
  128. return this.lstFollowers.size();
  129. }
  130. public List<UserInfo> getFollowers()
  131. {
  132. return this.lstFollowers;
  133. }
  134. public int getFollowingCnt()
  135. {
  136. if (this.lstFollowings == null)
  137. return 0;
  138. return this.lstFollowings.size();
  139. }
  140. public List<UserInfo> getFollowings()
  141. {
  142. return this.lstFollowings;
  143. }
  144. public int getGroupCnt()
  145. {
  146. if (this.lstGroups == null)
  147. return 0;
  148. return this.lstGroups.size();
  149. }
  150. public List<GroupInfo> getGroups()
  151. {
  152. return this.lstGroups;
  153. }
  154. public UserInfo getUserInfo()
  155. {
  156. return this.mUserInfo;
  157. }
  158. public String getUserKey()
  159. {
  160. return this.mUserKey;
  161. }
  162. public void init()
  163. {
  164. int j = 0;
  165. List localList = IMContacts.getInstance().getWatchedGroupContacts();
  166. int i;
  167. if ((localList != null) && (localList.size() > 0))
  168. {
  169. if (this.lstGroups == null)
  170. this.lstGroups = new ArrayList();
  171. i = 0;
  172. while (i < localList.size())
  173. {
  174. this.lstGroups.add(localList.get(i));
  175. i += 1;
  176. }
  177. }
  178. localList = IMContacts.getInstance().getWatchedUserContacts();
  179. if ((localList != null) && (localList.size() > 0))
  180. {
  181. i = j;
  182. if (this.lstFollowings == null)
  183. {
  184. this.lstFollowings = new ArrayList();
  185. i = j;
  186. }
  187. while (i < localList.size())
  188. {
  189. this.lstFollowings.add(localList.get(i));
  190. IMAgent.getInstance().addBaseUserInfo(((UserInfo)localList.get(i)).userKey, ((UserInfo)localList.get(i)).snsInfo.sns_avatar, ((UserInfo)localList.get(i)).snsInfo.sns_gender);
  191. i += 1;
  192. }
  193. }
  194. }
  195. public boolean isPhoneOwner()
  196. {
  197. if (this.mUserKey == null);
  198. String str;
  199. do
  200. {
  201. return false;
  202. str = InfoManager.getInstance().getUserProfile().getUserKey();
  203. }
  204. while ((str == null) || (!str.equalsIgnoreCase(this.mUserKey)));
  205. return true;
  206. }
  207. public void loadFollowers(RootNode.IInfoUpdateEventListener paramIInfoUpdateEventListener)
  208. {
  209. if (this.mUserKey != null)
  210. IMDataLoadWrapper.loadFollowerList(this.mUserKey, this);
  211. if (paramIInfoUpdateEventListener != null)
  212. InfoManager.getInstance().root().registerInfoUpdateListener(paramIInfoUpdateEventListener, 4);
  213. }
  214. public void loadFollowings(RootNode.IInfoUpdateEventListener paramIInfoUpdateEventListener)
  215. {
  216. if (this.mUserKey != null)
  217. IMDataLoadWrapper.loadFollowingList(this.mUserKey, this);
  218. if (paramIInfoUpdateEventListener != null)
  219. InfoManager.getInstance().root().registerInfoUpdateListener(paramIInfoUpdateEventListener, 5);
  220. }
  221. public void loadUserInfo(String paramString, RootNode.IInfoUpdateEventListener paramIInfoUpdateEventListener)
  222. {
  223. IMDataLoadWrapper.loadUserInfo(paramString, this);
  224. if (paramIInfoUpdateEventListener != null)
  225. InfoManager.getInstance().root().registerInfoUpdateListener(paramIInfoUpdateEventListener, 3);
  226. }
  227. public void onRecvResult(Result paramResult, Object paramObject1, IResultToken paramIResultToken, Object paramObject2)
  228. {
  229. int j = 0;
  230. int i = 0;
  231. paramObject1 = paramIResultToken.getType();
  232. if (paramResult.getSuccess());
  233. while (true)
  234. {
  235. try
  236. {
  237. if (paramObject1.equalsIgnoreCase("get_user_followers"))
  238. {
  239. paramObject1 = (String)((HashMap)paramObject2).get("user");
  240. if ((paramObject1 != null) && (this.mUserKey != null))
  241. {
  242. if (!paramObject1.equalsIgnoreCase(this.mUserKey))
  243. return;
  244. if (this.lstFollowers == null)
  245. {
  246. this.lstFollowers = new ArrayList();
  247. paramResult = ((JSONObject)paramResult.getData()).getJSONArray("data");
  248. if (paramResult == null)
  249. continue;
  250. if (i < paramResult.size())
  251. {
  252. paramObject1 = parseUserInfo(paramResult.getJSONObject(i));
  253. if (paramObject1 == null)
  254. continue;
  255. this.lstFollowers.add(paramObject1);
  256. continue;
  257. }
  258. }
  259. else
  260. {
  261. this.lstFollowers.clear();
  262. continue;
  263. }
  264. this.mFollowerCnt = this.lstFollowers.size();
  265. InfoManager.getInstance().root().setInfoUpdate(4);
  266. }
  267. }
  268. else
  269. {
  270. boolean bool;
  271. if (paramObject1.equalsIgnoreCase("get_user_followings"))
  272. {
  273. paramObject1 = (String)((HashMap)paramObject2).get("user");
  274. if ((paramObject1 != null) && (this.mUserKey != null) && (paramObject1.equalsIgnoreCase(this.mUserKey)))
  275. {
  276. if (this.lstFollowings == null)
  277. {
  278. this.lstFollowings = new ArrayList();
  279. paramResult = ((JSONObject)paramResult.getData()).getJSONArray("data");
  280. if (paramResult == null)
  281. continue;
  282. bool = isPhoneOwner();
  283. i = j;
  284. if (i < paramResult.size())
  285. {
  286. paramObject1 = parseUserInfo(paramResult.getJSONObject(i));
  287. if (paramObject1 == null)
  288. break label827;
  289. this.lstFollowings.add(paramObject1);
  290. if (!bool)
  291. break label827;
  292. IMContacts.getInstance().addWatchContacts(paramObject1);
  293. break label827;
  294. }
  295. }
  296. else
  297. {
  298. this.lstFollowings.clear();
  299. continue;
  300. }
  301. this.mFollowingCnt = this.lstFollowings.size();
  302. InfoManager.getInstance().root().setInfoUpdate(5);
  303. }
  304. }
  305. else if (paramObject1.equalsIgnoreCase("get_user_info"))
  306. {
  307. paramObject1 = (String)((HashMap)paramObject2).get("user");
  308. if ((paramObject1 != null) && (this.mUserKey != null) && (paramObject1.equalsIgnoreCase(this.mUserKey)))
  309. {
  310. paramResult = ((JSONObject)paramResult.getData()).getJSONObject("data");
  311. if ((paramResult != null) && (this.mUserKey != null))
  312. {
  313. if (this.mUserInfo == null)
  314. this.mUserInfo = new UserInfo();
  315. this.mUserInfo.userKey = this.mUserKey;
  316. paramObject1 = paramResult.getString("avatar");
  317. if ((paramObject1 != null) && (!paramObject1.equalsIgnoreCase("")))
  318. this.mUserInfo.snsInfo.sns_avatar = paramObject1;
  319. paramObject1 = paramResult.getString("username");
  320. if ((paramObject1 != null) && (!paramObject1.equalsIgnoreCase("")))
  321. this.mUserInfo.snsInfo.sns_name = paramObject1;
  322. paramObject1 = paramResult.getString("signature");
  323. if ((paramObject1 != null) && (!paramObject1.equalsIgnoreCase("")))
  324. this.mUserInfo.snsInfo.signature = paramObject1;
  325. paramObject1 = paramResult.getString("is_blocked");
  326. if ((paramObject1 != null) && (!paramObject1.equalsIgnoreCase("")))
  327. {
  328. if (Integer.valueOf(paramObject1).intValue() == 0)
  329. this.mUserInfo.isBlocked = false;
  330. }
  331. else
  332. {
  333. paramObject1 = paramResult.getString("level");
  334. if ((paramObject1 != null) && (!paramObject1.equalsIgnoreCase("")))
  335. this.mUserInfo.level = Integer.valueOf(paramObject1).intValue();
  336. this.mFollowerCnt = paramResult.getIntValue("num_of_follower");
  337. this.mFollowingCnt = paramResult.getIntValue("num_of_following");
  338. this.mUserInfo.snsInfo.sns_gender = paramResult.getString("gender");
  339. paramResult = paramResult.getJSONArray("groups");
  340. if (paramResult == null)
  341. continue;
  342. if (this.lstGroups == null)
  343. this.lstGroups = new ArrayList();
  344. bool = isPhoneOwner();
  345. i = 0;
  346. if (i >= paramResult.size())
  347. continue;
  348. paramObject1 = new GroupInfo();
  349. paramIResultToken = paramResult.getJSONObject(i);
  350. paramObject1.groupId = paramIResultToken.getString("id");
  351. paramObject1.groupName = paramIResultToken.getString("groupname");
  352. paramObject1.groupDesc = paramIResultToken.getString("description");
  353. addGroup(paramObject1);
  354. if (!bool)
  355. break label836;
  356. IMContacts.getInstance().addWatchContacts(paramObject1);
  357. break label836;
  358. }
  359. this.mUserInfo.isBlocked = true;
  360. continue;
  361. if (bool)
  362. IMContacts.getInstance().updateGroupInfo();
  363. InfoManager.getInstance().root().setInfoUpdate(3);
  364. }
  365. }
  366. }
  367. }
  368. return;
  369. i += 1;
  370. continue;
  371. }
  372. catch (Exception paramResult)
  373. {
  374. return;
  375. }
  376. label827: i += 1;
  377. continue;
  378. label836: i += 1;
  379. }
  380. }
  381. public void setUserInfo(UserInfo paramUserInfo)
  382. {
  383. this.mUserInfo = paramUserInfo;
  384. if (paramUserInfo != null)
  385. this.mUserKey = paramUserInfo.userKey;
  386. }
  387. public void setUserKey(String paramString)
  388. {
  389. this.mUserKey = paramString;
  390. }
  391. public void setUserKey(String paramString, int paramInt)
  392. {
  393. this.mUserKey = paramString;
  394. if (paramInt == 0)
  395. SharedCfg.getInstance().setWeiboSocialUserKey(paramString);
  396. do
  397. {
  398. return;
  399. if (paramInt == 1)
  400. {
  401. SharedCfg.getInstance().setTencentSocialUserKey(paramString);
  402. return;
  403. }
  404. if (paramInt == 5)
  405. {
  406. SharedCfg.getInstance().setQQUserKey(paramString);
  407. return;
  408. }
  409. }
  410. while (paramInt != 6);
  411. SharedCfg.getInstance().setWeChatUserKey(paramString);
  412. }
  413. public void unfollowGroup(String paramString)
  414. {
  415. if ((paramString != null) && (this.mUserKey != null) && (!this.mUserKey.equalsIgnoreCase("")))
  416. IMDataLoadWrapper.exitGroup(this.mUserKey, paramString, this);
  417. IMContacts.getInstance().unWatchGroupContacts(paramString);
  418. int i;
  419. if (this.lstGroups != null)
  420. i = 0;
  421. while (true)
  422. {
  423. if (i < this.lstGroups.size())
  424. {
  425. if (((GroupInfo)this.lstGroups.get(i)).groupId.equalsIgnoreCase(paramString))
  426. this.lstGroups.remove(i);
  427. }
  428. else
  429. {
  430. IMAgent.getInstance().leaveGroup(paramString);
  431. return;
  432. }
  433. i += 1;
  434. }
  435. }
  436. public void unfollowUser(String paramString)
  437. {
  438. if ((paramString != null) && (this.mUserKey != null) && (!this.mUserKey.equalsIgnoreCase("")))
  439. IMDataLoadWrapper.unFollowUser(this.mUserKey, paramString, this);
  440. IMContacts.getInstance().unWatchUserContacts(paramString);
  441. int i;
  442. if ((this.lstFollowings != null) && (paramString != null))
  443. i = 0;
  444. while (true)
  445. {
  446. if (i < this.lstFollowings.size())
  447. {
  448. if ((((UserInfo)this.lstFollowings.get(i)).userKey != null) && (((UserInfo)this.lstFollowings.get(i)).userKey.equalsIgnoreCase(paramString)))
  449. this.lstFollowings.remove(i);
  450. }
  451. else
  452. return;
  453. i += 1;
  454. }
  455. }
  456. public void updateUserInfo()
  457. {
  458. IMDataLoadWrapper.updateUserInfo(this, this);
  459. }
  460. }
  461. /* Location: C:\Users\User\dex2jar-2.0\dex\qting\classes-dex2jar.jar
  462. * Qualified Name: fm.qingting.qtradio.social.UserProfile
  463. * JD-Core Version: 0.6.2
  464. */