Posts

RxNetworking : Single Service class handle multiple request

I have single API Web Service class to handle multiple Reqeust using RxNetworking. STEP - 1 : Add INETERNET Permission --------------------------------------------------- <uses-permission android:name="android.permission.INTERNET"/> --------------------------------------------------- STEP - 2 : Add library in App-Level Gradle ---------------------------------------------------     //REACTIVE     implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'     implementation 'io.reactivex.rxjava2:rxjava:2.0.8'     implementation 'com.amitshekhar.android:android-networking:1.0.1'     implementation 'com.amitshekhar.android:jackson-android-networking:1.0.1' --------------------------------------------------- STEP - 3 :  RxNetworkingClass ------------------------------------------- public class RxNetworkingClass {     private static RxNetworkingClass instance = null;     Completion...

RxNetworking - POST Method

Making a POST Request AndroidNetworking . post( " https://fierce-cove-29863.herokuapp.com/createAnUser " ) .addBodyParameter( " firstname " , " Amit " ) .addBodyParameter( " lastname " , " Shekhar " ) .setTag( " test " ) .setPriority( Priority . MEDIUM ) .build() .getAsJSONObject( new JSONObjectRequestListener () { @Override public void onResponse ( JSONObject response ) { // do anything with response } @Override public void onError ( ANError error ) { // handle error } }); You can also post java object, json, file, etc in POST request like this. User user = new User (); user . firstname = " Amit " ; user . ...

RxNetworking - GET, PATH, HEADER

Installation link here :  http://rxandroid.blogspot.in/2018/03/rxnetworking-installation-and.html In Below Code - Pagination work happen AndroidNetworking. get ( "https://fierce-cove-29863.herokuapp.com/getAllUsers/{pageNumber}" ) .addPathParameter( "pageNumber" , "0" ) .addQueryParameter( "limit" , "3" ) .addHeaders( "token" , "1234" ) .setTag( "test" ) .setPriority(Priority. LOW ) .build() .getAsJSONArray( new JSONArrayRequestListener() { @Override public void onResponse(JSONArray response) { // do anything with response for ( int i = 0 ; i < response.length(); i++){ try { // System.out.println("Output --> "+response.g...

RxNetworking - Installation and configuration

Here, page of RxNetworking : https://github.com/amitshekhariitbhu/Fast-Android-Networking --> To install library - // REACTIVE compile 'io.reactivex.rxjava2:rxandroid:2.0.1' compile 'io.reactivex.rxjava2:rxjava:2.1.8' compile 'com.amitshekhar.android:rx2-android-networking:1.0.0' compile 'com.amitshekhar.android:jackson-android-networking:1.0.1' NOTE : Check latest version and code on above link. --> Paste below code in 'OnCreate'         AndroidNetworking.initialize(getApplicationContext());         // Then set the JacksonParserFactory like below         AndroidNetworking.setParserFactory(new JacksonParserFactory()); and also add Internet permission in Manifest.

Temp-1

1. Print Primptive & Non-Primptive Data Type - Using Flowable, Observable -------------------------------------------------------------------- A. Observable Observable.just( "one", "two", "three" ) .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(value -> textView.append(value+", ") ); B. Flowable  Flowable.just( "one", "two", "three" ) .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(value -> textView.append(value+", ") ); C. CompletableToFlowable  CompletableToFlowable.just( "one", "two", "three" ) .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(value -> textView.append(value+", ") ); ---------------------------------------------------------------------- 2. Print collection - Using Flowable, Observabl...

Installation

1. Add below library to App-Level Gradle compile ' io.reactivex.rxjava2:rxandroid:2.0.1 ' compile ' io.reactivex.rxjava2:rxjava:2.1.7 ' 2. Use Java 8 compatibility code - To support lambda expression and java 8+ feature   compileOptions {  targetCompatibility 1.8  sourceCompatibility 1.8  }