Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.

Commit 849b20c

Browse files
committed
Fixed the logic for performing an IP Scan and minor cosmetic
improvements.
1 parent 3dd274b commit 849b20c

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

QuickStartApp/res/layout/bridgelistlinear.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
android:singleLine="true"
3636
android:text="@string/txt_select_smartbridge"
3737
android:textAppearance="?android:attr/textAppearanceSmall"
38-
android:textColor="#FFFFFFFF" />
38+
android:textColor="#000" />
3939

4040

4141

QuickStartApp/src/com/philips/lighting/quickstart/PHHomeActivity.java

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ public class PHHomeActivity extends Activity implements OnItemClickListener {
4545
private HueSharedPreferences prefs;
4646
private AccessPointListAdapter adapter;
4747

48+
private boolean lastSearchWasIPScan = false;
49+
4850
@Override
4951
protected void onCreate(Bundle savedInstanceState) {
5052
super.onCreate(savedInstanceState);
@@ -114,15 +116,7 @@ public void run() {
114116
}
115117
});
116118

117-
} else {
118-
// FallBack Mechanism. If a UPNP Search returns no results then perform an IP Scan. Of course it could fail as the user has disconnected their bridge, connected to a wrong network or disabled Network Discovery on their router so it is not guaranteed to work.
119-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
120-
PHWizardAlertDialog.getInstance().showProgressDialog(R.string.search_progress, PHHomeActivity.this);
121-
PHBridgeSearchManager sm = (PHBridgeSearchManager) phHueSDK.getSDKService(PHHueSDK.SEARCH_BRIDGE);
122-
// Start the IP Scan Search if the UPNP and NPNP return 0 results.
123-
sm.search(false, false, true);
124-
}
125-
}
119+
}
126120

127121
}
128122

@@ -197,14 +191,24 @@ public void run() {
197191

198192
}
199193
else if (code == PHMessageType.BRIDGE_NOT_FOUND) {
200-
PHWizardAlertDialog.getInstance().closeProgressDialog();
201194

202-
PHHomeActivity.this.runOnUiThread(new Runnable() {
203-
@Override
204-
public void run() {
205-
PHWizardAlertDialog.showErrorDialog(PHHomeActivity.this, message, R.string.btn_ok);
206-
}
207-
});
195+
if (!lastSearchWasIPScan) { // Perform an IP Scan (backup mechanism) if UPNP and Portal Search fails.
196+
phHueSDK = PHHueSDK.getInstance();
197+
PHBridgeSearchManager sm = (PHBridgeSearchManager) phHueSDK.getSDKService(PHHueSDK.SEARCH_BRIDGE);
198+
sm.search(false, false, true);
199+
lastSearchWasIPScan=true;
200+
}
201+
else {
202+
PHWizardAlertDialog.getInstance().closeProgressDialog();
203+
PHHomeActivity.this.runOnUiThread(new Runnable() {
204+
@Override
205+
public void run() {
206+
PHWizardAlertDialog.showErrorDialog(PHHomeActivity.this, message, R.string.btn_ok);
207+
}
208+
});
209+
}
210+
211+
208212
}
209213
}
210214
};

0 commit comments

Comments
 (0)