G2A Many GEOs
SHARE
TWEET

Untitled

a guest Apr 10th, 2020 127 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.example.weatherapp.common
  2.  
  3. import androidx.annotation.MainThread
  4. import androidx.lifecycle.LifecycleOwner
  5. import androidx.lifecycle.MutableLiveData
  6. import androidx.lifecycle.Observer
  7. import java.util.concurrent.atomic.AtomicBoolean
  8.  
  9. class MutableLiveEvent<T> : MutableLiveData<T>() {
  10.     private val pending = AtomicBoolean(false)
  11.  
  12.     @MainThread
  13.     override fun observe(owner: LifecycleOwner, observer: Observer<in T>) {
  14.         super.observe(owner, Observer { t ->
  15.             if (pending.compareAndSet(true, false)) {
  16.                 observer.onChanged(t)
  17.             }
  18.         })
  19.     }
  20.  
  21.     @MainThread
  22.     override fun setValue(t: T?) {
  23.         pending.set(true)
  24.         super.setValue(t)
  25.     }
  26.  
  27.     @MainThread
  28.     fun call() {
  29.         value = null
  30.     }
  31. }
RAW Paste Data
Ledger Nano X - The secure hardware wallet
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top