/QingTingFanBianYi/src/fm/qingting/social/api/TencentWeiboApi.java

https://gitlab.com/qt-prometheus/qt-prometheus · Java · 171 lines · 155 code · 12 blank · 4 comment · 30 complexity · 2c6418ff069578bf4cc04eb23b58130a MD5 · raw file

  1. package fm.qingting.social.api;
  2. import android.content.Context;
  3. import com.alibaba.fastjson.JSON;
  4. import com.alibaba.fastjson.JSONObject;
  5. import com.tencent.weibo.sdk.android.api.ShortUrlAPI;
  6. import com.tencent.weibo.sdk.android.api.UserAPI;
  7. import com.tencent.weibo.sdk.android.api.WeiboAPI;
  8. import com.tencent.weibo.sdk.android.api.util.Util;
  9. import com.tencent.weibo.sdk.android.model.AccountModel;
  10. import com.tencent.weibo.sdk.android.model.ModelResult;
  11. import com.tencent.weibo.sdk.android.network.HttpCallback;
  12. import fm.qingting.social.ISocialEventListener;
  13. import fm.qingting.social.SocialEventListenerWrapper;
  14. import fm.qingting.social.auth.TencentWeiboAuth;
  15. public class TencentWeiboApi
  16. {
  17. public static void getShortLink(final Context paramContext, final String paramString, final ISocialEventListener paramISocialEventListener)
  18. {
  19. if (TencentWeiboAuth.isLoggedIn().booleanValue())
  20. {
  21. getShortLinkInternal(paramContext, paramString, paramISocialEventListener);
  22. return;
  23. }
  24. TencentWeiboAuth.login(paramContext, new SocialEventListenerWrapper(paramISocialEventListener)
  25. {
  26. public void onComplete(Object paramAnonymousObject1, Object paramAnonymousObject2)
  27. {
  28. TencentWeiboApi.getShortLinkInternal(paramContext, paramString, paramISocialEventListener);
  29. }
  30. });
  31. }
  32. private static void getShortLinkInternal(Context paramContext, String paramString, ISocialEventListener paramISocialEventListener)
  33. {
  34. new ShortUrlAPI(new AccountModel(Util.getSharePersistent(paramContext, "ACCESS_TOKEN"))).getShortUrl(paramContext, "json", paramString, new TencentWeiboHttpCallback(paramISocialEventListener), null, 4);
  35. }
  36. public static Boolean isSessionValid(Context paramContext)
  37. {
  38. return TencentWeiboAuth.isSessionValid(paramContext);
  39. }
  40. public static void readProfile(Context paramContext, final ISocialEventListener paramISocialEventListener)
  41. {
  42. String str = Util.getSharePersistent(paramContext, "ACCESS_TOKEN");
  43. if ((str == null) || (str == ""))
  44. return;
  45. new UserAPI(new AccountModel(str)).getUserInfo(paramContext, "json", new HttpCallback()
  46. {
  47. public void onResult(Object paramAnonymousObject)
  48. {
  49. paramAnonymousObject = (ModelResult)paramAnonymousObject;
  50. if (paramAnonymousObject == null);
  51. do
  52. {
  53. return;
  54. paramAnonymousObject = paramAnonymousObject.getObj().toString();
  55. JSONObject localJSONObject = (JSONObject)JSON.parse(paramAnonymousObject);
  56. if ((localJSONObject != null) && (localJSONObject.getInteger("ret").intValue() == 0))
  57. {
  58. localJSONObject = localJSONObject.getJSONObject("data");
  59. int i = localJSONObject.getInteger("sex").intValue();
  60. if (i == 1)
  61. paramAnonymousObject = "m";
  62. while (true)
  63. {
  64. Util.saveSharePersistent(this.val$context, "gender", paramAnonymousObject);
  65. Util.saveSharePersistent(this.val$context, "name", localJSONObject.getString("name"));
  66. Util.saveSharePersistent(this.val$context, "nick", localJSONObject.getString("nick"));
  67. paramAnonymousObject = localJSONObject.getString("head");
  68. if ((paramAnonymousObject != null) && (paramAnonymousObject.length() > 0))
  69. Util.saveSharePersistent(this.val$context, "avatar", paramAnonymousObject + "/120");
  70. Util.saveSharePersistent(this.val$context, "introduction", localJSONObject.getString("introduction"));
  71. Util.saveSharePersistent(this.val$context, "key", localJSONObject.getString("_id"));
  72. if (paramISocialEventListener == null)
  73. break;
  74. paramISocialEventListener.onComplete(null, null);
  75. return;
  76. if (i == 2)
  77. paramAnonymousObject = "f";
  78. else
  79. paramAnonymousObject = "n";
  80. }
  81. }
  82. }
  83. while (paramISocialEventListener == null);
  84. paramISocialEventListener.onException(paramAnonymousObject);
  85. }
  86. }
  87. , null, 4);
  88. }
  89. public static void shareImage(final Context paramContext, final String paramString1, final String paramString2, final ISocialEventListener paramISocialEventListener)
  90. {
  91. if (TencentWeiboAuth.isLoggedIn().booleanValue())
  92. {
  93. shareImageInternal(paramContext, paramString1, paramString2, paramISocialEventListener);
  94. return;
  95. }
  96. TencentWeiboAuth.login(paramContext, new SocialEventListenerWrapper(paramISocialEventListener)
  97. {
  98. public void onComplete(Object paramAnonymousObject1, Object paramAnonymousObject2)
  99. {
  100. if (paramISocialEventListener != null)
  101. TencentWeiboApi.shareImageInternal(paramContext, paramString1, paramString2, paramISocialEventListener);
  102. }
  103. });
  104. }
  105. private static void shareImageInternal(Context paramContext, String paramString1, String paramString2, ISocialEventListener paramISocialEventListener)
  106. {
  107. new WeiboAPI(new AccountModel(Util.getSharePersistent(paramContext, "ACCESS_TOKEN"))).addMulti(paramContext, "json", paramString1, 0.0D, 0.0D, paramString2, "", "", "", "", "", 0, 0, new TencentWeiboHttpCallback(paramISocialEventListener), null, 4);
  108. }
  109. public static void shareMusic(final Context paramContext, final String paramString1, final String paramString2, final String paramString3, final String paramString4, final ISocialEventListener paramISocialEventListener)
  110. {
  111. if (TencentWeiboAuth.isLoggedIn().booleanValue())
  112. {
  113. shareMusicInternal(paramContext, paramString1, paramString3, paramString2, paramString4, paramISocialEventListener);
  114. return;
  115. }
  116. TencentWeiboAuth.login(paramContext, new SocialEventListenerWrapper(paramISocialEventListener)
  117. {
  118. public void onComplete(Object paramAnonymousObject1, Object paramAnonymousObject2)
  119. {
  120. TencentWeiboApi.shareMusicInternal(paramContext, paramString1, paramString3, paramString2, paramString4, paramISocialEventListener);
  121. }
  122. });
  123. }
  124. private static void shareMusicInternal(Context paramContext, String paramString1, String paramString2, String paramString3, String paramString4, ISocialEventListener paramISocialEventListener)
  125. {
  126. new WeiboAPI(new AccountModel(Util.getSharePersistent(paramContext, "ACCESS_TOKEN"))).addMulti(paramContext, "json", paramString1, 0.0D, 0.0D, "", "", "", paramString3, paramString2, paramString4, 0, 96, new TencentWeiboHttpCallback(paramISocialEventListener), null, 4);
  127. }
  128. public static void shareText(final Context paramContext, final String paramString, final ISocialEventListener paramISocialEventListener)
  129. {
  130. if (TencentWeiboAuth.isLoggedIn().booleanValue())
  131. {
  132. shareTextInternal(paramContext, paramString, paramISocialEventListener);
  133. return;
  134. }
  135. TencentWeiboAuth.login(paramContext, new SocialEventListenerWrapper(paramISocialEventListener)
  136. {
  137. public void onComplete(Object paramAnonymousObject1, Object paramAnonymousObject2)
  138. {
  139. TencentWeiboApi.shareTextInternal(paramContext, paramString, paramISocialEventListener);
  140. }
  141. });
  142. }
  143. private static void shareTextInternal(Context paramContext, String paramString, ISocialEventListener paramISocialEventListener)
  144. {
  145. new WeiboAPI(new AccountModel(Util.getSharePersistent(paramContext, "ACCESS_TOKEN"))).addWeibo(paramContext, paramString, "json", 0.0D, 0.0D, 0, 0, new HttpCallback()
  146. {
  147. public void onResult(Object paramAnonymousObject)
  148. {
  149. if (this.val$listener != null)
  150. this.val$listener.onComplete(paramAnonymousObject, null);
  151. }
  152. }
  153. , null, 4);
  154. }
  155. }
  156. /* Location: C:\Users\User\dex2jar-2.0\dex\qting\classes-dex2jar.jar
  157. * Qualified Name: fm.qingting.social.api.TencentWeiboApi
  158. * JD-Core Version: 0.6.2
  159. */