Java 类com.loopj.android.http.RequestParams 实例源码

项目:GitHub    文件:JsonStreamerSample.java   
@Override
public RequestHandle executeSample(AsyncHttpClient client, String URL, Header[] headers, HttpEntity entity, ResponseHandlerInterface responseHandler) {
    RequestParams params = new RequestParams();
    params.setUseJsonStreamer(true);
    JSONObject body;
    if (isRequestBodyAllowed() && (body = getBodyTextAsJSON()) != null) {
        try {
            Iterator keys = body.keys();
            Log.d(LOG_TAG, "JSON data:");
            while (keys.hasNext()) {
                String key = (String) keys.next();
                Log.d(LOG_TAG, "  " + key + ": " + body.get(key));
                params.put(key, body.get(key).toString());
            }
        } catch (JSONException e) {
            Log.w(LOG_TAG, "Unable to retrieve a JSON value", e);
        }
    }
    return client.post(this, URL, headers, params,
            RequestParams.APPLICATION_JSON, responseHandler);
}
项目:GitHub    文件:FilesSample.java   
@Override
public RequestHandle executeSample(AsyncHttpClient client, String URL, Header[] headers, HttpEntity entity, ResponseHandlerInterface responseHandler) {
    try {
        RequestParams params = new RequestParams();
        final String contentType = RequestParams.APPLICATION_OCTET_STREAM;
        params.put("fileOne", createTempFile("fileOne", 1020), contentType, "fileOne");
        params.put("fileTwo", createTempFile("fileTwo", 1030), contentType);
        params.put("fileThree", createTempFile("fileThree", 1040), contentType, "customFileThree");
        params.put("fileFour", createTempFile("fileFour", 1050), contentType);
        params.put("fileFive", createTempFile("fileFive", 1060), contentType, "testingFileFive");
        params.setHttpEntityIsRepeatable(true);
        params.setUseJsonStreamer(false);
        return client.post(this, URL, params, responseHandler);
    } catch (FileNotFoundException fnfException) {
        Log.e(LOG_TAG, "executeSample failed with FileNotFoundException", fnfException);
    }
    return null;
}
项目:OSchina_resources_android    文件:OSChinaTeamApi.java   
/***
 * 改变一个任务的状态
 *
 * @param teamId
 * @param issue
 * @param target  修改的属性("state" : 状态, "assignee" 指派人, "deadline" : 截止日期)
 * @param handler
 * @return void
 * @author 火蚁 2015-3-6 上午11:44:01
 */
public static void changeIssueState(int teamId, TeamIssue issue,
                                    String target, AsyncHttpResponseHandler handler, Context context) {
    if (issue == null)
        return;
    RequestParams params = new RequestParams();
    params.put("uid", AccountHelper.getUserId());
    params.put("teamid", teamId);
    params.put("target", target);
    params.put("issueid", issue.getId());
    if (target.equals("state")) {
        params.put("state", issue.getState());
    } else if (target.equals("assignee")) {
        params.put("assignee", issue.getToUser().getId());
    } else if (target.equals("deadline")) {
        params.put("deadline", issue.getDeadlineTime());
    }
    ApiHttpClient.post("action/api/team_issue_update", params, handler);
}
项目:OSchina_resources_android    文件:OSChinaTeamApi.java   
/***
 * 发表一个新的团队动态
 *
 * @param teamId
 * @param content
 * @param img
 * @param handler
 * @return void
 * @author 火蚁 2015-3-9 下午2:46:13
 */
