public void addFriend(final FriendRequest friendRequest) {
    FriendshipAddForm dataForm = new FriendshipAddForm();
    dataForm.friend_id = friendRequest.getUid();

    friendshipResource
        .save(dataForm)
        .subscribeOn(Schedulers.io())
        .observeOn(Schedulers.io())
        .subscribe(
            response -> {
              // TODO show add friend Tip

              Friend friend = new Friend();
              friend.setUid(friendRequest.getUid());
              friend.setUsername(friendRequest.getUsername());
              friend.setNickname(
                  TextUtils.isEmpty(friendRequest.getNickname())
                      ? friendRequest.getDisplayName()
                      : friendRequest.getNickname());
              friend.setAvatar(friendRequest.getAvatar());
              friendDao.insert(friend);
            },
            error -> {
              // TODO show error info
            });

    // update friendRequest
    friendRequest.setStatus(FriendRequestStatus.ACCEPT.name());
    friendRequestDao.update(friendRequest);
  }
 public void synchronizationRemote() {
   friendshipResource
       .list()
       .observeOn(Schedulers.io())
       .subscribeOn(Schedulers.io())
       .flatMap(list -> Observable.from(list))
       .subscribe(
           friendVo -> {
             Friend friend =
                 friendDao.queryBuilder().where(FriendDao.Properties.Uid.eq(friendVo.id)).unique();
             if (friend == null) {
               friend = new Friend();
               friend.setUid(friendVo.id);
               friend.setUsername(friendVo.username);
               friend.setNickname(friendVo.nickname);
               friend.setAvatar(friendVo.avatar);
             } else {
               friend.setUsername(friendVo.username);
               friend.setNickname(friendVo.nickname);
               friend.setAvatar(friendVo.avatar);
             }
             friendDao.insertOrReplace(friend);
           });
 }
 public Friend findByUID(String userId) {
   return friendDao.queryBuilder().where(FriendDao.Properties.Uid.eq(userId)).unique();
 }