Giter VIP home page Giter VIP logo

rxvolley's Introduction

##RxVolley = Volley + RxJava + OkHttp

####Retrofit? No, I like Volley. RxVolley is modified Volley. Removed the HttpClient, and support RxJava.

If you are building with Gradle, simply add the following line to the dependencies section of your build.gradle file:

compile 'com.kymjs.rxvolley:rxvolley:1.1.0'

// If use okhttp function
compile 'com.kymjs.rxvolley:okhttp:1.1.0'

// If use image-loader function
compile 'com.kymjs.rxvolley:bitmapcore:1.1.0'

Getting Started

Builder pattern to create objects.
or 中文帮助 (正在不断完善中)

####Callback method do Get request and contenttype is form

HttpParams params = new HttpParams();

//http header, optional parameters
params.putHeaders("cookie", "your cookie");
params.putHeaders("User-Agent", "rxvolley"); 

//request parameters
params.put("name", "kymjs");
params.put("age", "18");

HttpCallback callBack = new HttpCallback(){
	@Override
    public void onSuccess(String t) {
    }
    @Override
    public void onFailure(int errorNo, String strMsg) {
    }
}

new RxVolley.Builder()
	.url("http://www.kymjs.com/rss.xml")
    .httpMethod(RxVolley.Method.GET) //default GET or POST/PUT/DELETE/HEAD/OPTIONS/TRACE/PATCH
    .cacheTime(6) //default: get 5min, post 0min
    .contentType(RxVolley.ContentType.FORM)//default FORM or JSON
    .params(params)
    .shouldCache(true) //default: get true, post false
    .callback(callBack)
    .encoding("UTF-8") //default
    .doTask();

####Callback method do Post request and contenttype is json

String paramJson = "{\n" +
                "    \"name\": \"kymjs\", " +
                "    \"age\": \"18\" " +
                "}";

//request parameters, json format
HttpParams params = new HttpParams();
params.putJsonParams(paramJson);

// upload progress
ProgressListener listener = new ProgressListener(){
    @Override
    public void onProgress(long transferredBytes, long totalSize){
    }
}

new RxVolley.Builder()
	.url("http://www.kymjs.com/rss.xml")
    .httpMethod(RxVolley.Method.POST) //default GET or POST/PUT/DELETE/HEAD/OPTIONS/TRACE/PATCH
    .cacheTime(6) //default: get 5min, post 0min
    .params(params)
    .contentType(RxVolley.ContentType.JSON)
    .shouldCache(true) //default: get true, post false
    .progressListener(listener) //upload progress
    .callback(callback)
    .encoding("UTF-8") //default
    .doTask();

####return Observable<Result> type

Observable<Result> observable = new RxVolley.Builder()
	.url("http://www.kymjs.com/rss.xml")
    .httpMethod(RxVolley.Method.POST) //default GET or POST/PUT/DELETE/HEAD/OPTIONS/TRACE/PATCH
    .cacheTime(6) //default: get 5min, post 0min
    .params(params)
    .contentType(RxVolley.ContentType.JSON)
    .getResult(); 
    
//do something
observable.subscribe(subscriber);

##Requirements

RxVolley can be included in any Android application.

RxVolley supports Android 3.1, API12 (HONEYCOMB_MR1) and later.

##More

####Which project uses it ?

####License

Licensed under the Apache License Version 2.0. The "License"

rxvolley's People

Contributors

kymjs avatar 70kg avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.