コード例 #1
0
  private void delFriend(final String userId) {
    gson = new Gson();
    LoginUserResult login = GetUserIdUtil.getLogin(this);
    if (login == null || login.p.user == null) {
      return;
    }
    LoginUserResult.User user = login.p.user;
    DelFriendRequest request = new DelFriendRequest();
    DelFriendRequest.Pramater pramater = request.p;
    pramater.userId = user.id + "";
    pramater.tokenId = login.p.tokenId;
    pramater.friendId = userId;
    switch (user.type) {
      case 0:
        pramater.ownerId = "";
        break;
      case 1:
        pramater.ownerId = user.id + "_com";
        break;
    }
    String json = gson.toJson(request);
    HttpConnectTool.update(
        json,
        this,
        new ConnectListener() {
          @Override
          public void contectSuccess(String result) {
            if (!TextUtils.isEmpty(result)) {
              DelFriendResult delFriendResult = gson.fromJson(result, DelFriendResult.class);
              if (delFriendResult != null) {
                if (delFriendResult.p.isTrue) {
                  if (delFriendResult.p.isSucce) {
                    try {
                      // 删除此联系人
                      deleteContact(userId);
                      // 删除相关的邀请消息
                      InviteMessgeDao dao = new InviteMessgeDao(FriendDatelActivity.this);
                      dao.deleteMessage(userId);
                    } catch (Exception e) {
                      e.printStackTrace();
                    }
                  } else {
                    ToastUtils.makeText(FriendDatelActivity.this, "删除失败!", ToastUtils.LENGTH_SHORT)
                        .show();
                  }
                } else {
                  IntentActivity.mIntent(FriendDatelActivity.this);
                }
              }
            }
          }

          @Override
          public void contectStarted() {}

          @Override
          public void contectFailed(String path, String request) {}
        });
  }
コード例 #2
0
  public void getResult() {
    gson = new Gson();
    FriendDatalRequest request = new FriendDatalRequest();
    FriendDatalRequest.Pramater pramater = request.p;
    pramater.userId = GetUserIdUtil.getUserId(this);
    pramater.tokenId = GetUserIdUtil.getTokenId(this);
    pramater.friendId = myFriendsList.userId;
    String json = gson.toJson(request);
    HttpConnectTool.update(
        json,
        this,
        new ConnectListener() {
          @Override
          public void contectSuccess(String result) {
            if (!TextUtils.isEmpty(result)) {
              datalResult = gson.fromJson(result, FriendDatalResult.class);
              if (datalResult != null) {
                if (datalResult.p.isTrue) {
                  FriendDatalResult.FriendDetails details = datalResult.p.friendDetails;
                  if (details != null) {
                    ImageLoaderUtil.loadImage(details.headImgUrl, headImg);
                    tv_name.setText(details.nickname);
                    tv_msg.setText("adsfasdf");
                    tv_dh.setText(details.exchange);
                    tv_jf.setText(details.score);
                    tv_zj.setText(details.wins);
                    tv_rw.setText(details.task);
                  }
                } else {
                  IntentActivity.mIntent(FriendDatelActivity.this);
                }
              }
            }
          }

          @Override
          public void contectStarted() {}

          @Override
          public void contectFailed(String path, String request) {}
        });
  }