Java Code Examples for com.zhy.http.okhttp.callback.StringCallback

The following examples show how to use com.zhy.http.okhttp.callback.StringCallback. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: OpenWeatherPlus-Android   Source File: AppNetConfig.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * post请求
 *
 * @param url
 * @param params
 * @param headers  请求头是非必传字段,如果没有,设置null即可
 * @param callback
 */
public static final void RequestPost(final String url, final HashMap<String, String> params,
                                     final HashMap<String, String> headers, final StringCallback callback) {
    if ( headers == null ) {
        OkHttpUtils.post().url(url).params(params).build().execute(callback);
    } else {
        OkHttpUtils.post().url(url).headers(headers).params(params).build().execute(callback);
    }
}
 
Example 2
Source Project: OpenWeatherPlus-Android   Source File: AppNetConfig.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * post请求
 *
 * @param url
 * @param params
 * @param headers  请求头是非必传字段,如果没有,设置null即可
 * @param callback
 */
public static final void RequestPost(final String url, final int writeTimeOut, final HashMap<String, String> params,
                                     final HashMap<String, String> headers, final StringCallback callback) {
    if ( headers == null ) {
        OkHttpUtils.post().url(url).params(params).build().readTimeOut(writeTimeOut).execute(callback);
    } else {
        OkHttpUtils.post().url(url).headers(headers).params(params).build().readTimeOut(writeTimeOut).execute(callback);
    }
}
 
Example 3
Source Project: OpenWeatherPlus-Android   Source File: AppNetConfig.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * 上传单个文件
 *
 * @param name     文件标识
 * @param fileName 文件名 如:lyh.png
 * @param file     上传的文件
 * @param params   需要携带的参数
 * @param url      上传的目标地址
 * @param headers  需要携带的请求头
 * @param callback 请求结果的回调
 */
public static final void RequestUpFile(final String name, final int writeTimeOut, final String fileName,
                                       final File file, final HashMap<String, String> params, final String url,
                                       final HashMap<String, String> headers, final StringCallback callback) {
    if ( headers == null ) {
        OkHttpUtils.post().addFile(name, fileName, file).params(params).url(url).build().writeTimeOut(writeTimeOut).execute(callback);
    } else {
        OkHttpUtils.post().addFile(name, fileName, file).params(params).headers(headers).url(url).build().writeTimeOut(writeTimeOut).execute(callback);
    }
}
 
Example 4
Source Project: OpenWeatherPlus-Android   Source File: AppNetConfig.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * 上传多个文件
 *
 * @param key      本次上传的唯一标识
 * @param files    上传的文件,String类型的key为文件名, 如:lyh.png , File类型的value是上传的文件
 * @param params   需要携带的参数
 * @param url      上传的目标地址
 * @param headers  需要携带的请求头信息
 * @param callback 服务器响应结果的回调
 */
public static final void RequestUpFiles(final String key, final HashMap<String, File> files,
                                        final HashMap<String, String> params, final String url,
                                        final HashMap<String, String> headers, final StringCallback callback) {
    if ( headers == null ) {
        OkHttpUtils.post().files(key, files).params(params).url(url).build().execute(callback);
    } else {
        OkHttpUtils.post().files(key, files).params(params).headers(headers).url(url).build().execute(callback);
    }
}
 
Example 5
Source Project: OpenWeatherPlus-Android   Source File: AppNetConfig.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * get请求
 *
 * @param url
 * @param callback
 */
public static final void RequestGet(final String url, final StringCallback callback) {
    OkHttpUtils.get().url(url).build().execute(callback);
}