Updated AndroidX libraries

pull/157/head
M66B 5 years ago
parent 7c856c7a9e
commit 24ea54f034

@ -126,18 +126,18 @@ configurations.all {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
def appcompat_version = "1.1.0-beta01"
def recyclerview_version = "1.1.0-alpha06"
def appcompat_version = "1.1.0-rc01"
def recyclerview_version = "1.1.0-beta01"
def coordinatorlayout_version = "1.1.0-beta01"
def constraintlayout_version = "2.0.0-beta1"
def material_version = "1.1.0-alpha07"
def browser_version = "1.0.0"
def lifecycle_version = "2.1.0-beta01"
def lifecycle_version = "2.1.0-rc01"
def room_version = "2.1.0"
def paging_version = "2.1.0"
def preference_version = "1.1.0-beta01"
def preference_version = "1.1.0-rc01"
def work_version = "2.1.0-rc01"
def exif_version = "1.1.0-alpha01"
def exif_version = "1.1.0-beta01"
def billingclient_version = "2.0.1"
def javamail_version = "1.6.3"
def jsoup_version = "1.12.1"
@ -172,6 +172,8 @@ dependencies {
implementation "androidx.browser:browser:$browser_version"
// https://mvnrepository.com/artifact/androidx.lifecycle/lifecycle-runtime
// https://mvnrepository.com/artifact/androidx.lifecycle/lifecycle-livedata
// https://mvnrepository.com/artifact/androidx.lifecycle/lifecycle-livedata-core
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
annotationProcessor "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"

@ -16,8 +16,6 @@
package androidx.lifecycle;
import android.os.SystemClock;
import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
@ -91,22 +89,14 @@ public abstract class ComputableLiveData<T> {
@Override
public void run() {
boolean computed;
long age;
do {
computed = false;
// compute can happen only in 1 thread but no reason to lock others.
if (mComputing.compareAndSet(false, true)) {
// as long as it is invalid, keep computing.
try {
age = SystemClock.elapsedRealtime();
T value = null;
while (mInvalid.compareAndSet(true, false)) {
long now = SystemClock.elapsedRealtime();
if (age + 1500 < now && value != null) {
eu.faircode.email.Log.i(mLiveData + " post age=" + (now - age));
age = now;
mLiveData.postValue(value);
}
computed = true;
value = compute();
}

@ -69,12 +69,12 @@ public abstract class LiveData<T> {
// how many observers are in active state
@SuppressWarnings("WeakerAccess") /* synthetic access */
int mActiveCount = 0;
private volatile Object mData = NOT_SET;
private volatile Object mData;
// when setData is called, we set the pending data and actual data swap happens on the main
// thread
@SuppressWarnings("WeakerAccess") /* synthetic access */
volatile Object mPendingData = NOT_SET;
private int mVersion = START_VERSION;
private int mVersion;
private boolean mDispatchingValue;
@SuppressWarnings("FieldCanBeLocal")
@ -92,6 +92,24 @@ public abstract class LiveData<T> {
}
};
/**
* Creates a LiveData initialized with the given {@code value}.
*
* @param value initial value
*/
public LiveData(T value) {
mData = value;
mVersion = START_VERSION + 1;
}
/**
* Creates a LiveData with no value assigned to it.
*/
public LiveData() {
mData = NOT_SET;
mVersion = START_VERSION;
}
private void considerNotify(ObserverWrapper observer) {
if (!observer.mActive) {
return;
@ -204,7 +222,7 @@ public abstract class LiveData<T> {
assertMainThread("observeForever");
AlwaysActiveObserver wrapper = new AlwaysActiveObserver(observer);
ObserverWrapper existing = mObservers.putIfAbsent(observer, wrapper);
if (existing != null && existing instanceof LiveData.LifecycleBoundObserver) {
if (existing instanceof LiveData.LifecycleBoundObserver) {
throw new IllegalArgumentException("Cannot add the same observer"
+ " with different lifecycles");
}
@ -353,7 +371,7 @@ public abstract class LiveData<T> {
return mActiveCount > 0;
}
class LifecycleBoundObserver extends ObserverWrapper implements GenericLifecycleObserver {
class LifecycleBoundObserver extends ObserverWrapper implements LifecycleEventObserver {
@NonNull
final LifecycleOwner mOwner;
@ -438,7 +456,7 @@ public abstract class LiveData<T> {
}
}
private static void assertMainThread(String methodName) {
static void assertMainThread(String methodName) {
if (!ArchTaskExecutor.getInstance().isMainThread()) {
throw new IllegalStateException("Cannot invoke " + methodName + " on a background"
+ " thread");

@ -23,6 +23,23 @@ package androidx.lifecycle;
*/
@SuppressWarnings("WeakerAccess")
public class MutableLiveData<T> extends LiveData<T> {
/**
* Creates a MutableLiveData initialized with the given {@code value}.
*
* @param value initial value
*/
public MutableLiveData(T value) {
super(value);
}
/**
* Creates a MutableLiveData with no value assigned to it.
*/
public MutableLiveData() {
super();
}
@Override
public void postValue(T value) {
super.postValue(value);

Loading…
Cancel
Save