All Projects → pranaypatel512 → RxRetroAPICall

pranaypatel512 / RxRetroAPICall

Licence: other
API call example using Retrofit and RxJava2

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to RxRetroAPICall

Mvpframes
整合大量主流开源项目并且可高度配置化的 Android MVP 快速集成框架,支持 AndroidX
Stars: ✭ 100 (+525%)
Mutual labels:  rxjava, rxjava2, retrofit2, rxjava-android
Dagger2
Kotlin Dagger2 example project
Stars: ✭ 145 (+806.25%)
Mutual labels:  rxjava, rxjava2, retrofit2
Fineract-CN-mobile
DEPRECATED project - Check the Apache fineract-cn-mobile project instead
Stars: ✭ 17 (+6.25%)
Mutual labels:  rxjava, retrofit2, retrofit2-rxjava
rxandroid2-retrofit2
Small tutorial to get started with RxAndroid 2 and Retrofit 2
Stars: ✭ 55 (+243.75%)
Mutual labels:  rxjava2, retrofit2, retrofit2-rxjava
Android Mvvm Rx3 Dagger2 Navcomponent
Implemented using MVVM, LiveData, Room, RX3, Dagger2, Coil, View Binding, Navigation Component and AndroidX
Stars: ✭ 72 (+350%)
Mutual labels:  rxjava, retrofit2, rxjava-android
Rxjavapriorityscheduler
RxPS - RxJavaPriorityScheduler - A RxJava Priority Scheduler library for Android and Java applications
Stars: ✭ 138 (+762.5%)
Mutual labels:  rxjava, rxjava2, rxjava-android
android-online-course
Android Online Course
Stars: ✭ 22 (+37.5%)
Mutual labels:  rxjava, rxjava2, rxjava-android
Rx.observe
Transform any method to an Rx Observable ! (VIPER)
Stars: ✭ 34 (+112.5%)
Mutual labels:  rxjava, rxjava2, rxjava-android
Marvel
Marvel Characters Android Application Assigned by smava GmbH
Stars: ✭ 227 (+1318.75%)
Mutual labels:  rxjava, retrofit2, rxjava-android
RxFamilyUser
框架使用retrofit2与rxjava2+databing,Md风格一个开源项目.
Stars: ✭ 21 (+31.25%)
Mutual labels:  rxjava2, retrofit2, retrofit2-rxjava
AndroidMVPArchitecture
Android MVP architecture sample project with or without RxJava and Dagger2 and Kotlin
Stars: ✭ 78 (+387.5%)
Mutual labels:  rxjava, okhttpclient, retrofit2
Aiyagirl
🔥 爱吖妹纸(含 Kotlin 分支版本)——Retrofit + RxJava + MVP 架构 APP 体验代码家的干货集中营 Gank.io,福利多多,不容错过
Stars: ✭ 1,109 (+6831.25%)
Mutual labels:  rxjava, rxjava2, retrofit2
Bigbang
Android base project used by Xmartlabs team
Stars: ✭ 47 (+193.75%)
Mutual labels:  rxjava, rxjava2, retrofit2
Graphql Retrofit Converter
A Retrofit 2 Converter.Factory for GraphQL.
Stars: ✭ 46 (+187.5%)
Mutual labels:  rxjava, rxjava2, retrofit2
iMoney
iMoney 金融项目
Stars: ✭ 55 (+243.75%)
Mutual labels:  rxjava, rxjava2, retrofit2
Fountain
Android Kotlin paged endpoints made easy
Stars: ✭ 175 (+993.75%)
Mutual labels:  rxjava, rxjava2, retrofit2
Mvvmhabit
goldze: 本人喜欢尝试新的技术,以后发现有好用的东西,我将会在企业项目中实战,没有问题了就会把它引入到MVVMHabit中,一直维护着这套框架,谢谢各位朋友的支持。如果觉得这套框架不错的话,麻烦点个 star,你的支持则是我前进的动力!
Stars: ✭ 6,789 (+42331.25%)
Mutual labels:  rxjava, rxjava2, retrofit2
Rxjava2 Operators Magician
你用不惯 RxJava,只因缺了这把钥匙 🔑 You are not used to RxJava, just because of the lack of this key.
Stars: ✭ 868 (+5325%)
Mutual labels:  rxjava, rxjava2, rxjava-android
Httprequest
基于Retrofit2+RxJava2+OkHttp3的网络请求框架,可以完美的应用到组件化、MVP模式等项目中
Stars: ✭ 181 (+1031.25%)
Mutual labels:  rxjava, rxjava2, retrofit2
BakingApp
Udacity Android Developer Nanodegree, project 2.
Stars: ✭ 54 (+237.5%)
Mutual labels:  rxjava2, retrofit2, retrofit2-rxjava

RxRetroAPICall

API call example using Retrofit and RxJava2

About RxRetroAPICall Example

  • Common API calling strcture to avoide code duplication.
  • Easy to use and understand.
  • Using Latest version of Retrofit and Rxjava2

RxAPICallback.java

/**
 * Common Callback to call API request response.
 * @param <P> : response Type
 */
public interface RxAPICallback<P> {
    void onSuccess(P t);

    void onFailed(Throwable throwable);
}

RxAPICallHelper.java

/**
 *
 * Common API Call Helper to make API call.
 */
public class RxAPICallHelper {
    public RxAPICallHelper() {
    }

    public static <T> Disposable call(Observable<T> observable, final RxAPICallback<T> rxAPICallback) {
        if (observable == null) {
            throw new IllegalArgumentException("Observable must not be null.");
        }


        if (rxAPICallback == null) {
            throw new IllegalArgumentException("Callback must not be null.");
        }

        return observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<T>() {
                    @Override
                    public void accept(@NonNull T t) throws Exception {
                        rxAPICallback.onSuccess(t);
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(@NonNull Throwable throwable) throws Exception {
                        if (throwable != null) {
                            rxAPICallback.onFailed(throwable);
                        } else {
                            rxAPICallback.onFailed(new Exception("Error: Something went wrong in api call."));
                        }
                    }
                });

    }
}

Example Call

/**
     * Call API to get stackoverflow User badge details
     */
    private void getUserBadgeDetails() {
        mProgressDialog.show();
        StackOverFlowUserBadgesService badgesService = ApiProduction.getInstance(this).provideService(StackOverFlowUserBadgesService.class);
        Observable<StackOverFlowUserBadgesResponse> responseObservable = badgesService.getBadges("2949612");
        disposable = RxAPICallHelper.call(responseObservable, new RxAPICallback<StackOverFlowUserBadgesResponse>() {
            @Override
            public void onSuccess(StackOverFlowUserBadgesResponse badgesResponse) {
                mProgressDialog.dismiss();
                showToast(badgesResponse.getItems().size() > 0 ? "Success" : "Failed");
                if (badgesResponse.getItems().size() > 0) {
                    calculateBadges(badgesResponse);
                }
                disposeCall();
            }

            @Override
            public void onFailed(Throwable throwable) {
                disposeCall();
                mProgressDialog.dismiss();
                showToast(throwable.getLocalizedMessage());
            }
        });
    }

Example Output

Find this project useful ? ❤️

  • Support it by clicking the ⭐️ button on the upper right of this page. ✌️

License

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].