use of com.keylesspalace.tusky.entity.Relationship in project Tusky by Vavassor.
the class AccountActivity method follow.
private void follow(final String id) {
Callback<Relationship> cb = new Callback<Relationship>() {
@Override
public void onResponse(Call<Relationship> call, Response<Relationship> response) {
if (response.isSuccessful()) {
Relationship relationship = response.body();
if (relationship.following) {
followState = FollowState.FOLLOWING;
} else if (relationship.requested) {
followState = FollowState.REQUESTED;
Snackbar.make(container, R.string.state_follow_requested, Snackbar.LENGTH_LONG).show();
} else {
followState = FollowState.NOT_FOLLOWING;
broadcast(TimelineReceiver.Types.UNFOLLOW_ACCOUNT, id);
}
updateButtons();
} else {
onFollowFailure(id);
}
}
@Override
public void onFailure(Call<Relationship> call, Throwable t) {
onFollowFailure(id);
}
};
Assert.expect(followState != FollowState.REQUESTED);
switch(followState) {
case NOT_FOLLOWING:
{
mastodonAPI.followAccount(id).enqueue(cb);
break;
}
case FOLLOWING:
{
mastodonAPI.unfollowAccount(id).enqueue(cb);
break;
}
}
}
Aggregations