Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixes from PR feedback
  • Loading branch information
noah-livio committed Jan 26, 2022
commit 666f99a9c688b90f022cacc894255f31712795d3
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

import androidx.annotation.NonNull;

import com.livio.BuildConfig;
import com.smartdevicelink.managers.file.filetypes.SdlArtwork;
import com.smartdevicelink.proxy.rpc.OnButtonEvent;
import com.smartdevicelink.proxy.rpc.OnButtonPress;
Expand Down Expand Up @@ -283,8 +282,16 @@ public void setStates(@NonNull List<SoftButtonState> states) {
DebugTool.logError(TAG, "A SoftButtonObject must have states with different names.");
return;
}
if (states.isEmpty()) {
DebugTool.logError(TAG, "A SoftButtonState list must contain at least one state");

boolean hasStateWithCurrentName = false;
for (SoftButtonState state : states) {
if(state.getName().equals(currentStateName)) {
hasStateWithCurrentNameName = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
hasStateWithCurrentNameName = true;
hasStateWithCurrentName = true;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, and that'll be easy to fix

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also to avoid confusion for the developer we will still want to set the states in the case the currentState is not present in the list, but we will still want to log the error.

We should test and confirm that the SoftButtonManager can handle this error case (trying to upload a SoftButton where the currentState is not in the list)

break;
}
}
if (!hasStateWithCurrentName) {
DebugTool.logError(TAG, "A SoftButtonObject must have a state with currentStateName.");
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

import androidx.annotation.NonNull;

import com.livio.BuildConfig;
import com.smartdevicelink.managers.file.filetypes.SdlArtwork;
import com.smartdevicelink.proxy.rpc.SoftButton;
import com.smartdevicelink.proxy.rpc.enums.SoftButtonType;
Expand Down