public class MainViewModel extends ViewModel {
private final MutableLiveData<ArrayList<UserObject>> liveData = new MutableLiveData<>();
public LiveData<ArrayList<UserObject>> getLiveData() {
return liveData;
}
public void getUserList() {
new UserRepository().getUserList(new RepositoryCallBack.UserGetList() {
@Override
public void onResponse(ArrayList<UserObject> userObject) {
liveData.setValue(userObject);
}
@Override
public void onError(int statusCode) {
//Информациб об ошибки необходимо передать в активити (View)
}
});
}
}
sealed class Result {
data class Ok(val data: UserObject): Result()
data class Error(val statusCode: Int): Result()
}