mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-26 09:20:23 +00:00
Ensure you can't set null values in DefaultValueLiveData.
This commit is contained in:
@@ -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();
|
||||
|
Reference in New Issue
Block a user