mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 02:38:36 +00:00
Ensure you can't set null values in DefaultValueLiveData.
This commit is contained in:
parent
3b601896d2
commit
a2de8a2a05
@ -3,6 +3,8 @@ package org.thoughtcrime.securesms.util;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import org.whispersystems.libsignal.util.guava.Preconditions;
|
||||
|
||||
/**
|
||||
* Helps prevent all the @Nullable warnings when working with LiveData.
|
||||
*/
|
||||
@ -15,6 +17,18 @@ public class DefaultValueLiveData<T> extends MutableLiveData<T> {
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postValue(@NonNull T value) {
|
||||
Preconditions.checkNotNull(value);
|
||||
super.postValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(@NonNull T value) {
|
||||
Preconditions.checkNotNull(value);
|
||||
super.setValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull T getValue() {
|
||||
T value = super.getValue();
|
||||
|
Loading…
x
Reference in New Issue
Block a user