MCPcopy Index your code
hub / github.com/HujiangTechnology/RestVolley

github.com/HujiangTechnology/RestVolley @v1.2.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.2.2 ↗ · + Follow
553 symbols 1,251 edges 62 files 283 documented · 51%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

RestVolley


A http request engine based on Volley and OkHttp, giving up Apache HttpClient request. supports image loading, restful api requesting, and file downloading. READ MORE

Dependency


binary on jcenter

dependency with Gradle:

compile 'com.hujiang.restvolley:restvolley:1.0.11'

Functions


Restful API request

RestVolley make restful API requesting conveniently.It support the most http method request, such as GET,HEAD,POST,DELETE,OPTIONS,PATCH,PUT,TRACE.

GET POST DELETE PUT HEAD PATCH OPTIONS TRACE
Cacheable Y N N N Y N Y Y
requireBody N Y N Y N Y N N
permitBody Y
  • create a request
//Get request
new GetRequest(context).url("").execute(String.class, new RestVolleyCallback<String>());
//post request
new PostRequest(context).url("").execute(String.class, new RestVolleyCallback<String>());
//Delete request
new DeleteRequest(context).url("").execute(String.class, new RestVolleyCallback<String>());
//Put request
new PutRequest(context).url("").execute(String.class, new RestVolleyCallback<String>());
//Head request
new HeadRequest(context).url("").execute(String.class, new RestVolleyCallback<String>());
//Patch request
new PatchRequest(context).url("").execute(String.class, new RestVolleyCallback<String>());
//Options request
new OptionsRequest(context).url("").execute(String.class, new RestVolleyCallback<String>());
//Trace request
new TraceRequest(context).url("").execute(String.class, new RestVolleyCallback<String>());
  • set http request params: header, urlparams, requestbody, contentType, charset
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(.....);
  • Cache
//default false
setShouldCache(true);
setCacheEntry(...)
  • RetryPolicy
setRetryPolicy(new DefaultRetryPolicy())
  • Priority
//default is Priority.Normal
setPriority(Priority.Normal)
  • ContentType and Charset
    //default is "application/json"
    setContentType("application/json")
    //default is "UTF-8"
    setCharset("UTF-8")

  • Tag
setTag(tag);
  • UserAgent
setUserAgent("")
  • timeout
setConnectTimeout(...);
setReadTimeout(...);
setWriteTimeout(...);

//for all timout
setTimeout(...);

  • header
addHeader(key, value);
//or
addHeaders(map);
  • params
//add url params
addParams(key, value);

//for post/put/patch or delete
addParams(key, file);
addParams(key, inputstream);
  • body and HttpEntity
