use of org.aisen.weibo.sina.sinasdk.bean.WeiBoUser in project AisenWeiBo by wangdan.
the class SinaSDK method userShow.
/**
* 按用户ID或昵称返回用户资料以及用户的最新发布的一条微博消息。<br>
* <br>
*
* @param uid
* (true):必须设置
* @param screenName
* (false):微博昵称,主要是用来区分用户UID跟微博昵称,当二者一样而产生歧义的时候,建议使用该参数
* @return
*/
public WeiBoUser userShow(String uid, String screenName) throws TaskException {
Params params = new Params();
if (!TextUtils.isEmpty(uid))
params.addParameter("uid", uid);
if (!TextUtils.isEmpty(screenName))
params.addParameter("screen_name", screenName);
params.setEncodeAble(false);
WeiBoUser user = doGet(getSetting("usershow"), configParams(params), WeiBoUser.class);
if (user != null) {
// Sina真的是有毛病啊
if (!TextUtils.isEmpty(user.getDescription()) && user.getDescription().toLowerCase().endsWith("-weibo")) {
user.setDescription(user.getDescription().substring(0, user.getDescription().length() - 6));
}
if (!TextUtils.isEmpty(user.getVerified_reason()) && user.getVerified_reason().toLowerCase().endsWith("-weibo")) {
user.setVerified_reason(user.getVerified_reason().substring(0, user.getVerified_reason().length() - 6));
}
}
return user;
}
use of org.aisen.weibo.sina.sinasdk.bean.WeiBoUser in project AisenWeiBo by wangdan.
the class FriendDB method findCacheData.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public IResult findCacheData(Setting action, Params params) {
if (params.containsKey("uid")) {
if (!params.getParameter("uid").equals(AppContext.getAccount().getUser().getIdstr()))
return null;
} else if (params.containsKey("screen_name")) {
if (!params.getParameter("screen_name").equals(AppContext.getAccount().getUser().getScreen_name()))
return null;
}
List<WeiBoUser> userList = selectAll();
if (userList.size() > 0) {
Friendship users = new Friendship();
users.setUsers(userList);
users.setFromCache(true);
users.setOutofdate(CacheTimeUtils.isOutofdate("Friends", AppContext.getAccount().getUser()));
users.setNext_cursor(ActivityHelper.getIntShareData(GlobalContext.getInstance(), "Friends" + AppContext.getAccount().getUser().getIdstr(), 0));
return users;
}
return null;
}
use of org.aisen.weibo.sina.sinasdk.bean.WeiBoUser in project AisenWeiBo by wangdan.
the class CommentsHotHttpUtility method parseResponse.
@Override
protected <T> T parseResponse(String resultStr, Class<T> responseCls) throws TaskException {
try {
JSONArray jsonArray = JSONArray.parseArray(resultStr);
StatusComments comments = new StatusComments();
comments.setComments(new ArrayList<StatusComment>());
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
if (jsonObject.containsKey("card_group")) {
JSONArray card_group = jsonObject.getJSONArray("card_group");
for (int j = 0; j < card_group.size(); j++) {
try {
JSONObject card = card_group.getJSONObject(j);
StatusComment comment = new StatusComment();
comment.setId(card.getString("id"));
comment.setText(Html.fromHtml(card.getString("text")).toString());
comment.setCreated_at(card.getString("created_at"));
comment.setSource(card.getString("source"));
comment.setLikedCount(card.getLong("like_counts"));
comment.setLiked(card.getBoolean("liked"));
JSONObject user = card.getJSONObject("user");
comment.setUser(new WeiBoUser());
comment.getUser().setInfoAll(false);
comment.getUser().setId(user.getString("id"));
comment.getUser().setScreen_name(user.getString("screen_name"));
comment.getUser().setProfile_image_url(user.getString("profile_image_url"));
comments.getComments().add(comment);
} catch (Exception e) {
Logger.printExc(CommentsHotHttpUtility.class, e);
}
}
}
}
return (T) comments;
} catch (Exception e) {
throw new TaskException(TaskException.TaskError.resultIllegal.toString());
}
}
use of org.aisen.weibo.sina.sinasdk.bean.WeiBoUser in project AisenWeiBo by wangdan.
the class BizFragment method destoryFollower.
/* 结束查看用户好友列表 */
// XXX /*开始移除粉丝*/
public void destoryFollower(final WeiBoUser user, final OnDestoryFollowerCallback callback) {
Token token = AppContext.getAccount().getAccessToken();
if (AppContext.getAccount().getAdvancedToken() != null)
token = AppContext.getAccount().getAdvancedToken();
final Token trueToken = token;
new MaterialDialog.Builder(getRealActivity()).title(R.string.title_destory_friend).content(R.string.biz_destory_follower).negativeText(R.string.cancel).positiveText(R.string.confirm).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
new WorkTask<Void, Void, WeiBoUser>() {
@Override
public WeiBoUser workInBackground(Void... params) throws TaskException {
return SinaSDK.getInstance(trueToken).friendshipsFollowersDestory(user.getIdstr());
}
@Override
protected void onPrepare() {
super.onPrepare();
ViewUtils.createProgressDialog(getRealActivity(), getRealString(R.string.biz_destory_follower_loading), ThemeUtils.getThemeColor()).show();
}
@Override
protected void onFailure(TaskException exception) {
super.onFailure(exception);
showMessage(exception.getMessage());
}
@Override
protected void onSuccess(WeiBoUser result) {
super.onSuccess(result);
if (getRealActivity() != null)
callback.onDestoryFollower(result);
}
@Override
protected void onFinished() {
super.onFinished();
ViewUtils.dismissProgressDialog();
}
}.execute();
}
}).show();
}
use of org.aisen.weibo.sina.sinasdk.bean.WeiBoUser in project AisenWeiBo by wangdan.
the class BizFragment method commentDestory.
// XXX /*删除评论*/
/* 删除评论 */
public void commentDestory(final StatusComment commnet, final OnCommentDestoryCallback callback) {
final WeiBoUser user = AppContext.getAccount().getUser();
new WorkTask<Void, Void, StatusComment>() {
protected void onPrepare() {
super.onPrepare();
ViewUtils.createProgressDialog(getRealActivity(), getRealString(R.string.biz_delete_cmt_loading), ThemeUtils.getThemeColor()).show();
}
protected void onFinished() {
super.onFinished();
ViewUtils.dismissProgressDialog();
}
protected void onSuccess(StatusComment result) {
super.onSuccess(result);
if (getRealActivity() == null) {
return;
}
if (callback != null)
callback.onCommentDestory(commnet);
showMessage(R.string.delete_success);
// 删除成功后,DB同时也删除
SinaDB.getTimelineDB().deleteById(new Extra(user.getIdstr(), null), StatusComment.class, result.getId());
}
protected void onFailure(TaskException exception) {
super.onFailure(exception);
if (getRealActivity() == null) {
return;
}
if (!TextUtils.isEmpty(exception.getMessage()))
showMessage(exception.getMessage());
else
showMessage(R.string.delete_faild);
}
@Override
public StatusComment workInBackground(Void... params) throws TaskException {
return SinaSDK.getInstance(AppContext.getAccount().getAccessToken()).commentsDestory(commnet.getId());
}
}.execute();
}
Aggregations