@Override public Integer doInBackground(Void... params) { try { HttpResponse response; String urlForDashboards = AccountSetting.getInstance().getDomainName() + ExoConstants.DASHBOARD_PATH; /* * Checking the session status each time we retrieve dashboard item list. * If time out, re logging in */ if (ExoConnectionUtils.checkTimeout(urlForDashboards) != ExoConnectionUtils.LOGIN_SUCCESS) return RESULT_TIMEOUT; items.clear(); response = ExoConnectionUtils.getRequestResponse(urlForDashboards); dashboardList = dashboardController.getDashboards(response); for (int i = 0; i < dashboardList.size(); i++) { DashboardItem gadgetTab = dashboardList.get(i); try { HttpResponse response2 = ExoConnectionUtils.getRequestResponse(gadgetTab.link); List<GadgetInfo> gadgets = dashboardController.getGadgetInTab(response2, gadgetTab.label, gadgetTab.link); if (gadgets != null && gadgets.size() > 0) { items.add(new GadgetInfo(gadgetTab.label)); items.addAll(gadgets); } } catch (IOException e) { Log.e("DashboardLoadTask", e.getMessage()); } } return RESULT_OK; } catch (IOException e) { if (Log.LOGD) Log.d(getClass().getSimpleName(), e.getMessage(), Log.getStackTraceString(e)); return RESULT_ERROR; } }
@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; } }