Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Without author's permission, this code is only for learning and cannot be used for other purposes.
Clone or download
Notice: Creating folder will generate an empty file .keep, because not support in Git

#WTAndroid 一个封装好的Android快速开发集合类.


WTHttpUtils wtHttpUtils = new WTHttpUtils(this); 
wtHttpUtils.setProgressDialogVisiable(true); //default 不设置默认显示加载dialog
wtHttpUtils.setProgressDialogCancelable(true); //default 不设置默认可以按返回键取消
wtHttpUtils.setProgressDialogMessage("标题","加载中"); //default 设置标题和内容 只传一个参数表示只设置内容 不设置默认不显示标题/内容默认为"加载中"

###一个post请求示例 //post参数设置 //非String参数值推荐使用 String.valueof(123); //支持上传文件 File image = new File("/sdcard/example.png"); Map<String, Object> postParams = new HashMap<String, Object>(); postParams.put("id", String.valueof(123)); postParams.put("image", new File("/sdcard/example.png"));

    "", //请求地址 (required)
    WTHttpUtils.HTTP_POST,   //请求方式  WTHttpUtils.HTTP_POST 或 WTHttpUtils.HTTP_GET 指定其他会在public void fail(String reason) {} 返回 HTTP_METHOD_ERROR 错误 必须 (required)
    postParams,  //指定为HTTP_POST时使用 (optional)
    5000, // default 超时设置 (optional)
    5000, // default 超时设置 (optional
    User.class,  //若返回为json字段 可设置此变量,请求并解析json成功后会在 public void json(Object json){}回调 (optional)
    new OnWTHttpRequestCompleteCallback() { //请求成功后的回调 (required)
        public void success(String response) {
            //请求成功后返回的response 不论什么情况 只要成功请求都会返回
            textView.setText("success\n\n" + response);
        public void fail(String reason) {
            //有如下这几个值 可以按需处理
            //public final static String HTTP_METHOD_ERROR;   //请求方法错误
            //public final static String HTTP_REQUEST_USER_CANCEL;  //请求过程中用户按返回键取消请求
            //public final static String HTTP_REQUEST_TIMEOUT;  //请求超时 
            //public final static String HTTP_CLIENT_PROTOCOL_EXCEPTION; //请求超时
            //public final static String HTTP_IO_EXCEPTION; //url网址错误
            //public final static String HTTP_UNKNOW_EXCEPTION; //未知异常
            //public final static String HTTP_RESPONSE_ERROR; //请求错误
            //public final static String HTTP_RESPONSE_STATUS_CODE_ERROR; //网页状态返回值不为200
            //public final static String HTTP_JSON_OBJECT_NOT_MATCH; //json与指定类型不匹配
            textView.setText("reason\n\n" + reason);
        public void json(Map<String, Object> json) {
            textView.setText("json\n\n" + json.toString());
        public void json(Object json) {


WTStringUtils 字符串判断常用类
WTViewHolder 简洁的ViewHolder(用法

Comments ( 0 )

Sign in for post a comment


这是一个Android开发过程中常用的方法集合,会不断添加新功能,旨在减少开发的代码量,提高开发效率. spread retract


No release




load more
can not load any more