当前位置: 首页>>代码示例>>Java>>正文


Java Activity类代码示例

本文整理汇总了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);
    }
}
 
开发者ID:bwssytems,项目名称:restful-harmony,代码行数:27,代码来源:HarmonyRestServer.java

示例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;
}
 
开发者ID:bwssytems,项目名称:ha-bridge,代码行数:18,代码来源:HarmonyHome.java

示例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;
}
 
开发者ID:bwssytems,项目名称:ha-bridge,代码行数:16,代码来源:HarmonyHome.java

示例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;
}
 
开发者ID:bwssytems,项目名称:ha-bridge,代码行数:12,代码来源:HarmonyActivity.java

示例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();
  }
 
开发者ID:bwssytems,项目名称:ha-bridge,代码行数:8,代码来源:HarmonyHandler.java

示例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();
}
 
开发者ID:bwssytems,项目名称:ha-bridge,代码行数:8,代码来源:HarmonyHandler.java

示例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);
			}
		}
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:18,代码来源:HarmonyHubBinding.java

示例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()));
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:14,代码来源:HarmonyHubBinding.java

示例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;
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:32,代码来源:HarmonyHubHandler.java

示例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()));
        }
    });
}
 
开发者ID:tuck182,项目名称:openhab-harmony-binding,代码行数:12,代码来源:BindingConfigCurrentActivity.java

示例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);
            }
        }
    }
}
 
开发者ID:openhab,项目名称:openhab1-addons,代码行数:19,代码来源:HarmonyHubBinding.java

示例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()));
    }
}
 
开发者ID:openhab,项目名称:openhab1-addons,代码行数:15,代码来源:HarmonyHubBinding.java

示例13: getCurrentActivity

import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
public Activity getCurrentActivity() {
	return currentActivity;
}
 
开发者ID:bwssytems,项目名称:restful-harmony,代码行数:4,代码来源:DevModeResponse.java

示例14: setCurrentActivity

import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
public void setCurrentActivity(Activity currentActivity) {
	this.currentActivity = currentActivity;
}
 
开发者ID:bwssytems,项目名称:restful-harmony,代码行数:4,代码来源:DevModeResponse.java

示例15: getActivities

import net.whistlingfish.harmony.config.Activity; //导入依赖的package包/类
public List<Activity> getActivities() {
	return harmonyConfig.getActivities();
}
 
开发者ID:bwssytems,项目名称:restful-harmony,代码行数:4,代码来源:DevModeResponse.java


注:本文中的net.whistlingfish.harmony.config.Activity类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。