GithubHelp home page GithubHelp logo

wepeiyanglite's Introduction

WePeiYangLite

WePeiYang lite version

  • rebuilding now

Network Module Usage

for example,

API Request: GET /auth/token/get?twtuname={}&twtpasswd={}

API Response:

{
	"error_code": 1000,
	"message": "message",
	"data": {
		"token": "xxxxxxx"
	}
}

Following these steps to add new API:

  1. add data model class in package com.twt.service.model. Note this, declaring the variable as public.

    public class Token {
    	public String token;
    }
    
    
  2. add HTTP API to class com.twt.service.api.WePeiYang.

    @GET("/auth/token/get")
    
Observable<APIResponse<Token>> login(@Query("twtuname")String twtuname, @Query("twtpasswd")String twtpasswd);
    
  3. add public method to class com.twt.service.api.WePeiYangClient.

    public void login(Object tag, Subscriber<Token> subscriber, String username, String password) {
    	Subscription subscription = mService.login(username, password)
    		.map(new ResponseTransformer<Token>())
        	.compose(WePeiYangClient.<Token>applySchedulers())
    	  	.subscribe(subscriber);
       addSubscription(tag, subscription);
    

} ```

Following these steps to use new API.
  1. Add OnNextListener in your working Controller or Presenter, or anywhere you want.

    protected OnNextListener<Token> mOnTokenListener = new OnNextListener<Token>() {
    	@Override
    	public void onNext(Token token) {
    		// do some stuff...
    	}
    }
    
  2. Just call the new API method.

    WePeiYangClient.getInstance()
    	.login(this, new APISubscriber<>(mContext, mOnTokenListener), twtuname, twtpasswd);
    
    

wepeiyanglite's People

Contributors

life2015 avatar tjliqy 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.