Skip to content

Commit

Permalink
Use stream findFirst API
Browse files Browse the repository at this point in the history
  • Loading branch information
seabornlee committed Oct 28, 2022
1 parent 64768f0 commit be68fdb
Showing 1 changed file with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.IntStream;

import io.reactivex.Single;
import io.reactivex.android.schedulers.AndroidSchedulers;
Expand Down Expand Up @@ -117,15 +118,9 @@ private NodeStatus fetchNodeStatus(long chainId)
private void updateStatus(long chainId, NodeStatus status)
{
statusMap.put(chainId, status);
int position = 0;
for (int i=0; i<networkList.size(); i++)
{
if (networkList.get(i).chainId == chainId)
{
position = i;
break;
}
}
int position = IntStream.range(0, networkList.size())
.filter(i -> networkList.get(i).chainId == chainId)
.findFirst().orElse(0);
notifyItemChanged(position);
Timber.d("updateStatus: chain: %s-%s: %s", chainId, EthereumNetworkBase.getShortChainName(chainId),status);
}
Expand Down

0 comments on commit be68fdb

Please sign in to comment.