Skip to content

Instantly share code, notes, and snippets.


Vasiliy Zukanov techyourchance

View GitHub Profile
techyourchance /
Created Dec 21, 2019
Base class for Java Observable which needs to be aware of whether it's "busy" and expose this information to its clients
public abstract class BaseBusyObservable<LISTENER_CLASS> extends BaseObservable<LISTENER_CLASS> {
private final AtomicBoolean mIsBusy = new AtomicBoolean(false);
public final boolean isBusy() {
return mIsBusy.get();
* Atomically assert not busy and become busy
techyourchance /
Last active May 8, 2020
Base class for Java Observable
public abstract class BaseObservable<LISTENER_CLASS> {
private final Object MONITOR = new Object();
private final Set<LISTENER_CLASS> mListeners = new HashSet<>();
public void registerListener(LISTENER_CLASS listener) {
synchronized (MONITOR) {
boolean hadNoListeners = mListeners.size() == 0;
You can’t perform that action at this time.