コード例 #1
0
  /**
   * 登陆成功后获得token
   *
   * @param callback
   * @return
   */
  public AbstractHttpRequest<User> getToken(ApiCallback<User> callback) {
    ApiReqeust<User> apiReqeust =
        new DefaultApiReqeust<User>(ApiReqeust.GET_METHOD, URI.create(HOST + DEMO_TOKEN), callback);
    AbstractHttpRequest<User> httpRequest =
        apiReqeust.obtainRequest(new GsonParser<User>(User.class), mAuthType);
    NetworkManager.getInstance().requestAsync(httpRequest);

    return httpRequest;
  }
コード例 #2
0
  /**
   * 获取好友列表 获取添加过的好友信息
   *
   * @param callback
   * @return
   */
  public AbstractHttpRequest<Friends> getNewFriendlist(ApiCallback<Friends> callback) {

    ApiReqeust<Friends> apiReqeust =
        new DefaultApiReqeust<Friends>(
            ApiReqeust.GET_METHOD, URI.create(HOST + DEMO_GET_FRIEND), callback);
    AbstractHttpRequest<Friends> httpRequest =
        apiReqeust.obtainRequest(new GsonParser<Friends>(Friends.class), mAuthType);
    NetworkManager.getInstance().requestAsync(httpRequest);

    return httpRequest;
  }
コード例 #3
0
  /**
   * demo server 获取我的群组列表
   *
   * @param callback
   * @return
   */
  public AbstractHttpRequest<Groups> getMyGroups(ApiCallback<Groups> callback) {

    ApiReqeust<Groups> apiReqeust =
        new DefaultApiReqeust<Groups>(
            ApiReqeust.GET_METHOD, URI.create(HOST + DEMO_GET_MY_GROUP), callback);
    AbstractHttpRequest<Groups> httpRequest =
        apiReqeust.obtainRequest(new GsonParser<Groups>(Groups.class), mAuthType);
    NetworkManager.getInstance().requestAsync(httpRequest);

    return httpRequest;
  }
コード例 #4
0
  /**
   * 根据userid 获得 userinfo
   *
   * @param callback
   * @return
   */
  public AbstractHttpRequest<User> getUserInfoByUserId(String userid, ApiCallback<User> callback) {
    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
    nameValuePairs.add(new BasicNameValuePair("id", userid + ""));

    ApiReqeust<User> apiReqeust =
        new DefaultApiReqeust<User>(
            ApiReqeust.GET_METHOD, URI.create(HOST + DEMO_PROFILE), nameValuePairs, callback);
    AbstractHttpRequest<User> httpRequest =
        apiReqeust.obtainRequest(new GsonParser<User>(User.class), mAuthType);
    NetworkManager.getInstance().requestAsync(httpRequest);

    return httpRequest;
  }
コード例 #5
0
  /**
   * demo server 退出群组
   *
   * @param callback
   * @return
   */
  public AbstractHttpRequest<Status> quitGroup(String username, ApiCallback<Status> callback) {

    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
    nameValuePairs.add(new BasicNameValuePair("id", username + ""));

    ApiReqeust<Status> apiReqeust =
        new DefaultApiReqeust<Status>(
            ApiReqeust.GET_METHOD, URI.create(HOST + DEMO_QUIT_GROUP), nameValuePairs, callback);
    AbstractHttpRequest<Status> httpRequest =
        apiReqeust.obtainRequest(new GsonParser<Status>(Status.class), mAuthType);
    NetworkManager.getInstance().requestAsync(httpRequest);

    return httpRequest;
  }
コード例 #6
0
  /**
   * 通过用户名搜索用户
   *
   * @param callback
   * @return
   */
  public AbstractHttpRequest<Friends> searchUserByUserName(
      String username, ApiCallback<Friends> callback) {

    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
    nameValuePairs.add(new BasicNameValuePair("username", username));

    ApiReqeust<Friends> apiReqeust =
        new DefaultApiReqeust<Friends>(
            ApiReqeust.GET_METHOD, URI.create(HOST + DEMO_SEARCH_NAME), nameValuePairs, callback);
    AbstractHttpRequest<Friends> httpRequest =
        apiReqeust.obtainRequest(new GsonParser<Friends>(Friends.class), mAuthType);
    NetworkManager.getInstance().requestAsync(httpRequest);

    return httpRequest;
  }
コード例 #7
0
  /**
   * demo server 通过群组id 获取群组信息
   *
   * @param callback
   * @return
   */
  public AbstractHttpRequest<Groups> getGroupByGroupId(
      String groupid, ApiCallback<Groups> callback) {

    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
    nameValuePairs.add(new BasicNameValuePair("id", groupid));

    ApiReqeust<Groups> apiReqeust =
        new DefaultApiReqeust<Groups>(
            ApiReqeust.GET_METHOD, URI.create(HOST + DEMO_GET_GROUP), nameValuePairs, callback);
    AbstractHttpRequest<Groups> httpRequest =
        apiReqeust.obtainRequest(new GsonParser<Groups>(Groups.class), mAuthType);
    NetworkManager.getInstance().requestAsync(httpRequest);

    return httpRequest;
  }
