Skip to content

Commit e35a699

Browse files
committed
changed node finding logic
1 parent e2f476f commit e35a699

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Diff for: wear-socket/src/main/java/com/github/jrejaud/wear_socket/WearSocket.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ private WearSocket() {
6363
//Setup and State Handling
6464
//********************************************************************
6565

66-
public void setupAndConnect(Context context, final String capability) {
66+
public void setupAndConnect(final Context context, final String capability) {
6767
this.context = context;
6868
this.capability = capability;
6969
Log.d(TAG, "Starting up Google Api Client");
@@ -83,7 +83,9 @@ public void onConnectionSuspended(int i) {
8383
.addOnConnectionFailedListener(new GoogleApiClient.OnConnectionFailedListener() {
8484
@Override
8585
public void onConnectionFailed(ConnectionResult result) {
86-
showErrorAndCloseApp("Error, cannot connect", true);
86+
String message = "Cannot start google api client";
87+
Toast.makeText(context,message,Toast.LENGTH_SHORT).show();
88+
throw new RuntimeException("Cannot start google api client");
8789
}
8890
})
8991
.addApi(Wearable.API)
@@ -120,12 +122,15 @@ public void run() {
120122

121123
private String findBestNodeId(Set<Node> nodes) {
122124
String bestNodeId = null;
125+
Log.d(TAG,"Found Set of nodes: "+nodes.size());
123126
for (Node node : nodes) {
124127
if (node.isNearby()) {
125-
bestNodeId = node.getId();
128+
Log.d(TAG,"Found nearby node: "+node.getId());
129+
return node.getId();
126130
}
127131
bestNodeId = node.getId();
128132
}
133+
Log.d(TAG,"No nearby node found, settling for: "+bestNodeId);
129134
return bestNodeId;
130135
}
131136

0 commit comments

Comments
 (0)