本文整理汇总了Java中net.whistlingfish.harmony.config.Activity类的典型用法代码示例。如果您正苦于以下问题:Java Activity类的具体用法?Java Activity怎么用?Java Activity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Activity类属于net.whistlingfish.harmony.config包,在下文中一共展示了Activity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
public int execute(String[] args) throws Exception {
if(devMode)
{
harmonyClient = null;
devResponse = new DevModeResponse();
}
else {
devResponse = null;
harmonyClient.addListener(new ActivityChangeListener() {
@Override
public void activityStarted(Activity activity) {
log.info(format("activity changed: [%d] %s", activity.getId(), activity.getLabel()));
}
});
harmonyClient.connect(args[0]);
}
port(Integer.valueOf(System.getProperty("server.port", "8081")));
int sleepTime = Integer.parseInt(System.getProperty("button.sleep", "100"));
harmonyApi = new HarmonyRest(harmonyClient, noopCalls, sleepTime, devResponse);
harmonyApi.setupServer();
while(true)
{
//no op
Thread.sleep(100000);
}
}
示例2: getActivities
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
public List<HarmonyActivity> getActivities() {
Iterator<String> keys = hubs.keySet().iterator();
ArrayList<HarmonyActivity> activityList = new ArrayList<HarmonyActivity>();
if(!validHarmony)
return null;
while(keys.hasNext()) {
String key = keys.next();
Iterator<Activity> activities = hubs.get(key).getMyHarmony().getActivities().iterator();
while(activities.hasNext()) {
HarmonyActivity anActivity = new HarmonyActivity();
anActivity.setActivity(activities.next());
anActivity.setHub(key);
activityList.add(anActivity);
}
}
return activityList;
}
示例3: getCurrentActivities
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
public List<HarmonyActivity> getCurrentActivities() {
Iterator<String> keys = hubs.keySet().iterator();
ArrayList<HarmonyActivity> activityList = new ArrayList<HarmonyActivity>();
if(!validHarmony)
return null;
while(keys.hasNext()) {
String key = keys.next();
Activity theActivity = hubs.get(key).getMyHarmony().getCurrentActivity();
HarmonyActivity anActivity = new HarmonyActivity();
anActivity.setActivity(theActivity);
anActivity.setHub(key);
activityList.add(anActivity);
}
return activityList;
}
示例4: setActivity
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
public void setActivity(Activity activity) {
byte ptext[];
String theLabel = activity.getLabel();
try {
ptext = theLabel.getBytes("ISO-8859-1");
activity.setLabel(new String(ptext, "UTF-8"));
} catch (UnsupportedEncodingException e) {
activity.setLabel(theLabel);
}
this.activity = activity;
}
示例5: getActivities
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
public List<Activity> getActivities() {
log.debug("Harmony api activities list requested.");
if(devMode)
return devResponse.getActivities();
return harmonyClient.getConfig().getActivities();
}
示例6: getCurrentActivity
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
public Activity getCurrentActivity() {
log.debug("Harmony api current sctivity requested.");
if(devMode)
return devResponse.getCurrentActivity();
return harmonyClient.getCurrentActivity();
}
示例7: updateActivity
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
/**
* For a given {@link Activity}, update all items who need to know about it
* @param activity
*/
private void updateActivity(Activity activity, String qualifier) {
logger.debug("updateActivity {}" + activity.getLabel());
for (HarmonyHubBindingProvider provider : providers) {
for(String itemName : provider.getItemNames()) {
HarmonyHubBindingConfig config = provider.getHarmonyHubBindingConfig(itemName);
if(config.matchesQualifier(qualifier) &&
config.getBindingType() == HarmonyHubBindingType.CurrentActivity) {
updateActivityForItem(itemName, config.getItemType(), activity);
}
}
}
}
示例8: updateActivityForItem
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
/**
* For a given {@link Activity}, update an {@link Item} with its {@link State} state
* @param item
* @param state
* @param activity
*/
private void updateActivityForItem(String itemName, Class<? extends Item> itemType, Activity activity) {
if(itemType.isAssignableFrom(NumberItem.class)) {
eventPublisher.postUpdate(itemName, new DecimalType(activity.getId()));
} else {
eventPublisher.postUpdate(itemName, new StringType(activity.getLabel()));
}
}
示例9: updateActivityStatus
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
private void updateActivityStatus(Activity activity, Activity.Status status) {
logger.debug("Received {} activity status for {}", status, activity.getLabel());
switch (status) {
case ACTIVITY_IS_STARTING:
triggerChannel(HarmonyHubBindingConstants.CHANNEL_ACTIVITY_STARTING_TRIGGER, getEventName(activity));
break;
case ACTIVITY_IS_STARTED:
case HUB_IS_OFF:
// hub is off is received with power-off activity
triggerChannel(HarmonyHubBindingConstants.CHANNEL_ACTIVITY_STARTED_TRIGGER, getEventName(activity));
break;
case HUB_IS_TURNING_OFF:
// hub is turning off is received for current activity, we will translate it into activity starting
// trigger of power-off activity (with ID=-1)
getConfigFuture().thenAccept(config -> {
if (config != null) {
Activity powerOff = config.getActivityById(-1);
if (powerOff != null) {
triggerChannel(HarmonyHubBindingConstants.CHANNEL_ACTIVITY_STARTING_TRIGGER,
getEventName(powerOff));
}
}
}).exceptionally(e -> {
setOfflineAndReconnect("Getting config failed: " + e.getMessage());
return null;
});
break;
default:
break;
}
}
示例10: bind
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
@Override
public void bind(final HarmonyHubBinding binding) {
final String itemName = item.getName();
binding.registerListener(qualifier, itemName, new ActivityChangeListener() {
@Override
public void activityStarted(Activity activity) {
binding.postUpdate(itemName, new StringType(activity.getLabel()));
}
});
}
示例11: updateActivity
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
/**
* For a given {@link Activity}, update all items who need to know about it
*
* @param activity
*/
private void updateActivity(Activity activity, String qualifier) {
logger.debug("updateActivity {}" + activity.getLabel());
for (HarmonyHubBindingProvider provider : providers) {
for (String itemName : provider.getItemNames()) {
HarmonyHubBindingConfig config = provider.getHarmonyHubBindingConfig(itemName);
if (config.matchesQualifier(qualifier)
&& config.getBindingType() == HarmonyHubBindingType.CurrentActivity) {
updateActivityForItem(itemName, config.getItemType(), activity);
}
}
}
}
示例12: updateActivityForItem
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
/**
* For a given {@link Activity}, update an {@link Item} with its {@link State} state
*
* @param item
* @param state
* @param activity
*/
private void updateActivityForItem(String itemName, Class<? extends Item> itemType, Activity activity) {
if (itemType.isAssignableFrom(NumberItem.class)) {
eventPublisher.postUpdate(itemName, new DecimalType(activity.getId()));
} else {
eventPublisher.postUpdate(itemName, new StringType(activity.getLabel()));
}
}
示例13: getCurrentActivity
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
public Activity getCurrentActivity() {
return currentActivity;
}
示例14: setCurrentActivity
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
public void setCurrentActivity(Activity currentActivity) {
this.currentActivity = currentActivity;
}
示例15: getActivities
import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
public List<Activity> getActivities() {
return harmonyConfig.getActivities();
}