Home | History | Annotate | Download | only in lifecycle

Lines Matching defs:source

2  * Copyright (C) 2017 The Android Open Source Project
31 * This class correctly propagates its active/inactive states down to source {@code LiveData}
51 * liveData1} and remove it as a source.
70 private SafeIterableMap<LiveData<?>, Source<?>> mSources = new SafeIterableMap<>();
73 * Starts to listen the given {@code source} LiveData, {@code onChanged} observer will be called
74 * when {@code source} value was changed.
77 * <p> If the given LiveData is already added as a source but with a different Observer,
80 * @param source the {@code LiveData} to listen to
82 * @param <S> The type of data hold by {@code source} LiveData
85 public <S> void addSource(@NonNull LiveData<S> source, @NonNull Observer<? super S> onChanged) {
86 Source<S> e = new Source<>(source, onChanged);
87 Source<?> existing = mSources.putIfAbsent(source, e);
90 "This source was already added with the different observer");
104 * @param <S> the type of data hold by {@code source} LiveData
108 Source<?> source = mSources.remove(toRemote);
109 if (source != null) {
110 source.unplug();
117 for (Map.Entry<LiveData<?>, Source<?>> source : mSources) {
118 source.getValue().plug();
125 for (Map.Entry<LiveData<?>, Source<?>> source : mSources) {
126 source.getValue().unplug();
130 private static class Source<V> implements Observer<V> {
135 Source(LiveData<V> liveData, final Observer<? super V> observer) {