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

Commit 3dd274b

Browse files
committed
Fixed READ CACHE bug. READ CACHE button now reads latest
BridgeResourceCache (rather than the cache from when Activity was created).
1 parent eef2e27 commit 3dd274b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ExampleApp/src/com/philips/lighting/hue/local/sdk/demo/light/PHUpdateLightStateActivity.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ protected void onCreate(Bundle savedInstanceState) {
9393

9494
phHueSDK = PHHueSDK.getInstance();
9595
bridge = phHueSDK.getSelectedBridge();
96-
lights = bridge.getResourceCache().getAllLights();
9796
getLightNames();
9897

9998
TextView tvLight = (TextView) findViewById(R.id.tvLight);
@@ -255,6 +254,7 @@ private void displayLastKnowLightState(PHLightState lastKnownLightState) {
255254
* Reads light names and stores in common container
256255
*/
257256
private void getLightNames() {
257+
lights = bridge.getResourceCache().getAllLights();
258258
int size = lights.size();
259259
lightArray = new String[size];
260260
for (int i = 0; i < size; i++) {
@@ -428,6 +428,7 @@ public void onClick(View v) {
428428
break;
429429
}
430430
int pos = lightSpinner.getSelectedItemPosition();
431+
lights = bridge.getResourceCache().getAllLights();
431432
PHLight light = lights.get(pos);
432433
if (tbGamutCorrection.isChecked()) {
433434
xy = PHUtilities.calculateXY(colorCode, light.getModelNumber());
@@ -568,6 +569,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
568569

569570
case R.id.read_cache:
570571
int pos = lightSpinner.getSelectedItemPosition();
572+
lights = bridge.getResourceCache().getAllLights();
571573
PHLight light = lights.get(pos);
572574
PHLightState lastKnownLightState = light.getLastKnownLightState();
573575
displayLastKnowLightState(lastKnownLightState);
@@ -597,6 +599,7 @@ private void setLightState() {
597599
*/
598600
private void updateLightState() {
599601
int pos = lightSpinner.getSelectedItemPosition();
602+
lights = bridge.getResourceCache().getAllLights();
600603
PHLight light = lights.get(pos);
601604
PHLightState state = getCurrentLightState();
602605
final PHWizardAlertDialog dialogManager = PHWizardAlertDialog

0 commit comments

Comments
 (0)