Skip to content

Commit

Permalink
Address review feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Hilbush <mark@hilbush.com>
  • Loading branch information
mhilbush committed May 18, 2020
1 parent 157025d commit 1365cf0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@
package org.openhab.binding.squeezebox.internal.dto;

import java.lang.reflect.Type;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;

import org.apache.commons.lang.StringUtils;

import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
Expand All @@ -40,18 +37,17 @@ public ButtonDTO deserialize(JsonElement jsonElement, Type tyoeOfT, JsonDeserial
if (jsonElement.isJsonPrimitive() && jsonElement.getAsJsonPrimitive().isNumber()) {
Integer value = jsonElement.getAsInt();
button = new ButtonDTO();
button.custom = Boolean.FALSE;
button.enabled = value == 0 ? Boolean.FALSE : Boolean.TRUE;
button.custom = false;
button.enabled = value != 0;
} else if (jsonElement.isJsonObject()) {
JsonObject jsonObject = jsonElement.getAsJsonObject();
button = new ButtonDTO();
button.custom = Boolean.TRUE;
button.custom = true;
button.icon = jsonObject.get("icon").getAsString();
button.jiveStyle = jsonObject.get("jiveStyle").getAsString();
button.toolTip = jsonObject.get("tooltip").getAsString();
List<String> commandList = StreamSupport.stream(jsonObject.getAsJsonArray("command").spliterator(), false)
.map(JsonElement::getAsString).collect(Collectors.toList());
button.command = StringUtils.join(commandList, " ");
button.command = StreamSupport.stream(jsonObject.getAsJsonArray("command").spliterator(), false)
.map(JsonElement::getAsString).collect(Collectors.joining(" "));
}
return button;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,12 @@ public void handleCommand(ChannelUID channelUID, Command command) {
squeezeBoxServerHandler.playFavorite(mac, command.toString());
break;
case CHANNEL_LIKE:
if (likeCommand != null) {
if (likeCommand != null && command.equals(OnOffType.ON)) {
squeezeBoxServerHandler.like(mac, likeCommand);
}
break;
case CHANNEL_UNLIKE:
if (unlikeCommand != null) {
if (unlikeCommand != null && command.equals(OnOffType.ON)) {
squeezeBoxServerHandler.unlike(mac, unlikeCommand);
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -866,9 +866,7 @@ private void handlePlaylistMessage(final String mac, String[] messageParts) {
if (action.equals("newsong")) {
mode = "play";
// Execute in separate thread to avoid delaying listener
scheduler.execute(() -> {
updateCustomButtons(mac);
});
scheduler.execute(() -> updateCustomButtons(mac));
// Set the track duration to 0
updatePlayer(new PlayerUpdateEvent() {
@Override
Expand Down

0 comments on commit 1365cf0

Please sign in to comment.