You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* SoftButtonObject define a button that can have multiple SoftButtonState values.<br>
47
+
* SoftButtonObject defines a button that can have multiple SoftButtonState values.<br>
48
48
* The states of SoftButtonObject allow the developer to not have to manage multiple SoftButtons that have very similar functionality.<br>
49
49
* For example, a repeat button in a music app can be thought of as one SoftButtonObject with three typical states: repeat off, repeat 1, and repeat on.<br>
50
50
* @see SoftButtonState
51
51
*/
52
52
publicclassSoftButtonObject {
53
53
54
-
privatestaticfinalStringTAG = "SoftButtonObject";
55
54
staticintSOFT_BUTTON_ID_NOT_SET_VALUE = -1;
56
55
staticintSOFT_BUTTON_ID_MIN_VALUE = 0;
57
56
staticintSOFT_BUTTON_ID_MAX_VALUE = 65535;
@@ -74,13 +73,13 @@ public SoftButtonObject(@NonNull String name, @NonNull List<SoftButtonState> sta
74
73
75
74
// Make sure there aren't two states with the same name
76
75
if (hasTwoStatesOfSameName(states)) {
77
-
Log.e(TAG, "Two states have the same name in states list for soft button object");
76
+
DebugTool.logError("Two states have the same name in states list for soft button object");
78
77
return;
79
78
}
80
79
81
80
this.name = name;
82
81
this.states = states;
83
-
currentStateName = initialStateName;
82
+
this.currentStateName = initialStateName;
84
83
this.buttonId = SOFT_BUTTON_ID_NOT_SET_VALUE;
85
84
this.onEventListener = onEventListener;
86
85
}
@@ -95,6 +94,16 @@ public SoftButtonObject(@NonNull String name, @NonNull SoftButtonState state, On
Log.e(TAG, String.format("Attempted to transition to state: %s on soft button object: %s but no state with that name was found", newStateName, this.name));
115
+
DebugTool.logError(String.format("Attempted to transition to state: %s on soft button object: %s but no state with that name was found", newStateName, this.name));
116
+
returnfalse;
117
+
}
118
+
119
+
if (states.size() == 1) {
120
+
DebugTool.logWarning("There's only one state, so no transitioning is possible!");
107
121
returnfalse;
108
122
}
123
+
109
124
DebugTool.logInfo(String.format("Transitioning soft button object %s to state %s", this.name, newStateName));
110
125
currentStateName = newStateName;
111
126
112
127
// Send a new Show RPC because the state has changed which means the actual SoftButton has changed
113
128
if (updateListener != null) {
114
129
updateListener.onUpdate();
115
130
} else {
116
-
Log.e(TAG, String.format("SoftButtonManager is not set for soft button object: %s. Update cannot be triggered", this.name));
131
+
DebugTool.logError(String.format("SoftButtonManager is not set for soft button object: %s. Update cannot be triggered", this.name));
117
132
}
118
133
119
134
returntrue;
@@ -126,16 +141,13 @@ public void transitionToNextState() {
126
141
StringnextStateName = null;
127
142
for (inti = 0; i < states.size(); i++) {
128
143
if (states.get(i).getName().equals(currentStateName)) {
129
-
if (i == (states.size() - 1)) {
130
-
nextStateName = states.get(0).getName();
131
-
} else {
132
-
nextStateName = states.get(i + 1).getName();
133
-
}
144
+
intnextStateNumber = (i == states.size() - 1) ? 0 : (i + 1);
0 commit comments