PageRenderTime 564ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 0ms

/QingTingFanBianYi/src/fm/qingting/qtradio/pushmessage/RegionMessageHandler.java

https://gitlab.com/qt-prometheus/qt-prometheus
Java | 226 lines | 207 code | 15 blank | 4 comment | 38 complexity | 67c6a153b20cbdddaf5ac4787a30f95a MD5 | raw file
  1. package fm.qingting.qtradio.pushmessage;
  2. import android.content.Context;
  3. import com.alibaba.fastjson.JSON;
  4. import com.alibaba.fastjson.JSONObject;
  5. import fm.qingting.framework.data.DataManager;
  6. import fm.qingting.framework.data.IResultRecvHandler;
  7. import fm.qingting.framework.data.IResultToken;
  8. import fm.qingting.framework.data.Result;
  9. import fm.qingting.qtradio.model.ActivityNode;
  10. import fm.qingting.qtradio.model.DataLoadWrapper;
  11. import fm.qingting.qtradio.model.Node;
  12. import fm.qingting.qtradio.model.ProgramNode;
  13. import java.util.ArrayList;
  14. import java.util.HashMap;
  15. import java.util.List;
  16. import java.util.Map;
  17. public class RegionMessageHandler
  18. implements MessagePump.IRecvPushMsgListener
  19. {
  20. private static RegionMessageHandler _instance;
  21. private String RegionTopic = "region:other";
  22. private ActivityNode mActivityNode;
  23. private int mCategoryId;
  24. private int mChannelId;
  25. private String mContent;
  26. private int mContentType;
  27. private Context mContext;
  28. private long mExpireTime;
  29. private String mMsgType = "pullmsg";
  30. private int mProgramId;
  31. private String mTaskId;
  32. private String mTitle;
  33. private IResultRecvHandler resultRecver = new IResultRecvHandler()
  34. {
  35. public void onRecvResult(Result paramAnonymousResult, Object paramAnonymousObject1, IResultToken paramAnonymousIResultToken, Object paramAnonymousObject2)
  36. {
  37. if (paramAnonymousResult.getSuccess())
  38. {
  39. paramAnonymousObject1 = paramAnonymousIResultToken.getType();
  40. if (!paramAnonymousObject1.equalsIgnoreCase("GET_VIRTUAL_PROGRAM_INFO"))
  41. break label51;
  42. paramAnonymousResult = (ProgramNode)paramAnonymousResult.getData();
  43. if (paramAnonymousResult != null)
  44. {
  45. RegionMessageHandler.this.writeToDB(paramAnonymousResult);
  46. RegionMessageHandler.this.sendNotification();
  47. }
  48. }
  49. label51:
  50. do
  51. {
  52. do
  53. return;
  54. while (!paramAnonymousObject1.equalsIgnoreCase("GET_LIVE_CHANNEL_INFO"));
  55. paramAnonymousResult = (Node)paramAnonymousResult.getData();
  56. }
  57. while ((paramAnonymousResult == null) || (!paramAnonymousResult.nodeName.equalsIgnoreCase("channel")));
  58. RegionMessageHandler.this.writeToDB(paramAnonymousResult);
  59. RegionMessageHandler.this.sendNotification();
  60. }
  61. };
  62. private void _writeToDB(List<Node> paramList)
  63. {
  64. if ((paramList == null) || (paramList.size() == 0))
  65. return;
  66. HashMap localHashMap = new HashMap();
  67. localHashMap.put("nodes", paramList);
  68. DataManager.getInstance().getData("updatedb_pull_node", null, localHashMap);
  69. }
  70. private void buildTopic()
  71. {
  72. }
  73. private boolean canHandle(String paramString)
  74. {
  75. if (paramString == null);
  76. while (!this.RegionTopic.equalsIgnoreCase(paramString))
  77. return false;
  78. return true;
  79. }
  80. public static RegionMessageHandler getInstance()
  81. {
  82. if (_instance == null)
  83. _instance = new RegionMessageHandler();
  84. return _instance;
  85. }
  86. private boolean handleMsg(String paramString)
  87. {
  88. if ((paramString == null) || (paramString.equalsIgnoreCase("")));
  89. while (true)
  90. {
  91. return false;
  92. try
  93. {
  94. resetInfo();
  95. paramString = (JSONObject)JSON.parse(paramString);
  96. String str = paramString.getString("type");
  97. this.mTitle = paramString.getString("title");
  98. this.mContent = paramString.getString("content");
  99. this.mTaskId = paramString.getString("uuid");
  100. this.mExpireTime = paramString.getLongValue("expiretime");
  101. if (!isOutOfDate())
  102. {
  103. if (str.equalsIgnoreCase("virtual_program"))
  104. {
  105. this.mCategoryId = paramString.getIntValue("cat_id");
  106. this.mChannelId = paramString.getIntValue("channel_id");
  107. this.mProgramId = paramString.getIntValue("program_id");
  108. this.mContentType = 1;
  109. DataLoadWrapper.loadVProgramInfo(Integer.valueOf(this.mProgramId).intValue(), this.resultRecver);
  110. }
  111. while (true)
  112. {
  113. PushMessageLog.sendPushLog(this.mContext, this.mTaskId, this.RegionTopic, this.mCategoryId, 0, this.mChannelId, this.mProgramId, this.mContent, "RecvGeTuiPushMsg");
  114. return false;
  115. if (str.equalsIgnoreCase("live_channel"))
  116. {
  117. this.mCategoryId = paramString.getIntValue("cat_id");
  118. this.mChannelId = paramString.getIntValue("channel_id");
  119. this.mProgramId = 0;
  120. this.mContentType = 5;
  121. DataLoadWrapper.loadLiveChannelNode(Integer.valueOf(this.mChannelId).intValue(), this.resultRecver);
  122. }
  123. else
  124. {
  125. if (!str.equalsIgnoreCase("activity"))
  126. break;
  127. this.mActivityNode = new ActivityNode();
  128. this.mActivityNode.contentUrl = paramString.getString("content_url");
  129. this.mActivityNode.titleIconUrl = paramString.getString("title_icon");
  130. this.mActivityNode.infoUrl = paramString.getString("info_url");
  131. this.mActivityNode.infoTitle = this.mTitle;
  132. this.mActivityNode.desc = this.mContent;
  133. this.mContentType = 4;
  134. sendActivityNotification();
  135. }
  136. }
  137. }
  138. }
  139. catch (Exception paramString)
  140. {
  141. }
  142. }
  143. return false;
  144. }
  145. private boolean isOutOfDate()
  146. {
  147. if (this.mExpireTime == 0L);
  148. while (this.mExpireTime >= System.currentTimeMillis() / 1000L)
  149. return false;
  150. return true;
  151. }
  152. private void resetInfo()
  153. {
  154. this.mCategoryId = 0;
  155. this.mChannelId = 0;
  156. this.mProgramId = 0;
  157. this.mTitle = null;
  158. this.mContent = null;
  159. this.mTaskId = null;
  160. this.mExpireTime = 0L;
  161. this.mActivityNode = null;
  162. }
  163. private void sendActivityNotification()
  164. {
  165. if (this.mActivityNode != null)
  166. {
  167. MessageNotification.sendActivityNotification(this.mActivityNode, "push_activity", this.mTaskId, this.RegionTopic, this.mContentType, this.mContext);
  168. PushMessageLog.sendPushLog(this.mContext, this.mTaskId, this.RegionTopic, this.mCategoryId, 0, this.mChannelId, this.mProgramId, this.mContent, "SendGeTuiPushMsg");
  169. }
  170. }
  171. private void sendNotification()
  172. {
  173. MessageNotification localMessageNotification = new MessageNotification(this.mContext);
  174. localMessageNotification.mCategoryId = this.mCategoryId;
  175. localMessageNotification.mChannleId = this.mChannelId;
  176. localMessageNotification.mProgramId = this.mProgramId;
  177. localMessageNotification.mTitle = this.mTitle;
  178. localMessageNotification.mContent = this.mContent;
  179. localMessageNotification.mMsgType = this.mMsgType;
  180. localMessageNotification.mContentType = this.mContentType;
  181. localMessageNotification.mTag = this.RegionTopic;
  182. localMessageNotification.mTaskId = this.mTaskId;
  183. MessageNotification.sendSimpleNotification(localMessageNotification);
  184. PushMessageLog.sendPushLog(this.mContext, this.mTaskId, this.RegionTopic, this.mCategoryId, 0, this.mChannelId, this.mProgramId, this.mContent, "SendGeTuiPushMsg");
  185. }
  186. private void writeToDB(Node paramNode)
  187. {
  188. if (paramNode == null)
  189. return;
  190. ArrayList localArrayList = new ArrayList();
  191. localArrayList.add(paramNode);
  192. _writeToDB(localArrayList);
  193. }
  194. public void init(Context paramContext)
  195. {
  196. MessagePump.getInstance().registerRecvMsg(this);
  197. this.mContext = paramContext;
  198. buildTopic();
  199. }
  200. public boolean onRecvPushMsg(PushMessage paramPushMessage, int paramInt)
  201. {
  202. if (paramPushMessage == null);
  203. while ((paramInt != 0) || (!canHandle(paramPushMessage.mTopic)))
  204. return false;
  205. return handleMsg(paramPushMessage.mMessage);
  206. }
  207. }
  208. /* Location: C:\Users\User\dex2jar-2.0\dex\qting\classes-dex2jar.jar
  209. * Qualified Name: fm.qingting.qtradio.pushmessage.RegionMessageHandler
  210. * JD-Core Version: 0.6.2
  211. */