2121import butterknife .Bind ;
2222import butterknife .ButterKnife ;
2323import butterknife .OnClick ;
24+ import java .util .concurrent .TimeUnit ;
2425import rx .Observable ;
2526import rx .Subscriber ;
2627import rx .android .schedulers .AndroidSchedulers ;
@@ -59,7 +60,10 @@ public void onDemoPseudoCacheClicked() {
5960 _resultList .setAdapter (_adapter );
6061 _initializeCache ();
6162
62- Observable .merge (_getCachedData (), _getFreshData ())
63+
64+ _getFreshData ()//
65+ .publish (fd -> Observable .merge (fd , _getCachedData ().takeUntil (fd )))
66+ //Observable.merge(_getCachedData(), _getFreshData())
6367 .subscribeOn (Schedulers .io ())
6468 .observeOn (AndroidSchedulers .mainThread ())
6569 .subscribe (new Subscriber <Pair <Contributor , Long >>() {
@@ -77,13 +81,13 @@ public void onError(Throwable e) {
7781 public void onNext (Pair <Contributor , Long > contributorAgePair ) {
7882 Contributor contributor = contributorAgePair .first ;
7983
80- if (_resultAgeMap .containsKey (contributor ) &&
81- _resultAgeMap .get (contributor ) > contributorAgePair .second ) {
82- return ;
83- }
84+ // if (_resultAgeMap.containsKey(contributor) &&
85+ // _resultAgeMap.get(contributor) > contributorAgePair.second) {
86+ // return;
87+ // }
8488
8589 _contributionMap .put (contributor .login , contributor .contributions );
86- _resultAgeMap .put (contributor , contributorAgePair .second );
90+ // _resultAgeMap.put(contributor, contributorAgePair.second);
8791
8892 _adapter .clear ();
8993 _adapter .addAll (getListStringFromMap ());
@@ -117,7 +121,7 @@ private Observable<Pair<Contributor, Long>> _getCachedData() {
117121 list .add (dataWithAgePair );
118122 }
119123
120- return Observable .from (list );
124+ return Observable .from (list ). delay ( 5 , TimeUnit . SECONDS ) ;
121125 }
122126
123127 private Observable <Pair <Contributor , Long >> _getFreshData () {
0 commit comments