在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:RestVolley开源软件地址:https://gitee.com/firefly_osc/RestVolley开源软件介绍:RestVolleyA http request engine based on Volley and OkHttp, giving up Apache HttpClient request. supports image loading, restful api requesting, and file downloading. READ MORE Dependencybinary on jcenter dependent with Maven: <dependency> <groupId>com.hujiang.restvolley</groupId> <artifactId>restvolley</artifactId> <version>1.0.1</version></dependency> or Gradle: compile 'com.hujiang.restvolley:restvolley:1.0.1' FunctionsRestful API requestRestVolley make restful API requesting conveniently.It support the most http method request, such as
//Get requestnew GetRequest(context).url("").execute(String.class, new RestVolleyCallback<String>());//post requestnew PostRequest(context).url("").execute(String.class, new RestVolleyCallback<String>());//Delete requestnew DeleteRequest(context).url("").execute(String.class, new RestVolleyCallback<String>());//Put requestnew PutRequest(context).url("").execute(String.class, new RestVolleyCallback<String>());//Head requestnew HeadRequest(context).url("").execute(String.class, new RestVolleyCallback<String>());//Patch requestnew PatchRequest(context).url("").execute(String.class, new RestVolleyCallback<String>());//Options requestnew OptionsRequest(context).url("").execute(String.class, new RestVolleyCallback<String>());//Trace requestnew TraceRequest(context).url("").execute(String.class, new RestVolleyCallback<String>());
new GetRequest(context).url("") .setTag("") .setRetryPolicy(new DefaultRetryPolicy()) .setShouldCache(true) .setPriority(Priority.Normal) //default is "application/json" .setContentType("application/json") //default is "UTF-8" .setCharset("UTF-8") .addHeader("userId", "12345") .addHeaders(map) .setUserAgent("") .addParams(key, value) .setCacheEntry(...) .execute(.....);
//default falsesetShouldCache(true);setCacheEntry(...)
setRetryPolicy(new DefaultRetryPolicy())
//default is Priority.NormalsetPriority(Priority.Normal)
//default is "application/json" setContentType("application/json") //default is "UTF-8" setCharset("UTF-8")
setTag(tag);
setUserAgent("")
setConnectTimeout(...);setReadTimeout(...);setWriteTimeout(...);//for all timoutsetTimeout(...);
addHeader(key, value);//oraddHeaders(map);
//add url paramsaddParams(key, value);//for post/put/patch or deleteaddParams(key, file);addParams(key, inputstream);
//body and HttpEntity for post/put/patch or deletesetBody(byte[] bytes);setBody(HttpEntity httpEntity);setBody(String s);//convert params to form data entity.paramsToFormEntity();//convert params to json entity.paramsToJsonEntity();//convert params to multipart entity.paramsToMultipartEntity();
//async execute with callback.new GetRequest(context).url().execute(String.class, new RestVolleyCallback<String>());//sync execute.RestVolleyResponse<String> response = new GetRequest(context).url().syncExecute(String.class);
suggest using the default RequestEngine, only if the request need proxy. //new GetRequest(context).setRequestEngine(...);//create a new RequestEngineRestVolley.newRequestEngine(context, engineTag); Image loadRestVolleyImageLoader has memory cache and disk cache, supports not only network image request, but sdcard/assets/res/ContentProvider Uri image request, uri scheme like:
RestVolleyImageLoader.instance(context).setConfig(ImageLoaderGlobalConfig cfg);
ImageLoaderGlobalConfig.create().memCacheSize(..).diskCacheSize(..).diskCacheDir(..).requestEngine(..);
ImageLoadOption.create().defaultImgResId(..) .errorImgResId(..) .imgLoadAnimation(..) .scaleType(..) .maxWidth(..) .maxHeight(..) .cacheEnable(..);
RestVolleyImageLoader.instance(context).displayImage(uri, imageView);//RestVolleyImageLoader.instance(context).displayImage(uri, imageView, imageLoadOption);
RestVolleyImageLoader.instance(context).loadImage(uri, ImageListener);//RestVolleyImageLoader.instance(context).loadImage(uri, ImageLoadOption, ImageListener);
RestVolleyImageLoader.instance(context).syncLoadImage(String uri);//RestVolleyImageLoader.instance(context).syncLoadImage(uri, ImageLoadOption);
RestVolleyImageLoader.instance(context).isCached(...);RestVolleyImageLoader.instance(context).removeCache(...); File downloadnew RestVolleyDownload(context) .url(url) .addHeader(key, value) .tag(tag) .setProxy(...) .setTimeout(...) .setIsAppend(..) .download(......) //or .syncdownload(....) simple static download. RestVolleyDownload.download(....)//orRestVolleyDownload.syncDownload(....) Data uploadUsing RestVolleyUpload as PostRequest. new RestVolleyUpload(context).url(..).execute(...);//ornew RestVolleyUpload(context).url(..).syncExecute(...); LicenseCopyright (C) 2016 Hujiang, Inc.Copyright (C) 2014 Xiaoke Zhang.Copyright (C) 2011 The Android Open Source Project.Copyright (C) 2016 Square, Inc.Licensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License. Change Log
|
请发表评论