@Override public void onPostExecute(String[] result) { if (result != null) { SocialServiceHelper.getInstance().userIdentity = mUserIdentity; SocialServiceHelper.getInstance().activityService = mActivityService; SocialServiceHelper.getInstance().identityService = mIdentityService; SocialServiceHelper.getInstance().spaceService = mSpaceService; SocialServiceHelper.getInstance().userProfile = result; if (HomeActivity.homeActivity != null) { HomeActivity.homeActivity.setProfileInfo(result); } if (AccountSetting.getInstance().shouldSaveProfileInfo(result[1], result[0])) { SettingUtils.persistServerSetting(mContext); } /** Load activities for view flipper */ homeController.onLoad(ExoConstants.HOME_SOCIAL_MAX_NUMBER, HomeController.FLIPPER_VIEW); } else { loaderItem.setLoading(false); WarningDialog dialog = new WarningDialog(mContext, titleString, contentString, okString); dialog.show(); } }
@Override public Integer doInBackground(Boolean... params) { isLikeAction = params[0]; try { ActivityService<RestActivity> activityService = SocialServiceHelper.getInstance().activityService; String activityId = SocialDetailHelper.getInstance().getActivityId(); QueryParams queryParams = new QueryParamsImpl(); queryParams.append( QueryParams.NUMBER_OF_LIKES_PARAM.setValue(ExoConstants.NUMBER_OF_LIKES_PARAM)); queryParams.append( QueryParams.NUMBER_OF_COMMENTS_PARAM.setValue(ExoConstants.NUMBER_OF_COMMENTS_PARAM)); queryParams.append(QueryParams.POSTER_IDENTITY_PARAM.setValue(true)); selectedRestActivity = activityService.get(activityId, queryParams); SocialDetailHelper.getInstance().setLiked(false); streamInfo = new SocialActivityInfo(); RestProfile restProfile = selectedRestActivity.getPosterIdentity().getProfile(); streamInfo.setActivityId(selectedRestActivity.getId()); streamInfo.setImageUrl(restProfile.getAvatarUrl()); streamInfo.setUserName(restProfile.getFullName()); streamInfo.setTitle(selectedRestActivity.getTitle()); streamInfo.setBody(selectedRestActivity.getBody()); streamInfo.setPostedTime(selectedRestActivity.getPostedTime()); if (SocialActivityUtil.getPlatformVersion() >= 4.0f) { streamInfo.setUpdatedTime(selectedRestActivity.getLastUpdated()); } streamInfo.setLikeNumber(selectedRestActivity.getTotalNumberOfLikes()); streamInfo.setCommentNumber(selectedRestActivity.getTotalNumberOfComments()); activityType = selectedRestActivity.getType(); streamInfo.setType(activityType); streamInfo.restActivityStream = selectedRestActivity.getActivityStream(); streamInfo.templateParams = selectedRestActivity.getTemplateParams(); List<RestIdentity> likeList = selectedRestActivity.getAvailableLikes(); List<RestComment> commentList = selectedRestActivity.getAvailableComments(); if (likeList != null) { for (RestIdentity like : likeList) { RestProfile likeProfile = like.getProfile(); SocialLikeInfo socialLike = new SocialLikeInfo(); socialLike.likedImageUrl = likeProfile.getAvatarUrl(); String identity = like.getId(); if (identity.equalsIgnoreCase(SocialServiceHelper.getInstance().userIdentity)) { socialLike.setLikeName(youText); likeLinkedList.addFirst(socialLike); SocialDetailHelper.getInstance().setLiked(true); } else { String likeName = like.getProfile().getFullName(); socialLike.setLikeName(likeName); likeLinkedList.add(socialLike); } } } if (commentList != null) { for (RestComment comment : commentList) { SocialCommentInfo socialComment = new SocialCommentInfo(); RestIdentity restId = comment.getPosterIdentity(); RestProfile profile = restId.getProfile(); socialComment.setCommentId(restId.getId()); socialComment.setCommentName(profile.getFullName()); socialComment.setImageUrl(profile.getAvatarUrl()); socialComment.setCommentTitle(comment.getText()); socialComment.setPostedTime(comment.getPostedTime()); socialCommentList.add(socialComment); } } return 1; } catch (SocialClientLibException e) { if (Log.LOGD) Log.d(getClass().getSimpleName(), "doInBackground ", Log.getStackTraceString(e)); return 0; } catch (RuntimeException e) { if (Log.LOGD) Log.d(getClass().getSimpleName(), "doInBackground ", Log.getStackTraceString(e)); return -1; } }