Java Code Examples for androidx.lifecycle.Observer#onChanged()

The following examples show how to use androidx.lifecycle.Observer#onChanged() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SingleLiveEvent.java    From monero-wallet-android-app with MIT License 6 votes vote down vote up
@MainThread
public void observe(LifecycleOwner owner, final Observer<? super T> observer) {

    if (hasActiveObservers()) {
        Log.w(TAG, "Multiple observers registered but only one will be notified of changes.");
    }

    // Observe the internal MutableLiveData
    super.observe(owner, new Observer<T>() {
        @Override
        public void onChanged(@Nullable T t) {
            if (mPending.compareAndSet(true, false)) {
                observer.onChanged(t);
            }
        }
    });
}
 
Example 2
Source File: SingleLiveEvent.java    From PopularMovies with MIT License 6 votes vote down vote up
@MainThread
public void observe(LifecycleOwner owner, final Observer<? super T> observer) {

    if (hasActiveObservers()) {
        Timber.w("Multiple observers registered but only one will be notified of changes.");
    }

    // Observe the internal MutableLiveData
    super.observe(owner, new Observer<T>() {
        @Override
        public void onChanged(@Nullable T t) {
            if (mPending.compareAndSet(true, false)) {
                observer.onChanged(t);
            }
        }
    });
}
 
Example 3
Source File: SingleLiveEvent.java    From Deadline with GNU General Public License v3.0 6 votes vote down vote up
@MainThread
@Override
public void observe(@NonNull LifecycleOwner owner, @NonNull final Observer<? super T> observer) {
    if (hasActiveObservers()) {
        Log.w(TAG, "Multiple observers registered but only one will be notified of changes.");
    }

    // Observe the internal MutableLiveData
    super.observe(owner, new Observer<T>() {
        @Override
        public void onChanged(@Nullable T t) {
            if (mPending.compareAndSet(true, false)) {
                observer.onChanged(t);
            }
        }
    });

}
 
Example 4
Source File: SingleLiveEvent.java    From UpdogFarmer with GNU General Public License v3.0 6 votes vote down vote up
@MainThread
public void observe(@NonNull LifecycleOwner owner, @NonNull Observer<? super T> observer) {

    if (hasActiveObservers()) {
        Log.w(TAG, "Multiple observers registered but only one will be notified of changes.");
    }

    // Observe the internal MutableLiveData
    super.observe(owner, new Observer<T>() {
        @Override
        public void onChanged(@Nullable T t) {
            if (mPending.compareAndSet(true, false)) {
                observer.onChanged(t);
            }
        }
    });
}
 
Example 5
Source File: SingleLiveEvent.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
@MainThread
public void observe(@NonNull LifecycleOwner owner, @NonNull final Observer<? super T> observer) {
  if (hasActiveObservers()) {
    Log.w(TAG, "Multiple observers registered but only one will be notified of changes.");
  }

  // Observe the internal MutableLiveData
  super.observe(owner, t -> {
    if (mPending.compareAndSet(true, false)) {
      observer.onChanged(t);
    }
  });
}
 
Example 6
Source File: SingleLiveEvent.java    From Bluefruit_LE_Connect_Android_V2 with MIT License 5 votes vote down vote up
@MainThread
public void observe(@NonNull LifecycleOwner owner, @NonNull final Observer<? super T> observer) {

    if (hasActiveObservers()) {
        Log.w(TAG, "Multiple observers registered but only one will be notified of changes.");
    }

    // Observe the internal MutableLiveData
    super.observe(owner, t -> {
        if (mPending.compareAndSet(true, false)) {
            observer.onChanged(t);
        }
    });
}
 
Example 7
Source File: SingleLiveEvent.java    From Android-nRF-Mesh-Library with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@MainThread
public void observe(@NonNull final LifecycleOwner owner, @NonNull final Observer<? super T> observer) {
    if (hasActiveObservers()) {
        Log.w(TAG, "Multiple observers registered but only one will be notified of changes.");
    }

    // Observe the internal MutableLiveData
    super.observe(owner, t -> {
        if (mPending.compareAndSet(true, false)) {
            observer.onChanged(t);
        }
    });
}
 
Example 8
Source File: SingleLiveEvent.java    From mcumgr-android with Apache License 2.0 5 votes vote down vote up
@MainThread
public void observe(@NonNull final LifecycleOwner owner, @NonNull final Observer<? super T> observer) {

    if (hasActiveObservers()) {
        Timber.w("Multiple observers registered but only one will be notified of changes.");
    }

    // Observe the internal MutableLiveData
    super.observe(owner, t -> {
        if (mPending.compareAndSet(true, false)) {
            observer.onChanged(t);
        }
    });
}
 
Example 9
Source File: SingleLiveEvent.java    From Android-nRF-Blinky with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@MainThread
@Override
public void observe(@NonNull final LifecycleOwner owner, @NonNull final Observer<? super T> observer) {
	if (hasActiveObservers()) {
		Log.w(TAG, "Multiple observers registered but only one will be notified of changes.");
	}

	// Observe the internal MutableLiveData
	super.observe(owner, t -> {
		if (pending.compareAndSet(true, false)) {
			observer.onChanged(t);
		}
	});
}