kaushikgopal / RxJava-Android-Samples

Learning RxJava for Android by example
Apache License 2.0
7.55k stars 1.37k forks source link

CacheMerge example updates entire adapter for each onNext #72

Closed JimVercoelen closed 8 years ago

JimVercoelen commented 8 years ago

Hi,

Was checking out this repo (which is awesome btw) and noticed that the CacheMerge example does some unnecessary updating (I think).

For each onNext() the entire adapter will be cleared and updated, while there is only added one 'contributor' at a time.

This looks a bit inefficiently to me.

@Override public void onNext(Pair<Contributor, Long> contributorAgePair) { ... _adapter.clear(); _adapter.addAll(getListStringFromMap()); }

Only adding the 'Next' 'contributor' could be better or not? @Override public void onNext(Pair<Contributor, Long> contributorAgePair) { ... String rowLog = String.format("%s [%d]", contributor.login, contributor.contributions); _adapter.add(rowLog); }

JimVercoelen commented 8 years ago

I added an pull request in case It's better

kaushikgopal commented 8 years ago

thanks @JimVercoelen I've added some comments on #73. Let's carry the conversation there. Closing this issue out.