Giter Site home page Giter Site logo

retrofitclient's Introduction

RetrofitClient

基于Retrofit和Rxjava封装的请求工具类

Base Retrofit& Rxjava Encapsulates the request of the tools

基于Retrofit2.0 封装的超好用的RetrofitClient

GET

RetrofitClient.getInstance(context)
              .createBaseApi()
              .get("you path url"
                    ,maps, maps, new Subscriber<IpResult>());

POST

RetrofitClient.getInstance(context)
             .createBaseApi(
              ).post("you path url"
                    ,maps, maps, new Subscriber<IpResult>());

JSON

          RequestBody jsonbody = RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"), new Gson().toJson(user));

     RetrofitClient.getInstance(MainActivity.this)
         .createBaseApi()
         .json("url", jsonBody, new BaseSubscriber<T>(context) {

  }

                   

#UpLoad

    RequestBody requestFile =
                    RequestBody.create(MediaType.parse("image/jpg"), new File(mPath));
        
    RetrofitClient.getInstance(MainActivity.this)
              .createBaseApi()
               .upload(url, requestFile, new Subscriber<ResponseBody>);

Download

  RetrofitClient.getInstance(MainActivity.this)
                 .createBaseApi()

                    .download(url1, new CallBack());

Execute you APIService

    //create  you APiService    
     MyApiService service = RetrofitClient.getInstance(MainActivity.this).create(MyApiService.class);    
   // execute and add observable    
   RetrofitClient.getInstance(MainActivity.this).execute(            
                              service.getData("21.22.11.33"), new Subscriber<IpResult>() {                                     

                   
               });}

更多介绍:http://www.jianshu.com/p/29c2a9ac5abf

http://blog.csdn.net/sk719887916/article/details/51958010

Author : Tamic

推荐使用:

Novate: https://github.com/Tamicer/Novate

retrofitclient's People

Contributors

tamicer 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.