Skip to content

Instantly share code, notes, and snippets.

@magillus
magillus / RealmContext.java
Created June 7, 2017 21:57
Realm Context wrapper.
package com.example.mat.rxjavaplayground.rxutil;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.util.Collections;
import java.util.List;
import io.reactivex.functions.Function;
@magillus
magillus / RxBoundServcie.java
Last active March 27, 2021 15:07
Rx wrapper around bounded Android Service that emits IBinder. It binds to a service on subscription and unbinds on disposing the subscription's disposable.
package com.example.mat.rxutil;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import java.lang.ref.WeakReference;
@magillus
magillus / RxBroadcastReceiver.java
Last active August 21, 2020 22:25
RxJava2.0 Broadcast Receiver for getting intent broadcasts as Observable<Intent>
/**
* RxJava based broadcast reciever that registers its local BroadcastReceiver until end of subscription.
* Listens for update and passes Intent to the Stream (Subscriber).
*
* Copyright 2016 Mateusz Perlak - http://www.apache.org/licenses/LICENSE-2.0
* Created on 11/18/16.
*/
public class RxBroadcastReceiver implements ObservableOnSubscribe<Intent> {
protected final WeakReference<Context> contextWeakReference;
@magillus
magillus / ContentObserverSubscriber.java
Last active August 16, 2021 23:28
RxContentObserver, wraps ContentObserver registration and on change with RxJava2.0 Observable that will emit updates.
package com.example.mat.rxutil;
import android.content.ContentResolver;
import android.database.ContentObserver;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.os.HandlerThread;
import java.lang.ref.WeakReference;
@magillus
magillus / ContentObserverSubscriber.java
Last active April 18, 2020 21:46
RxContentObserver, wraps ContentObserver registration and on change with RxJava Observable that will emit updates.
package com.example.mat.rxutil;
import android.content.ContentResolver;
import android.database.ContentObserver;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.os.HandlerThread;
import java.lang.ref.WeakReference;