public static void pubTeamNewActive(int teamId, String content, File img,
                                    AsyncHttpResponseHandler handler, Context context) {
    RequestParams params = new RequestParams();
    params.put("teamid", teamId);
    params.put("uid", AccountHelper.getUserId());
    params.put("msg", content);
    params.put("appid", 3);
    if (img != null) {

        try {
            params.put("img", img);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
    ApiHttpClient.post("action/api/team_tweet_pub", params, handler);
}
项目:OSchina_resources_android    文件:OSChinaApi.java   
/**
 * 活动报名
 *
 * @param data
 * @param handler
 */
@Deprecated
public static void eventApply(EventApplyData data, AsyncHttpResponseHandler handler) {
    RequestParams params = new RequestParams();
    params.put("event", data.getEvent());
    params.put("user", data.getUser());
    params.put("name", data.getName());
    params.put("gender", data.getGender());
    params.put("mobile", data.getPhone());
    params.put("company", data.getCompany());
    params.put("job", data.getJob());
    if (!StringUtils.isEmpty(data.getRemark())) {
        params.put("misc_info", data.getRemark());
    }
    post("action/api/event_apply", params, handler);
}
项目:OSchina_resources_android    文件:OSChinaApi.java   
/**
 * 发布评论
 */
public static void pubComment(long sourceId, int type, String content, long referId, long replyId,
                              long reAuthorId,
                              TextHttpResponseHandler handler) {
    RequestParams params = new RequestParams();
    params.put("sourceId", sourceId);
    params.put("type", type);
    params.put("content", content);
    if (referId > 0)
        params.put("referId", referId);
    if (replyId > 0)
        params.put("replyId", replyId);
    if (reAuthorId > 0)
        params.put("reAuthorId", reAuthorId);
    post("action/apiv2/comment_push", params, handler);
}
项目:OSchina_resources_android    文件:OSChinaApi.java   
/**
 * 发布博客
 *
 * @param Blog    博客
 * @param handler 回调
 */
public static void pubBlog(Blog blog, TextHttpResponseHandler handler) {
    RequestParams params = new RequestParams();
    params.put("title", blog.getTitle());
    params.put("abstract", blog.getSummary());
    params.put("system", blog.getSystem());
    params.put("catalog", blog.getCatalog());
    params.put("canVisible", blog.getCanVisible());
    params.put("canComment", blog.getCanComment());
    params.put("isStick", blog.getIsStick());
    params.put("type", blog.getType());
    params.put("content", blog.getContent());
    ApiHttpClient.post("action/apiv2/pub_blog", params, handler);
}
项目:Mobike    文件:BuidUrl.java   
/**
 * 信用积分
 *
 * @return
 */
public static String getCredit()//s
{
    RequestParams requestParms = new RequestParams();
    requestParms.put("userid", useid);//q.getUrl().d()
    requestParms.put("times", System.currentTimeMillis());
    requestParms.put("lang", Locale.getDefault().getLanguage());
    return getUrl("/credit/index.html", requestParms);
}
项目:GitHub    文件:ContentTypeForHttpEntitySample.java   
@Override
public RequestHandle executeSample(AsyncHttpClient client, String URL, Header[] headers, HttpEntity entity, ResponseHandlerInterface responseHandler) {
    RequestParams rParams = new RequestParams();
    rParams.put("sample_key", "Sample String");
    try {
        File sample_file = File.createTempFile("temp_", "_handled", getCacheDir());
        rParams.put("sample_file", sample_file);
    } catch (IOException e) {
        Log.e(LOG_TAG, "Cannot add sample file", e);
    }
    return client.post(this, URL, headers, rParams, "multipart/form-data", responseHandler);
}
项目:FBEventSync    文件:Graph.java   
public static RequestHandle refreshTokens(Context context, String scopes, AsyncHttpResponseHandler handler) {
    SyncHttpClient client = new SyncHttpClient();
    RequestParams params = new RequestParams();
    params.put("client_id", context.getString(R.string.facebook_app_id));
    params.put("redirect_uri", "https://www.facebook.com/connect/login_success.html");
    params.put("response_type", "token");
    params.put("scopes", scopes);
    return client.get("https://www.facebook.com/v2.9/dialog/oauth", params, handler);
}
项目:InstantUpload    文件:BaseInfo.java   
public RequestParams getParams() {
    RequestParams params = new RequestParams();
    params.put("vender_id", vendorId);
    params.put("device_id", deviceId);
    params.put("serial", serial);
    params.put("android_device_unique_id", androidDeviceUniqueId);
    params.put("android_user_unique_id", androidUserUniqueId);
    params.put("android_device_info", androidDeviceInfo);
    params.put("android_os_ver", androidOSVer);
    params.put("lib_version", libVersion);
    params.put("device_info", deviceInfo);

    return params;
}
项目:OSchina_resources_android    文件:OSChinaApi.java   
/**
 * @param type      {@link #TYPE_USER_FLOWS ,#TYPE_USER_FANS}
 * @param userId    userId
 * @param pageToken pageToken
 * @param handler   handler
 */
public static void getUserFansOrFlows(int type, long userId, String pageToken, TextHttpResponseHandler handler) {
    if (userId <= 0) return;
    RequestParams params = new RequestParams();
    params.put("id", userId);
    params.put("pageToken", pageToken);

    String uri = "user_follows";
    if (type == TYPE_USER_FANS) {
        uri = "user_fans";
    }
    ApiHttpClient.get("action/apiv2/" + uri, params, handler);
}
项目:OSchina_resources_android    文件:API.java   
/**
 * 获取项目评论
 *
 * @param id      项目id
 * @param handler 回调
 */
public static void getProjectComments(long id, String token, TextHttpResponseHandler handler) {
    RequestParams params = new RequestParams();
    params.put("projectId", id);
    params.put("pageToken", token);
    ApiHttpClient.get("action/apiv2/git_comments_list", params, handler);
}
项目:JSSample    文件:HttpUtils.java   
public static void post(Context context, String urlString, RequestParams params, JsonHttpResponseHandler res)   //带参数,获取json对象或者数组
{
    if (isNetworkConnected(context)) {
        client.cancelRequests(context, true);
        client.post(urlString, params, res);
    } else {
        makeText(context);
    }

}
项目:OSchina_resources_android    文件:API.java   
/**
 * 获取代码片段
 *
 * @param language language
 * @param type     type
 * @param page     page
 * @param handler  handler
 */
public static void getGists(String language, String type, int page, TextHttpResponseHandler handler) {
    RequestParams params = new RequestParams();
    if (!TextUtils.isEmpty(language))
        params.put("language", language);
    if (!TextUtils.isEmpty(type))
        params.put("type", type);
    params.put("page", page);
    mClient.get("https://gitee.com/api/v3/gists/public", params, handler);
}
项目:OSchina_resources_android    文件:API.java   
/**
 * 发表代码片段评论
 *
 * @param id      id
 * @param name    name
 * @param content content
 * @param handler 回调
 */
public static void pubGistComment(String id, String name, String url, String content, TextHttpResponseHandler handler) {
    RequestParams params = new RequestParams();
    params.put("gistId", id);
    params.put("name", name);
    params.put("url", url);
    params.put("content", content);
    ApiHttpClient.post("action/apiv2/pub_gist_comment", params, handler);
}
项目:JSSample    文件:HttpUtils.java   
public static void post(Context context, String uString, RequestParams params, TextHttpResponseHandler res) {
    if (isNetworkConnected(context)) {
        client.cancelRequests(context, true);
        client.post(uString, params, res);
    } else {
        makeText(context);
    }

}
项目:OSchina_resources_android    文件:OSChinaTeamApi.java   
/**
 * 获取团队项目列表
 *
 * @param teamId
 * @param handler
 */
public static void getTeamProjectList(int teamId,
                                      AsyncHttpResponseHandler handler) {
    RequestParams params = new RequestParams();
    params.put("teamid", teamId);
    ApiHttpClient.get("action/api/team_project_list", params, handler);
}
项目:OSchina_resources_android    文件:OSChinaTeamApi.java   
/**
 * 获取team动态列表
 *
 * @param teamId
 * @param activeId
 * @param pageIndex
 * @param handler
 */
public static void getTeamCommentList(int teamId, int activeId,
                                      int pageIndex, AsyncHttpResponseHandler handler) {
    RequestParams params = new RequestParams();
    params.put("teamid", teamId);
    params.put("id", activeId);
    params.put("pageIndex", pageIndex);
    params.put("pageSize", 20);
    ApiHttpClient.get("action/api/team_reply_list_by_activeid", params,
            handler);
}
项目:OSchina_resources_android    文件:OSChinaApi.java   
/**
 * 请求动弹评论列表
 *
 * @param sourceId 动弹id
 * @param handler  回调
 */
public static void getTweetCommentList(long sourceId, String pageToken, TextHttpResponseHandler handler) {
    RequestParams params = new RequestParams();
    params.put("sourceId", sourceId);
    params.put("pageToken", pageToken);
    ApiHttpClient.get("action/apiv2/tweet_comments", params, handler);
}
项目:OSchina_resources_android    文件:OSChinaTeamApi.java   
/***
 * 获取项目的动态列表
 *
 * @param teamId
 * @param project
 * @param type    "all"(default),"issue","code","other"
 * @param page
 * @param handler
 * @return void
 * @author 火蚁 2015-3-2 下午5:18:54
 */
public static void getTeamProjectActiveList(int teamId,
                                            TeamProject project, String type, int page,
                                            AsyncHttpResponseHandler handler) {
    RequestParams params = new RequestParams();
    params.put("teamid", teamId);
    params.put("projectid", project.getGit().getId());
    if (!TextUtils.isEmpty(project.getSource())) {
        params.put("source", project.getSource());
    }
    params.put("type", type);
    params.put("pageIndex", page);
    ApiHttpClient.get("action/api/team_project_active_list", params,
            handler);
}
项目:OSchina_resources_android    文件:OSChinaApi.java   
/**
 * 修改用户资料
 * 忽略则不修改
 *
 * @param handler 回调
 */
public static void updateUserInfo(String userName,
                                  String signature,
                                  String skill,
                                  String field,
                                  String province,
                                  String city,
                                  TextHttpResponseHandler handler) {
    RequestParams params = new RequestParams();
    if (!TextUtils.isEmpty(userName)) {
        params.put("nickname", userName);
    }
    if (!TextUtils.isEmpty(signature)) {
        params.put("signature", signature);
    }
    if (!TextUtils.isEmpty(skill)) {
        params.put("skill", skill);
    }
    if (!TextUtils.isEmpty(field)) {
        params.put("field", field);
    }
    if (!TextUtils.isEmpty(province)) {
        params.put("province", province);
    }
    if (!TextUtils.isEmpty(city)) {
        params.put("city", city);
    }
    ApiHttpClient.get("action/apiv2/user_edit_infos", params, handler);
}
项目:Mobike    文件:BuidUrl.java   
public static String GetEggShell()//B
{
    RequestParams requestParms = new RequestParams();
    //    requestParms.put("time", RideManager.getUrl().x());
    //    requestParms.put("free", 60 * RideManager.getUrl().y());
    return getHelp("/EggShell.html", requestParms);
}
项目:OSchina_resources_android    文件:OSChinaTeamApi.java   
/***
 * 任务、周报、讨论的回复列表
 *
 * @param teamId
 * @param id
 * @param type      评论列表的类型(周报diary,讨论discuss,任务issue)
 * @param pageIndex
 * @param handler
 * @return void
 * @author 火蚁 2015-2-2 上午11:39:04
 */
public static void getTeamReplyList(int teamId, int id, String type,
                                    int pageIndex, AsyncHttpResponseHandler handler) {
    RequestParams params = new RequestParams();
    params.put("teamid", teamId);
    params.put("id", id);
    params.put("type", type);
    params.put("pageIndex", pageIndex);
    ApiHttpClient
            .get("action/api/team_reply_list_by_type", params, handler);

}
项目:OSchina_resources_android    文件:OSChinaApi.java   
/**
 * update the user icon
 *
 * @param file    file
 * @param handler handler
 */
public static void updateUserIcon(File file, TextHttpResponseHandler handler) {
    if (file == null) return;
    RequestParams params = new RequestParams();
    try {
        params.put("portrait", file);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    post("action/apiv2/user_edit_portrait", params, handler);

}
项目:OSchina_resources_android    文件:OSChinaApi.java   
public static void checkUpdate(TextHttpResponseHandler handler) {
    RequestParams params = new RequestParams();
    params.put("appId", 1);
    params.put("catalog", 1);
    params.put("all", false);
    ApiHttpClient.get("action/apiv2/product_version", params, handler);
}
项目:OSchina_resources_android    文件:OSChinaApi.java   
@Deprecated
public static void getTweetList(int uid, int page, AsyncHttpResponseHandler handler) {
    RequestParams params = new RequestParams();
    params.put("uid", uid);
    params.put("pageIndex", page);
    params.put("pageSize", AppContext.PAGE_SIZE);
    ApiHttpClient.get("action/api/tweet_list", params, handler);
}
项目:OSchina_resources_android    文件:OSChinaApi.java   
@Deprecated
public static void getTweetTopicList(int page, String topic, AsyncHttpResponseHandler handler) {
    RequestParams params = new RequestParams();
    params.put("pageIndex", page);
    params.put("title", topic);
    params.put("pageSize", AppContext.PAGE_SIZE);
    ApiHttpClient.get("action/api/tweet_topic_list", params, handler);
}
项目:OSchina_resources_android    文件:OSChinaApi.java   
@Deprecated
public static void pubLikeTweet(int tweetId, int authorId, AsyncHttpResponseHandler handler) {
    RequestParams params = new RequestParams();
    params.put("tweetid", tweetId);
    params.put("uid", AccountHelper.getUserId());
    params.put("ownerOfTweet", authorId);
    post("action/api/tweet_like", params, handler);
}
项目:OSchina_resources_android    文件:OSChinaApi.java   
@Deprecated
public static void pubUnLikeTweet(int tweetId, int authorId, AsyncHttpResponseHandler handler) {
    RequestParams params = new RequestParams();
    params.put("tweetid", tweetId);
    params.put("uid", AccountHelper.getUserId());
    params.put("ownerOfTweet", authorId);
    post("action/api/tweet_unlike", params, handler);
}
项目:OSchina_resources_android    文件:OSChinaApi.java   
/**
 * @param searchTag   软件分类  推荐:recommend 最新:time 热门:view 国产:list_cn
 * @param page
 * @param handler
 */
@Deprecated
public static void getSoftwareList(String searchTag, int page,
                                   AsyncHttpResponseHandler handler) {
    RequestParams params = new RequestParams();
    params.put("searchTag", searchTag);
    params.put("pageIndex", page);
    params.put("pageSize", AppContext.PAGE_SIZE);
    ApiHttpClient.get("action/api/software_list", params, handler);
}
项目:OSchina_resources_android    文件:OSChinaApi.java   
/**
 * 获取评论列表
 *
 * @PARAM ID
 * @PARAM CATALOG
 * 1新闻 2帖子 3动弹 4动态
 * @PARAM PAGE
 * @PARAM HANDLER
 */
@Deprecated
public static void getCommentList(int id, int catalog, int page
        , AsyncHttpResponseHandler handler) {
    RequestParams params = new RequestParams();
    params.put("catalog", catalog);
    params.put("id", id);
    params.put("pageIndex", page);
    params.put("pageSize", AppContext.PAGE_SIZE);
    params.put("clientType", "android");
    ApiHttpClient.get("action/api/comment_list", params, handler);
}
项目:OSchina_resources_android    文件:OSChinaApi.java   
/**
 * 新版获得各种类型详情统一接口和Model
 */
public static void getDetail(int type, String ident, long id, TextHttpResponseHandler handler) {
    RequestParams params = new RequestParams();
    params.put("type", type);
    params.put("id", id);
    if (!TextUtils.isEmpty(ident))
        params.put("ident", ident);
    ApiHttpClient.get("action/apiv2/detail", params, handler);
}
项目:OSchina_resources_android    文件:OSChinaApi.java   
/**
 * 用户针对某个新闻,帖子,动弹,消息发表评论的接口,参数使用POST方式提交
 *
 * @param catalog           1新闻  2 帖子  3 动弹  4消息中心
 * @param id             被评论的某条新闻,帖子,动弹或者某条消息的id
 * @param uid            当天登陆用户的UID
 * @param content        发表的评论内容
 * @param isPostToMyZone 是否转发到我的空间,0不转发  1转发到我的空间(注意该功能之对某条动弹进行评论是有效,其他情况下服务器借口可以忽略该参数)
 * @param handler
 */
@Deprecated
public static void publicComment(int catalog, long id, int uid, String content
        , int isPostToMyZone, AsyncHttpResponseHandler handler) {
    RequestParams params = new RequestParams();
    params.put("catalog", catalog);
    params.put("id", id);
    params.put("uid", uid);
    params.put("content", content);
    params.put("isPostToMyZone", isPostToMyZone);
    post("action/api/comment_pub", params, handler);
}
项目:OSchina_resources_android    文件:OSChinaApi.java   
public static void pubMessage(long authorId, File content, TextHttpResponseHandler handler) {
    RequestParams params = new RequestParams();
    params.put("authorId", authorId);
    try {
        params.put("file", content);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    post("action/apiv2/messages_pub", params, handler);
}
项目:OSchina_resources_android    文件:OSChinaApi.java   
@Deprecated
public static void publicBlogComment(long blog, int uid, String content
        , AsyncHttpResponseHandler handler) {
    RequestParams params = new RequestParams();
    params.put("blog", blog);
    params.put("uid", uid);
    params.put("content", content);
    post("action/api/blogcomment_pub", params, handler);
}
项目:Mobike    文件:BuidUrl.java   
/**
 * 红包问题
 * @param p
 * @param t
 * @return
 */
public static String getRedPacketProblem(int p, int t)//getUrl
{
    RequestParams requestParms = new RequestParams();
    requestParms.put("p", p);
    requestParms.put("t", t);
    return getHelp("/redPacketProblem.html", requestParms);
}
项目:OSchina_resources_android    文件:OSChinaApi.java   
/**
 * 用户添加收藏
 *
 * @param uid   用户UID
 * @param objid 比如是新闻ID 或者问答ID 或者动弹ID
 * @param type  1:软件 2:话题 3:博客 4:新闻 5:代码
 */
@Deprecated
public static void addFavorite(int uid, long objid, int type,
                               AsyncHttpResponseHandler handler) {
    RequestParams params = new RequestParams();
    params.put("uid", uid);
    params.put("objid", objid);
    params.put("type", type);
    post("action/api/favorite_add", params, handler);
}
项目:OSchina_resources_android    文件:OSChinaApi.java   
/**
 * 获取活动列表
 *
 * @param pageIndex
 * @param uid       <= 0 近期活动 实际的用户ID 则获取用户参与的活动列表,需要已登陆的用户
 * @param handler
 */
@Deprecated
public static void getEventList(int pageIndex, int uid,
                                AsyncHttpResponseHandler handler) {
    RequestParams params = new RequestParams();
    params.put("pageIndex", pageIndex);
    params.put("uid", uid);
    params.put("pageSize", AppContext.PAGE_SIZE);
    ApiHttpClient.get("action/api/event_list", params, handler);
}