Ensure you can't set null values in DefaultValueLiveData.
This commit is contained in:
parent
3b601896d2
commit
a2de8a2a05
1 changed files with 14 additions and 0 deletions
|
@ -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…
Add table
Reference in a new issue