kaushikgopal / RxJava-Android-Samples

Learning RxJava for Android by example

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CacheMerge example updates entire adapter for each onNext

JimVercoelen opened this issue · comments

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);
}

I added an pull request in case It's better

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