コード例 #8
0
  /**
   * 登录 demo server
   *
   * @param email
   * @param password
   * @param callback 1 关羽 生产 2,张飞 测试
   * @return
   */
  public AbstractHttpRequest<User> login(
      String email, String password, ApiCallback<User> callback) {

    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
    nameValuePairs.add(new BasicNameValuePair("email", email));
    nameValuePairs.add(new BasicNameValuePair("password", password));
    //        nameValuePairs.add(new BasicNameValuePair("env", "2"));

    ApiReqeust<User> apiReqeust =
        new DefaultApiReqeust<User>(
            ApiReqeust.POST_METHOD, URI.create(HOST + DEMO_LOGIN_EMAIL), nameValuePairs, callback);
    AbstractHttpRequest<User> httpRequest =
        apiReqeust.obtainRequest(new GsonParser<User>(User.class), mAuthType);
    NetworkManager.getInstance().requestAsync(httpRequest);
    return httpRequest;
  }
コード例 #9
0
  /**
   * demo server 删除好友
   *
   * @param callback
   * @return
   */
  public AbstractHttpRequest<Status> deletefriends(String id, ApiCallback<Status> callback) {

    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
    nameValuePairs.add(new BasicNameValuePair("id", id + ""));

    ApiReqeust<Status> apiReqeust =
        new DefaultApiReqeust<Status>(
            ApiReqeust.POST_METHOD,
            URI.create(HOST + DEMO_DELETE_FRIEND),
            nameValuePairs,
            callback);
    AbstractHttpRequest<Status> httpRequest =
        apiReqeust.obtainRequest(new GsonParser<Status>(Status.class), mAuthType);
    NetworkManager.getInstance().requestAsync(httpRequest);

    return httpRequest;
  }
コード例 #10
0
  /**
   * demo server 注册新用户
   *
   * @param username
   * @param callback
   * @return
   */
  public AbstractHttpRequest<Status> updateProfile(String username, ApiCallback<Status> callback) {

    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
    nameValuePairs.add(new BasicNameValuePair("username", username));

    ApiReqeust<Status> apiReqeust =
        new DefaultApiReqeust<Status>(
            ApiReqeust.POST_METHOD,
            URI.create(HOST + DEMO_UPDATE_PROFILE),
            nameValuePairs,
            callback);
    AbstractHttpRequest<Status> httpRequest =
        apiReqeust.obtainRequest(new GsonParser<Status>(Status.class), mAuthType);
    NetworkManager.getInstance().requestAsync(httpRequest);

    return httpRequest;
  }
コード例 #11
0
  /**
   * 发好友邀请
   *
   * @param callback
   * @return
   */
  public AbstractHttpRequest<User> sendFriendInvite(
      String userid, String message, ApiCallback<User> callback) {
    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
    nameValuePairs.add(new BasicNameValuePair("id", userid + ""));
    nameValuePairs.add(new BasicNameValuePair("message", message));

    ApiReqeust<User> apiReqeust =
        new DefaultApiReqeust<User>(
            ApiReqeust.POST_METHOD,
            URI.create(HOST + DEMO_REQUEST_FRIEND),
            nameValuePairs,
            callback);
    AbstractHttpRequest<User> httpRequest =
        apiReqeust.obtainRequest(new GsonParser<User>(User.class), mAuthType);
    NetworkManager.getInstance().requestAsync(httpRequest);

    return httpRequest;
  }
コード例 #12
0
  /**
   * demo server 注册新用户
   *
   * @param email
   * @param username
   * @param password
   * @param callback
   * @return
   */
  public AbstractHttpRequest<Status> register(
      String email, String username, String mobile, String password, ApiCallback<Status> callback) {

    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
    nameValuePairs.add(new BasicNameValuePair("email", email));
    nameValuePairs.add(new BasicNameValuePair("username", username));
    nameValuePairs.add(new BasicNameValuePair("password", password));
    nameValuePairs.add(new BasicNameValuePair("mobile", mobile));

    ApiReqeust<Status> apiReqeust =
        new DefaultApiReqeust<Status>(
            ApiReqeust.POST_METHOD, URI.create(HOST + DEMO_REQ), nameValuePairs, callback);
    //        ApiReqeust<Status> apiReqeust = new DefaultApiReqeust<Status>(ApiReqeust.POST_METHOD,
    // URI.create(HOST + DEMO_REQ), nameValuePairs, callback);

    AbstractHttpRequest<Status> httpRequest =
        apiReqeust.obtainRequest(new GsonParser<Status>(Status.class), null, null);
    NetworkManager.getInstance().requestAsync(httpRequest);

    return httpRequest;
  }