DownZ


Source link: https://github.com/100rabhkr/DownZLibrary

DownZ

| View release history

DownZ is an HTTP library that boosts networking in Android apps and makes it significantly easier and faster.

DownZ offers the following benefits:

  • Handles HTTP requests.
  • Transparent memory response caching of JSON and Images with support for request prioritization.
  • Cancel a request of image upload or download at any given time.
  • Images in memory cache are auto removed if not used for a long time.
  • Ease of customization, for example, cancel request and clear cache.
  • Strong requisition that makes it easy to effectively manage UI with data being fetched asynchronously from the network.

DownZ excels at handling HTTP requests.It comes with built-in support for images, JSON and Xml. By providing built-in support for the features you require, DownZ frees you from writing tons of code and finally allows you to concentrate on the logic that is specific to your app.


Download

You can use Gradle

Step 1. Add the JitPack repository to your build file , Add it in your root build.gradle at the end of repositories:

allprojects {
  repositories {

...
maven {
 url 'https://jitpack.io' 
}
  
}
 
}
 

Step 2. Add the dependency

dependencies {

compile 'com.github.100rabhkr:DownZLibrary:1.1' 
}
 

Or Maven:

Step 1. Add the JitPack repository to your build file

<repositories>  <repository>

<id>jitpack.io</id>

<url>https://jitpack.io</url>  </repository> </repositories> 

Step 2. Add the dependency

<dependency>
  <groupId>com.github.100rabhkr</groupId>
  <artifactId>DownZLibrary</artifactId>
  <version>1.1</version> </dependency> 

Or Sbt:

Step 1. Add the JitPack repository to your build file Add it in your build.sbt at the end of resolvers:

 resolvers += "jitpack" at "https://jitpack.io" 

Step 2. Add the dependency

 libraryDependencies += "com.github.100rabhkr" % "DownZLibrary" % "1.1" 

Snapshots from Sample App


Download Sample App

All the source code can be downloaded from Github's Release page

You can also download the sample app from here

How do I use DownZ?

Make Standard Request

…  DownZ

 .from(mContext) //context

  .load(DownZ.Method.GET, “http://yoururl.com”)

 .asBitmap()  //asJsonArray() or asJsonObject() or asXml() can be used depending on need

 .setCallback(new HttpListener<Bitmap>() {

  @Override

  public void onRequest() {

 //On Beginning of request

}

@Override

  public void onResponse(Bitmap data) {

 if(data != null){

  // do something

 
}

  
}

@Override

  public void onError() {

 //do something when there is an error

}

@Override

  public void onCancel() {

 //do something when request cancelled

}

 
}
);
 

Pass Header or Request Parameters (Optional)


 ... DownZ

 .from(MainActivity.this)

 .load(DownZ.Method.GET,mUrl)

 .setHeaderParameter("key","value")

 .setRequestParameter("key1","value1")

 .setRequestParameter("key2","value2")

 .asBitmap()

 .setCallback(new HttpListener<Bitmap>() {

  @Override

  public void onRequest() {

}

@Override

  public void onResponse(Bitmap bitmap) {

if(bitmap != null){

  //do something

}

  
}

@Override

  public void onError() {

}

@Override

  public void onCancel() {

}

 
}
);
 

Enable Cache

... public class SomeActivity extends AppCompatActivity {

  ...
  CacheManager<JSONArray> cacheManager; // we can use JSONObject, Bitmap as generic type
  @Override
  protected void onCreate(Bundle savedInstanceState) {

...

cacheManager=new CacheManager<>(40*1024*1024);
 // 40mb
  
}
  public void OnRequestMade(View v){

DownZ

 .from(this)

 .load(DownZ.Method.GET, "http://www.url.com")

 .asJsonArray()

 .setCacheManager(cacheManager)

 .setCallback(new HttpListener<JSONArray>() {

  @Override

  public void onRequest() {

//fired when request begins

  
}

@Override

  public void onResponse(JSONArray data) {

if(data!=null){

 // do some stuff here

}

  
}

@Override

  public void onError() {

}

@Override

  public void onCancel() {

}

 
}
);
 
}
 
}
 

Load Image into ImageView

... public class SomeActivity extends AppCompatActivity {

  ...
  CacheManager<Bitmap> cacheManager;

@Override
  protected void onCreate(Bundle savedInstanceState) {

...

cacheManager=new CacheManager<>(40*1024*1024);
 // 40mb

imageview = (ImageView) findViewById(R.id.image_profile);

imageview.setDrawingCacheEnabled(true);
 //can be used if Image has to be shared afterwards

imageview.buildDrawingCache();

...

  
}
 //event to make request public void btnLoadImageClicked(View v){

  DownZ

 .from(this)

 .load(DownZ.Method.GET, "http://www.url.com/image.jpg")

 .asBitmap()

 .setCacheManager(cacheManager)

 .setCallback(new HttpListener<Bitmap>() {

  @Override

  public void onRequest() {

//fired when request begin
 
}

@Override

  public void onResponse(Bitmap data) {

if(data!=null){

 // do some stuff here

 imageview.setImageBitmap(data);

}

  
}

@Override

  public void onError() {

}

@Override

  public void onCancel() {

}

 
}
);
 
}
  
}
 

Removing from Cache

 ...  public class SomeActivity extends AppCompatActivity {

  ...
  CacheManager<Bitmap> cacheManager;

@Override
  protected void onCreate(Bundle savedInstanceState) {

...

String mUrl = "http://yoururl.com/image.png";

cacheManager=new CacheManager<>(40*1024*1024);
 // 40mb

imageview = (ImageView) findViewById(R.id.image_profile);

imageview.setDrawingCacheEnabled(true);
 //can be used if Image has to be shared afterwards

imageview.buildDrawingCache();

...

  
}
 //event to clear item from cache public void btntoClearCache(View v){

cacheManager.removeDataFromCache(mUrl);
 
}
 
}
 

Getting Help

To report a specific problem or feature request in DownZ, you can open a new issue on Github. For questions, suggestions, or even to say 'hi', just drop an email at [email protected]

Contributing

If you like DownZ, please contribute by writing at [email protected]. Your help and support would make DownZ even better. Before submitting pull requests, contributors must sign Google's individual contributor license agreement.

Author

Saurabh Kumar - @100rabhkr on GitHub, @NotSaurabhKumar on Twitter

License

MIT See the LICENSE file for details.

Disclaimer

This is not an official Google product.

Resources

Official Google Actions SDK is written in Node.js. But in many situations voice interfaces like Google Home or Google Assistant will extend or replace mobile apps. If you are old fashioned Android engineer and the most of your code is already written in Java, why not reuse it and build voice extension to app on your own? And this is the main reason to build Google Actions Java SDK - enabling as much developers as possible to build their brilliant ideas for Google Assistant and Home.

Currently this is just working proof of concept of Google Actions Java SDK. It means that there is no documentation, fixed interface, (not much) unit tests and many, many others.

Google Actions Java SDK is build based on official Node.js library, but it's not a mirror copy of it. The goal is to make it fully compatible with Conversational Protocol of Assistant Platform.

Applozic Android Video Calling SDK lets you integrate video call, audio call, real time chat and in-app messaging in just few lines of code.

A versatile layout that fades its edges regardless of child view type.

WDate is a short way utility class that wraps the standard Date class, providing many useful methods without using the Calendar object.

This class aims to help developers to avoid writing boring DateUtils classes for every project.

Simplify your code to its minimum expression with this set of Kotlin extensions for Realm. Forget about all boilerplate related with Realm API and performs database operations in one line of code.

This library allows to use Material steppers inside Android applications.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes