这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ private void onResourcesEventTask(List<Resource> resources) {
}
getThing().getThings().forEach(thing -> {
if (thing.getHandler() instanceof Clip2ThingHandler clip2ThingHandler) {
resources.forEach(resource -> clip2ThingHandler.onResource(resource));
clip2ThingHandler.onResources(resources);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -631,12 +631,38 @@ public void initialize() {
}
}

/**
* Update the channel state depending on new resources sent from the bridge.
*
* @param resources a collection of Resource objects containing the new state.
*/
public void onResources(Collection<Resource> resources) {
boolean sceneActivated = resources.stream().anyMatch(r -> sceneContributorsCache.containsKey(r.getId())
&& (r.getSceneActive().orElse(false) || r.getSmartSceneActive().orElse(false)));
for (Resource resource : resources) {
// Skip scene deactivation when we have also received a scene activation.
boolean updateChannels = !sceneActivated || !sceneContributorsCache.containsKey(resource.getId())
|| resource.getSceneActive().orElse(false) || resource.getSmartSceneActive().orElse(false);
onResource(resource, updateChannels);
}
}

/**
* Update the channel state depending on a new resource sent from the bridge.
*
* @param resource a Resource object containing the new state.
*/
private void onResource(Resource resource) {
onResource(resource, true);
}

/**
* Update the channel state depending on a new resource sent from the bridge.
*
* @param resource a Resource object containing the new state.
* @param updateChannels update channels (otherwise only update cache/properties).
*/
public void onResource(Resource resource) {
private void onResource(Resource resource, boolean updateChannels) {
if (disposing) {
return;
}
Expand All @@ -658,7 +684,7 @@ public void onResource(Resource resource) {
Resource cachedResource = getResourceFromCache(resource);
if (cachedResource != null) {
Setters.setResource(resource, cachedResource);
resourceConsumed = updateChannels(resource);
resourceConsumed = updateChannels && updateChannels(resource);
putResourceToCache(resource);
if (ResourceType.LIGHT == resource.getType() && !updateLightPropertiesDone) {
updateLightProperties(resource);
Expand Down