//body and HttpEntity for post/put/patch or delete
setBody(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();

  • execute and syncExecute
//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);
  • request with new RequestEngine

suggest using the default RequestEngine, only if the request need proxy.

//
new GetRequest(context).setRequestEngine(...);

//create a new RequestEngine
RestVolley.newRequestEngine(context, engineTag);

Image load

RestVolleyImageLoader has memory cache and disk cache, supports not only network image request, but sdcard/assets/res/ContentProvider Uri image request, uri scheme like:

http/https http://www.google.com/xxx/xxx.png
file file:///mnt/sdcard/xxx.png
assets assets://assets_default.png
res “drawable://” + R.drawable.drawable_default, or "drawable://" + R.raw.defaut
ContentProvider content://media/external/images/media/27916
  • set global config
RestVolleyImageLoader.instance(context).setConfig(ImageLoaderGlobalConfig cfg);
  • ImageLoaderGlobalConfig
ImageLoaderGlobalConfig.create().memCacheSize(..).diskCacheSize(..).diskCacheDir(..).requestEngine(..);
  • ImageLoadOption
ImageLoadOption.create().defaultImgResId(..)
    .errorImgResId(..)
    .imgLoadAnimation(..)
    .scaleType(..)
    .maxWidth(..)
    .maxHeight(..)
    .cacheEnable(..);
  • displayImage
RestVolleyImageLoader.instance(context).displayImage(uri, imageView);
//
RestVolleyImageLoader.instance(context).displayImage(uri, imageView, imageLoadOption);
  • loadImage
RestVolleyImageLoader.instance(context).loadImage(uri, ImageListener);
//
RestVolleyImageLoader.instance(context).loadImage(uri, ImageLoadOption, ImageListener);
  • syncLoadImage
RestVolleyImageLoader.instance(context).syncLoadImage(String uri);
//
RestVolleyImageLoader.instance(context).syncLoadImage(uri, ImageLoadOption);
  • others
RestVolleyImageLoader.instance(context).isCached(...);
RestVolleyImageLoader.instance(context).removeCache(...);

File download

new RestVolleyDownload(context)
    .url(url)
    .addHeader(key, value)
    .tag(tag)
    .setProxy(...)
    .setTimeout(...)
    .setIsAppend(..)
    .download(......)
    //or
    .syncdownload(....)

simple static download.

RestVolleyDownload.download(....)
//or
RestVolleyDownload.syncDownload(....)

Data upload

Using RestVolleyUpload as PostRequest.

new RestVolleyUpload(context).url(..).execute(...);
//or
new RestVolleyUpload(context).url(..).syncExecute(...);

License


Copyright (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.0

Unless required by applicable law or agreed to in writing, software
distributed 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 and
limitations under the License.

Change Log


Extension points exported contracts — how you extend this code

ImageListener (Interface)
Interface for the response handlers on image requests. The call flow is this: 1. Upon being attached to a request, [4 …
restvolley/src/main/java/com/hujiang/restvolley/image/ImageLoaderCompat.java
OnDownloadListener (Interface)
下载回调监听接口. [1 implementers]
restvolley/src/main/java/com/hujiang/restvolley/download/RestVolleyDownload.java
UrlRewriter (Interface)
An interface for transforming URLs before use.
restvolley/src/main/java/com/hujiang/restvolley/OkHttpStack.java
ImageDisplayer (Interface)
image display interface @author simon @version 1.0.0 @since 2016-10-25
restvolley/src/main/java/com/hujiang/restvolley/image/ImageDisplayer.java
JsonValueInterface (Interface)
This interface is used to encapsulate JSON values that are handled entirely by the app. For example, apps could manage a
restvolley/src/main/java/com/hujiang/restvolley/webapi/request/JsonValueInterface.java

Core symbols most depended-on inside this repo

get
called by 35
restvolley/src/main/java/com/hujiang/restvolley/cookie/PersistentCookieStore.java
add
called by 22
restvolley/src/main/java/com/hujiang/restvolley/cookie/PersistentCookieStore.java
getDiskCache
called by 15
restvolley/src/main/java/com/hujiang/restvolley/image/RestVolleyImageCache.java
getUrl
called by 11
restvolley/src/main/java/com/hujiang/restvolley/webapi/request/RestVolleyRequest.java
execute
called by 9
restvolley/src/main/java/com/hujiang/restvolley/TaskScheduler.java
load
called by 9
restvolley/src/main/java/com/hujiang/restvolley/image/ImageLoaderCompat.java
getName
called by 8
restvolley/src/main/java/com/hujiang/restvolley/ThreadPool.java
attemptRetryOnException
called by 8
restvolley/src/main/java/com/hujiang/restvolley/compat/RVNetwork.java

Shape

Method 470
Class 75
Interface 6
Enum 2

Languages

Java100%

Modules by API surface

restvolley/src/main/java/com/hujiang/restvolley/webapi/request/RestVolleyRequest.java68 symbols
restvolley/src/main/java/com/hujiang/restvolley/image/ImageLoaderCompat.java56 symbols
restvolley/src/main/java/com/hujiang/restvolley/download/RestVolleyDownload.java37 symbols
restvolley/src/main/java/com/hujiang/restvolley/webapi/request/SimpleMultipartEntity.java23 symbols
restvolley/src/main/java/com/hujiang/restvolley/image/RestVolleyImageCache.java21 symbols
app/src/main/java/com/hujiang/restvolley/demo/DownloadActivity.java20 symbols
restvolley/src/main/java/com/hujiang/restvolley/webapi/request/JsonStreamerEntity.java18 symbols
restvolley/src/main/java/com/hujiang/restvolley/image/RestVolleyImageLoader.java16 symbols
restvolley/src/main/java/com/hujiang/restvolley/cookie/PersistentCookieStore.java16 symbols
restvolley/src/main/java/com/hujiang/restvolley/webapi/request/RestVolleyRequestWithBody.java15 symbols
restvolley/src/main/java/com/hujiang/restvolley/ThreadPool.java15 symbols
restvolley/src/main/java/com/hujiang/restvolley/image/NetworkImageViewCompat.java14 symbols

For agents

$ claude mcp add RestVolley \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact