Skip to content

Commit

Permalink
Removed unnecessary getRemoteNodes().
Browse files Browse the repository at this point in the history
  • Loading branch information
patloew committed Mar 11, 2016
1 parent 520b04b commit b27ecff
Showing 1 changed file with 2 additions and 30 deletions.
32 changes: 2 additions & 30 deletions library/src/main/java/com/patloew/rxwear/RxWear.java
Original file line number Diff line number Diff line change
Expand Up @@ -483,9 +483,7 @@ private static Observable<DataApi.GetFdForAssetResult> getFdForAssetInternal(Dat
* based on a DataMap.
*
* Example:
* RxWear.Data.PutSerializable.to("/path", serializable)
* .setUrgent()
* .toObservable()
* RxWear.Data.PutSerializable.urgentTo("/path", serializable)
* .subscribe(dataItem -> {
* // do something
* });
Expand Down Expand Up @@ -716,7 +714,7 @@ public static Observable<Integer> sendToAllRemoteNodes(@NonNull final String pat
}

private static Observable<Integer> sendToAllRemoteNodesInternal(final String path, final byte[] data, final Long timeout, final TimeUnit timeUnit) {
return Node.getRemoteNodesInternal(timeout, timeUnit).flatMap(new Func1<List<com.google.android.gms.wearable.Node>, Observable<com.google.android.gms.wearable.Node>>() {
return Node.getConnectedNodesInternal(timeout, timeUnit).flatMap(new Func1<List<com.google.android.gms.wearable.Node>, Observable<com.google.android.gms.wearable.Node>>() {
@Override
public Observable<com.google.android.gms.wearable.Node> call(List<com.google.android.gms.wearable.Node> nodes) {
return Observable.from(nodes);
Expand Down Expand Up @@ -932,31 +930,5 @@ private static Observable<com.google.android.gms.wearable.Node> getLocalNodeInte
return Observable.create(new NodeGetLocalObservable(RxWear.get(), timeout, timeUnit));
}

// getRemoteNodes

public static Observable<List<com.google.android.gms.wearable.Node>> getRemoteNodes() {
return getRemoteNodesInternal(null, null);
}

public static Observable<List<com.google.android.gms.wearable.Node>> getRemoteNodes(long timeout, @NonNull TimeUnit timeUnit) {
return getRemoteNodesInternal(timeout, timeUnit);
}

private static Observable<List<com.google.android.gms.wearable.Node>> getRemoteNodesInternal(Long timeout, TimeUnit timeUnit) {
return getConnectedNodesInternal(timeout, timeUnit).zipWith(getLocalNodeInternal(timeout, timeUnit), new Func2<List<com.google.android.gms.wearable.Node>, com.google.android.gms.wearable.Node, List<com.google.android.gms.wearable.Node>>() {
@Override
public List<com.google.android.gms.wearable.Node> call(List<com.google.android.gms.wearable.Node> connectedNodes, com.google.android.gms.wearable.Node localNode) {
Iterator<com.google.android.gms.wearable.Node> iterator = connectedNodes.iterator();

while(iterator.hasNext()) {
com.google.android.gms.wearable.Node node = iterator.next();
if(node.getId().equals(localNode.getId())) { iterator.remove(); }
}

return connectedNodes;
}
});
}

}
}

0 comments on commit b27ecff

Please sign in to comment.