This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@MainThread | |
public void observe(@NonNull LifecycleOwner owner, @NonNull Observer<? super T> observer) { | |
assertMainThread("observe"); | |
if (owner.getLifecycle().getCurrentState() == DESTROYED) { | |
// ignore | |
return; | |
} | |
LifecycleBoundObserver wrapper = new LifecycleBoundObserver(owner, observer); | |
/* | |
* mObservers是一个map,key是Observer, value是ObserverWrapper,用来存放所有该LiveData对象的观察者。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component("indexRandomer") | |
public class IndexRandomer implements Randomer { | |
@Override | |
public List<Integer> nextIntList(int bound, int length) { | |
List<Integer> list = IntStream.range(0, bound).collect(ArrayList::new, ArrayList::add, ArrayList::addAll); | |
Random rnd = new Random(); | |
List<Integer> result = new ArrayList<>(length); | |
for (int i = 0; i < length; i++, bound--) { | |
int idx = rnd.nextInt(bound); | |
result.add(list.get(idx)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ZZZ... | |
First Gist... |