Working with Activity Likes

Like Post

To like or dislike activity post or comment, do next:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
boolean setLiked = true;
GetSocial.likeActivity(activityId, setLiked, new Callback<ActivityPost>() {
    @Override
    public void onSuccess(ActivityPost activityPost) {
        Log.i("GetSocial", "Activity was successfully liked");
        // You can check if activity is liked by calling
        // boolean isPostLikedByMe = activityPost.isLikedByMe();
    }

    @Override
    public void onFailure(GetSocialException e) {
        Log.e("GetSocial", "Failed to like post: " + e.getMessage());
    }
});

If you want to unlike activity, pass false as parameter setLiked.

We handle data consistency, so if you’re trying to like already liked the activity, or dislike not liked the activity, an operation will call successful callback without any changes.

GetSocial UI

Activity is liked/unliked when user presses Like button.

List of Post Likes

To get a list of users, who liked an activity:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
GetSocial.getActivityLikers(activityId, offset, limit, new Callback<List<PublicUser>>() {
    @Override
    public void onSuccess(List<PublicUser> publicUsers) {
        Log.i("GetSocial", "Successfully retrieved list of activity likers");
        showListOfUsers(publicUsers);
    }

    @Override
    public void onFailure(GetSocialException e) {
        Log.e("GetSocial", "Retrieving failed: " + e.getMessage());
    }
});

Where offset and limit is pagination parameters, for example, to get first 50 users, who liked a post, use offset=0 and limit=50, to get next page - offset=50, limit=50 etc.

GetSocial UI

Likers list is displayed after user pressed on likes count:


GetSocial Activity Likes View

Give us your feedback! Was this article helpful?

😀 🙁