persist the 3 values across activity creation
This commit is contained in:
parent
fd5b1826de
commit
14fc595760
|
@ -10,6 +10,10 @@ import android.widget.TextView;
|
||||||
import goRicochetMobile.GoRicochetMobile;
|
import goRicochetMobile.GoRicochetMobile;
|
||||||
|
|
||||||
public class RemoteActivity extends AppCompatActivity {
|
public class RemoteActivity extends AppCompatActivity {
|
||||||
|
private static final String DEVICE_NAME_KEY = "deviceName";
|
||||||
|
private static final String BATTERY_LEVEL_KEY = "batteryLevel";
|
||||||
|
private static final String VIBE_LEVEL_KEY = "vibeLEvel";
|
||||||
|
|
||||||
TextView deviceText;
|
TextView deviceText;
|
||||||
TextView batteryText;
|
TextView batteryText;
|
||||||
TextView statusText;
|
TextView statusText;
|
||||||
|
@ -62,6 +66,13 @@ public class RemoteActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
if (savedInstanceState != null) {
|
||||||
|
deviceText.setText(savedInstanceState.getString(DEVICE_NAME_KEY));
|
||||||
|
batteryText.setText(savedInstanceState.getString(BATTERY_LEVEL_KEY));
|
||||||
|
vibeLevel = savedInstanceState.getInt(VIBE_LEVEL_KEY);
|
||||||
|
setVibeLevel(vibeLevel);
|
||||||
|
} else {
|
||||||
GetDeviceNameTask getDeviceNameTask = new GetDeviceNameTask();
|
GetDeviceNameTask getDeviceNameTask = new GetDeviceNameTask();
|
||||||
getDeviceNameTask.execute();
|
getDeviceNameTask.execute();
|
||||||
|
|
||||||
|
@ -71,6 +82,14 @@ public class RemoteActivity extends AppCompatActivity {
|
||||||
GetLevelTask getLevelTask = new GetLevelTask();
|
GetLevelTask getLevelTask = new GetLevelTask();
|
||||||
getLevelTask.execute();
|
getLevelTask.execute();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSaveInstanceState(final Bundle outState) {
|
||||||
|
outState.putString(DEVICE_NAME_KEY, deviceText.getText().toString());
|
||||||
|
outState.putString(BATTERY_LEVEL_KEY, batteryText.getText().toString());
|
||||||
|
outState.putInt(VIBE_LEVEL_KEY, vibeLevel);
|
||||||
|
}
|
||||||
|
|
||||||
// current impelementation of OD server can return 0 to 6 (potentially downsampled from 12?)
|
// current impelementation of OD server can return 0 to 6 (potentially downsampled from 12?)
|
||||||
// The go API respects that, further downsample to [off low med high] here
|
// The go API respects that, further downsample to [off low med high] here
|
||||||
|
|
Loading…
Reference in New Issue