All Projects → leonardoxh → Livedata Call Adapter

leonardoxh / Livedata Call Adapter

Licence: apache-2.0
A simple LiveData call adapter for retrofit

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Livedata Call Adapter

Jetpackmvvm
🐔🏀一个Jetpack结合MVVM的快速开发框架,基于MVVM模式集成谷歌官方推荐的JetPack组件库:LiveData、ViewModel、Lifecycle、Navigation组件 使用Kotlin语言,添加大量拓展函数,简化代码 加入Retrofit网络请求,协程,帮你简化各种操作,让你快速开发项目
Stars: ✭ 1,100 (+824.37%)
Mutual labels:  okhttp, retrofit, livedata
WanAndroid
wanandroid的Kotlin版,采用Android X
Stars: ✭ 20 (-83.19%)
Mutual labels:  retrofit, okhttp, okhttp3
Okhttp Json Mock
Mock your datas for Okhttp and Retrofit in json format in just a few moves
Stars: ✭ 231 (+94.12%)
Mutual labels:  json, okhttp, retrofit
RestaurantsExplorer
Android application build with MVVM Pattern, using Zomato API to enable search cities arround the world and display the city restaurants on a map.
Stars: ✭ 32 (-73.11%)
Mutual labels:  retrofit, okhttp, livedata
AndroidGo
Android、Flutter 开发者帮助 APP。包含事件分发、性能分析、Google Jetpack组件、OkHttp、RxJava、Retrofit、Volley、Canvas绘制以及优秀博文代码案例等内容,帮助开发者快速上手!
Stars: ✭ 30 (-74.79%)
Mutual labels:  retrofit, okhttp, livedata
Retrofiturlmanager
🔮 Let Retrofit support multiple baseUrl and can be change the baseUrl at runtime (以最简洁的 Api 让 Retrofit 同时支持多个 BaseUrl 以及动态改变 BaseUrl).
Stars: ✭ 1,961 (+1547.9%)
Mutual labels:  okhttp, okhttp3, retrofit
android-clean-architecture
🚀🚀🚀 The boilerplate for Android using Kotlin & Clean architecture.
Stars: ✭ 21 (-82.35%)
Mutual labels:  retrofit, okhttp, livedata
Newandroidarchitecture Component Github
Sample project based on the new Android Component Architecture
Stars: ✭ 229 (+92.44%)
Mutual labels:  architecture, retrofit, livedata
WanAndroidJetpack
🔥 WanAndroid 客户端,Kotlin + MVVM + Jetpack + Retrofit + Glide。基于 MVVM 架构,用 Jetpack 实现,网络采用 Kotlin 的协程和 Retrofit 配合使用!精美的 UI,便捷突出的功能实现,欢迎下载体验!
Stars: ✭ 124 (+4.2%)
Mutual labels:  retrofit, okhttp, livedata
RxHttp
基于RxJava2+Retrofit+OkHttp4.x封装的网络请求类库,亮点多多,完美兼容MVVM(ViewModel,LiveData),天生支持网络请求和生命周期绑定,天生支持多BaseUrl,支持文件上传下载进度监听,支持断点下载,支持Glide和网络请求公用一个OkHttpClient⭐⭐⭐
Stars: ✭ 25 (-78.99%)
Mutual labels:  retrofit, okhttp, okhttp3
Kriptofolio
Free open source minimalistic cryptocurrencies portfolio app for Android.
Stars: ✭ 79 (-33.61%)
Mutual labels:  retrofit, okhttp, livedata
Viabus Architecture
让 Android 开发可以像流水线一样高效的,职责分离架构 ⚡ 不同于 MVP 的配置解耦,也不能和 似是而非 的 MVVM - Clean 同日而语。VIABUS 是世界范围内首个明确提出,通过职责分离,来真正实现 UI 和 业务并行开发的 Android 项目级开发架构和设计模式理念。
Stars: ✭ 485 (+307.56%)
Mutual labels:  okhttp, architecture, retrofit
Wanandroid
🏄 基于Architecture Components dependencies (Lifecycles,LiveData,ViewModel,Room)构建的WanAndroid开源项目。 你值得拥有的MVVM快速开发框架:https://github.com/jenly1314/MVVMFrame
Stars: ✭ 410 (+244.54%)
Mutual labels:  okhttp3, architecture, livedata
Aachulk
️🔥️🔥️🔥AACHulk是以Google的ViewModel+DataBinding+LiveData+Lifecycles框架为基础, 结合Okhttp+Retrofit+BaseRecyclerViewAdapterHelper+SmartRefreshLayout+ARouter打造的一款快速MVVM开发框架
Stars: ✭ 109 (-8.4%)
Mutual labels:  okhttp, retrofit, livedata
Meteorite
一个基于Android MVP的简单明了的指引性通用架构,目的是帮助更多的开发者去全面了解实践开发相关的各种技术,快速搭建属于自已的APP。这个项目涉及到如下技术的实际应用:1、MVP 2、网络请求(Novate基于rxjava,okhttp,retrofit封装架构)3、DbFlow(可保存文件入SD卡) 4、6.0权限申请 5、XRecyclerView 6、万能Adapter7、异常处理 8、日志打印 9、屏幕适配 10、代码混淆 11、多渠道打包 12、内存泄露检测 13、热修复 14、升级更新 15、极光推送 工程更新完善中……欢迎关注 @特别感谢ZJ.Y的Logo支持。
Stars: ✭ 49 (-58.82%)
Mutual labels:  okhttp, retrofit
Easygo
基于Kotlin、OkHttp的声明式网络框架,像写HTML界面一样写网络调用代码
Stars: ✭ 40 (-66.39%)
Mutual labels:  okhttp, retrofit
Tdcapp
Sample app which access the TDC (The Developer's Conference) REST API.
Stars: ✭ 55 (-53.78%)
Mutual labels:  retrofit, livedata
Androidarchitecture
Recommended architecture by Android
Stars: ✭ 883 (+642.02%)
Mutual labels:  architecture, livedata
Fetch
The best file downloader library for Android
Stars: ✭ 1,124 (+844.54%)
Mutual labels:  okhttp, retrofit
Contentful.java
Java SDK for Contentful's Content Delivery API
Stars: ✭ 63 (-47.06%)
Mutual labels:  okhttp, retrofit

Android Arsenal Build Status

LiveData Call Adapter for Retrofit

A Retrofit 2 CallAdapter.Factory for Android LiveData

Usage

Add LiveDataCallAdapterFactory as a Call adapter when building your Retrofit instance:

Retrofit retrofit = new Retrofit.Builder()
        .baseUrl("https://example.com")
        .addCallAdapterFactory(LiveDataCallAdapterFactory.create())
        .addConverterFactory(LiveDataResponseBodyConverterFactory.create())
        .addConverterFactory(YourConverterFactory.create())
        .build();

Your service methods can now use LiveData as their return type, but, note that we also have a LiveDataResponseBodyConverterFactory this wrapper is necessary when you have a converter that touch on the return type like moshi or gson, to bypass the Resource<T> class and give to the Converter.Factory the correct type to serialize.

public interface SuperService {
    @GET("/pimba") LiveData<Resource<Pimba>> getPimba();
    @GET("/pimba") LiveData<Response<Resource<Pimba>>> getPimbas();
}

Please note the usage of the Resource object, it is required to provide the error callback to the LiveData object, so when you want verify what is happening on your network call for example:

retrofit.create(SuperService.class)
        .getPimba()
        .observe(this, new Observer<Resource<Pimba>>() {
            @Override
            public void onChange(Resource<Pimba> resource) {
                if (resource.isSuccess()) {
                    //doSuccessAction with resource.resource
                } else {
                    //doErrorAction with resource.error
                }
            }
        })

Gradle dependency

dependencies {
    implementation "com.github.leonardoxh:retrofit2-livedata-adapter:1.1.2"
}

Inspiration

License

Copyright 2018 Leonardo Rossetto

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