All Projects → VincentMasselis → RxUIKotlin

VincentMasselis / RxUIKotlin

Licence: other
Kotlin designed reactive extensions for the Android UI

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to RxUIKotlin

TpHulk
androidx,mvp,mvvm,jetpack
Stars: ✭ 19 (-26.92%)
Mutual labels:  rxjava2
android-eth-wallet
Android cryptocurrency wallet app with clean architecture
Stars: ✭ 28 (+7.69%)
Mutual labels:  rxjava2
RightSheetBehavior
Modified BottomSheetBehavior to be shown from the right side.
Stars: ✭ 14 (-46.15%)
Mutual labels:  android-ui
android-tableview-kotlin
Android's missing TableView component.
Stars: ✭ 40 (+53.85%)
Mutual labels:  android-ui
android-live-broadcasts
Live broadcast receiver library for Android
Stars: ✭ 19 (-26.92%)
Mutual labels:  rxjava2
AndroidBatteryStats
Displays all battery stats of an Android device using broadcast receiver.
Stars: ✭ 20 (-23.08%)
Mutual labels:  android-ui
RxFamilyUser
框架使用retrofit2与rxjava2+databing,Md风格一个开源项目.
Stars: ✭ 21 (-19.23%)
Mutual labels:  rxjava2
Football-App
⚽ Football App using MVVM, LiveData, RxJava2, DI, Room, Repository Patern
Stars: ✭ 17 (-34.62%)
Mutual labels:  rxjava2
Reside-Menu
By applying viewpager animation you can also make AMAZING Reside Menu's
Stars: ✭ 72 (+176.92%)
Mutual labels:  android-ui
CeilingLayout
CeilingLayout用来控制子View的吸顶联滑,理论上支持实现了NestedScrollingChild的联滑控件,如NestedScrollView、RecyclerView、SmartRefreshLayout等;只需要在xml里配置需要吸顶子View的位置索引就能自动实现吸顶联滑效果。
Stars: ✭ 26 (+0%)
Mutual labels:  android-ui
AndroidEssentialLibraries
👻 Android Essential Libraries - A couple of the Android Libraries to use in your Projects 🛠
Stars: ✭ 203 (+680.77%)
Mutual labels:  android-ui
DragBoardView
⭐ Android 看板,支持项拖拽、列拖拽。Draggable kanban/board view for Android.
Stars: ✭ 85 (+226.92%)
Mutual labels:  android-ui
RxWebView
RxJava2 binding APIs for Android's WebView
Stars: ✭ 22 (-15.38%)
Mutual labels:  rxjava2
recycler-adapter
RecyclerView-driven declarative UIs
Stars: ✭ 124 (+376.92%)
Mutual labels:  android-ui
WaveView
Simple Android library to draw sinusoidal waves.
Stars: ✭ 43 (+65.38%)
Mutual labels:  android-ui
mvp-android-template
MVP Android Template to give you a Quick Head Start for your next Android Project. It implements MVP Architecture using Dagger2, Room, RxJava2 , Retrofit2
Stars: ✭ 20 (-23.08%)
Mutual labels:  rxjava2
checkview
An animating check mark
Stars: ✭ 86 (+230.77%)
Mutual labels:  android-ui
SignInSignupScreen-Android
SignIn and SignUp in android 😊😊😉
Stars: ✭ 51 (+96.15%)
Mutual labels:  android-ui
signal-strength-view
📶 Material design signal strength view for Android
Stars: ✭ 30 (+15.38%)
Mutual labels:  android-ui
MVPArchitecture
Android MVP architecture in Kotlin using Dagger2, RxJava2, Retrofit2 and so on
Stars: ✭ 27 (+3.85%)
Mutual labels:  rxjava2

RxUIKotlin

Download Build Status

Android UI + Kotlin + RxJava3

Made with love at the Equisense HQ. This library is used in our Equisense app since a few years.

Introduction

This library is made to manage your subscriptions when fetching data with RxJava3 inside a Activity, a Fragment or a ViewHolder. It cancel your request depending of the state of the lifecycle by disposing your subscription (calling dispose() on the Disposable object returned by the subscribe methods).

RxUIKotlin is lightweight, the .aar file weights less than 50kb and it only require a few dependencies: appcompat, recyclerview, rxjava and rxandroid. RxUIKotlin will never change the behavior of your chaning, it only dipose it when you want to.

RxUIKotlin is splitted into 2 separates artifacts, the core, which is explained here, and the fragmentmanager. fragmentmanager helps you to listen fragment events, adding or removing from a FragmentManager. You can use fragmentmanager without core, both are independent.

Unlike RxLifecycle, this library doesn't transform your observable by emitting onComplete() when your view is gone, it just dispose() your Disposable, that's all. So you can use Single or Completable in your code without manually handle every CancellationException.

Unlike android-disposebag, this library doesn't use Android Architecture to listen the lifecycle because the class Lifecycle from Android Architecture doesn't emit states PRE_ATTACH, ATTACH, ACTIVITY_CREATED, VIEW_CREATED, DESTROY_VIEW, SAVE_INSTANCE_STATE, DESTROY_VIEW and DETACH while RxUIKotlin does.

Restrictions

It works only with RxJava3, it's designed to work with Kotlin (usage of extensions) and it dispose only the fragments from the AndroidX library.

The last supported RxJava2 version is the 1.2.3

Installation

implementation "com.vincentmasselis.rxuikotlin:rxuikotlin-core:3.0.0" //Use version 1.2.3 for RxJava2

Usage

Inside a Fragment:

anObservable
  .subscribe {
    //Do your stuff
  }
  .disposeOnState(FragmentState.DESTROY_VIEW, this)

It's exactly the same for activities:

  .disposeOnState(ActivityState.DESTROY, this)

and the view holders after you have overriden LifecycleAdapter and LifecycleViewHolder:

  .disposeOnState(ViewHolderState.ADAPTER_DETACH, this)

That's all !

RecyclerView and ViewHolder

Unlike Fragment and Activity, a RecyclerView.ViewHolder doesn't have explicit methods which represents a lifecyle, but, under the hood, there is a way to create a lifecycle-like behavior by using the modified version of RecyclerView.Adapter named LifecycleAdapter and the modified RecyclerView.ViewHolder named LifecycleViewHolder.

LifecycleAdapter creates 2 lifecycles "Window Attach-Detach" and "Adapter Attach-Detach". First calls LifecycleViewHolder.onWindowAttach and LifecycleViewHolder.onWindowDetach methods when the ViewHolder is dettached from the window and attached again a few moments before onBindViewHolder is called. Second calls LifecycleViewHolder.onAdapterAttach and LifecycleViewHolder.onAdapterDetach when the LifecycleAdapter is added or removed from the RecyclerView.

To use theses methods, you have to subclass LifecycleAdapter instead of RecyclerView.Adapter and LifecycleViewHolder instead of RecyclerView.ViewHolder, then, inside your ViewHolder, you can now override theses 4 methods onWindowAttach, onWindowDetach, onAdapterAttach and onAdapterDetach to create you own lifecycle behavior just like you do with a Fragment or an Activity.

override fun onAdapterAttach() {
  super.onAdapterAttach()
  anObservable
    .subscribe {
      //Do your stuff
    }
    .disposeOnState(ViewHolderState.ADAPTER_DETACH, this)
}

The only restraint of using LifecycleAdapter is the obligation to call subscribe:

myRecyclerView.subscribe(MyAdapter()).disposeOnState(ActivityState.DESTROY, this)

Repport an issue

https://github.com/VincentMasselis/RxUIKotlin/issues

TODO

  • Example app
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].