Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.nimi0112:volleyplus:1.0'
}
dependencies {
implementation("com.github.nimi0112:volleyplus:1.0")
}
<dependency>
<groupId>com.github.nimi0112</groupId>
<artifactId>volleyplus</artifactId>
<version>1.0</version>
</dependency>
libraryDependencies += "com.github.nimi0112" % "volleyplus" % "1.0"
:dependencies [[com.github.nimi0112/volleyplus "1.0"]]
<a href="https://www.buymeacoffee.com/1hakr" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/yellow_img.png" alt="Buy Me A Coffee" height='50' style='border:0px;height:50px;' ></a>
VolleyPlus library Project improvements to Volley along with full image caching.It involves using RequestQueue, RequestTickle and Request.
RequestQueue
- Dispatch Queue which takes a Request and executes in a worker thread or if cache found its takes from cache and responds back to the UI main thread.RequestTickle
- A single class which takes a Request and executes in same thread or if cache found its takes from cache and responds back to the same thread. Mainly useful in sync operations where you want to perform operations sequentially.Request
- All network(HTTP) requests are created from this class. It takes main parameters required for a HTTP request like
VolleyPlus Provides variety of implementations of Request.
VolleyPlus has also very powerful image caching SimpleImageLoder.
NewtworkImageView
usage with SimpleImageLoader
RequestQueue
RequestQueue mRequestQueue = Volley.newRequestQueue(getApplicationContext());
StringRequest stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
....
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
....
}
});
mRequestQueue.add(stringRequest);
RequestTickle
RequestTickle mRequestTickle = VolleyTickle.newRequestTickle(getApplicationContext());
StringRequest stringRequest = new StringRequest(Request.Method.GET, url, null, null);
mRequestTickle.add(stringRequest);
NetworkResponse response = mRequestTickle.start();
if (response.statusCode == 200) {
String data = VolleyTickle.parseResponse(response);
....
}
else{
....
}
SimpleImageLoader
ImageCacheParams cacheParams = new ImageCacheParams(getApplicationContext(), "CacheDirectory");
cacheParams.setMemCacheSizePercent(0.5f);
SimpleImageLoader mImageFetcher = new SimpleImageLoader(getApplicationContext(), R.drawable.holder_image, cacheParams);
mImageFetcher.setMaxImageSize(300);
....
mImageFetcher.get(url, image_view);
OR
network_image_view.setImageUrl(url, mImageFetcher);
network_image_view.setDefaultImageResId(R.drawable.holder_image);
Volley is available as an AAR, so you just need to add the following dependency to your build.gradle
.
buildscript {
repositories {
jcenter()
}
}
...
dependencies {
compile 'dev.dworks.libs:volleyplus:+'
}
...
Copyright 2017 Hari Krishna Dulipudi
Copyright (C) 2011 The Android Open Source Project
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.