All Projects → amalhanaja → ReactiveConnectivity

amalhanaja / ReactiveConnectivity

Licence: Apache-2.0 license
ReactiveConnectivity - a library for Listen Connectivity Change on Android

Programming Languages

kotlin
9241 projects
java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to ReactiveConnectivity

RxHttp
基于RxJava2+Retrofit+OkHttp4.x封装的网络请求类库,亮点多多,完美兼容MVVM(ViewModel,LiveData),天生支持网络请求和生命周期绑定,天生支持多BaseUrl,支持文件上传下载进度监听,支持断点下载,支持Glide和网络请求公用一个OkHttpClient⭐⭐⭐
Stars: ✭ 25 (+13.64%)
Mutual labels:  rxjava, rxjava2
Rxble
使用 RxJava 封装的低功耗蓝牙类库
Stars: ✭ 203 (+822.73%)
Mutual labels:  rxjava, rxjava2
Rxpermission
Reactive permissions for Android
Stars: ✭ 182 (+727.27%)
Mutual labels:  rxjava, rxjava2
Httprequest
基于Retrofit2+RxJava2+OkHttp3的网络请求框架,可以完美的应用到组件化、MVP模式等项目中
Stars: ✭ 181 (+722.73%)
Mutual labels:  rxjava, rxjava2
Prefser
Wrapper for Android SharedPreferences with object serialization and RxJava Observables
Stars: ✭ 228 (+936.36%)
Mutual labels:  rxjava, rxjava2
Rxbus
Event Bus By RxJava.
Stars: ✭ 2,126 (+9563.64%)
Mutual labels:  rxjava, rxjava2
Reactivewifi
Android library listening available WiFi Access Points and related information with RxJava Observables
Stars: ✭ 186 (+745.45%)
Mutual labels:  rxjava, rxjava2
Reactivebeacons
Android library scanning BLE beacons nearby with RxJava
Stars: ✭ 171 (+677.27%)
Mutual labels:  rxjava, rxjava2
Reactivenetwork
Android library listening network connection state and Internet connectivity with RxJava Observables
Stars: ✭ 2,484 (+11190.91%)
Mutual labels:  rxjava, rxjava2
Rxfit
🏃Reactive Fitness API Library for Android and RxJava
Stars: ✭ 218 (+890.91%)
Mutual labels:  rxjava, rxjava2
Mvvm Architecture Android Beginners
This repository contains a sample app that implements MVVM architecture using Kotlin, ViewModel, LiveData, and etc.
Stars: ✭ 176 (+700%)
Mutual labels:  rxjava, rxjava2
Kpermissions
A Kotlin library which helps to request runtime permissions in Android.
Stars: ✭ 253 (+1050%)
Mutual labels:  rxjava, rxjava2
Disposer
Easily dispose rxJava streams with Android's Lifecycle
Stars: ✭ 176 (+700%)
Mutual labels:  rxjava, rxjava2
RxAnimator
An RxJava2 binding for android Animator
Stars: ✭ 80 (+263.64%)
Mutual labels:  rxjava, rxjava2
Fountain
Android Kotlin paged endpoints made easy
Stars: ✭ 175 (+695.45%)
Mutual labels:  rxjava, rxjava2
Androidbasemvp
🚀一个快速搭建MVP+RxJava2+Retrofit 基础框架,主要是封装有Http网络请求、日志、缓存、加载等待、toast、页面状态布局管理、权限、RxBus、Glide图片加载等组件,方便快速开发新项目、减少开发成本。
Stars: ✭ 184 (+736.36%)
Mutual labels:  rxjava, rxjava2
Reactivesensors
Android library monitoring device hardware sensors with RxJava
Stars: ✭ 161 (+631.82%)
Mutual labels:  rxjava, rxjava2
Rxwear
⌚️ Reactive Wearable API Library for Android and RxJava
Stars: ✭ 163 (+640.91%)
Mutual labels:  rxjava, rxjava2
Rxjava3 Android Examples
RxJava 3 Android Examples - Migration From RxJava 2 to RxJava 3 - How to use RxJava 3 in Android
Stars: ✭ 213 (+868.18%)
Mutual labels:  rxjava, rxjava2
Android Mvvm Architecture
This repository contains a detailed sample app that implements MVVM architecture using Dagger2, Room, RxJava2, FastAndroidNetworking and PlaceholderView
Stars: ✭ 2,720 (+12263.64%)
Mutual labels:  rxjava, rxjava2

ReactiveConnectivity

ReactiveConnectivity - a library for Listen Connectivity Change on Android

API codebeat badge

ReactiveConnectivity is an Android Library to Listening NetworkConnectivity with RxJava Observables, It's written with Reactive Programming Approach. Library supports both new and legacy network monitoring.

Installation

  • Add the following to your project level build.gradle:
allprojects {
	repositories {
		maven { url "https://jitpack.io" }
	}
}
  • Add this to your app build.gradle:
dependencies {
	implementation 'com.github.amalhanaja:ReactiveConnectivity:1.0'
}

Permission

Add the ACCESS_NEWORK_STATE permission to AndroidManifest.xml

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

Using RxJava2

  • Getting Observbale:
private val observable by lazy {
        ReactiveConnectivity.buildObserver(this)
                .subscribeOn(Schedulers.computation())
                .observeOn(AndroidSchedulers.mainThread())
    }
private var disposable: Disposable? = null  // Lazy Initialization
  • Initialize disposable on onStart() for Activity OR onResume() for Fragment method :
disposable = observable.subscribe({ onChange ->
            // TODO : DO SOMETHING ON NETWORK CHANGE
        }, { error ->
            // TODO : HANDLE ERROR HERE
        })
  • Dispose disposable on onStop() for Activity OR onPause() for Fragment method to avoid Memory Leaks :
disposable?.dispose()

Without RxJava2

  • Initialize Observer:
private val observer by lazy {
        ReactiveConnectivity(
                context = this,
                onError = { it.printStackTrace() },
                onChange = {
                    Toast.makeText(this, "MAIN ACTIVITY : ${it.name}", Toast.LENGTH_SHORT).show()
                }
        )
}
  • Subscribe observer on onStart() for Activity OR onResume() for Fragment method :
observer.subscribe()
  • Dispose observer on onStop() for Activity OR onPause() for Fragment method to avoid Memory Leaks :
disposable.dispose()

License

Copyright 2018 Alfian Akmal Hanantio

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.

Special thanks to pwittchen, ReactiveX, JetBrains and jitpack.io for their contributions to this project.

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