Esempio n. 1
0
  @Override
  public void contextChanged(ContextEvent event) {
    super.contextChanged(event);
    ContextItem thiscontextItem = event.getItem();
    if (thiscontextItem != null) {
      if (thiscontextItem instanceof Destination) {
        // lets do something here...
        String getContextChangedName = getName();
        String getEventItemName = ((Person) event.getItem()).getName();
        System.out.println("Name::" + getContextChangedName + " " + " Item::" + getEventItemName);
      } else if (thiscontextItem instanceof CurrentLocation) {
        CurrentLocation currentlocation = new CurrentLocation();
        int currentFloor = currentlocation.getCurrentFloor();
        char currentSector = currentlocation.getCurrentSector();
        int currentRoom = currentlocation.getcurrentRoom();
        System.out.println(
            "Floor::" + currentFloor + " Sector::" + currentSector + " Room::" + currentRoom);

      } else {
        // do something if there is not instance of
        // data being receive
      }
      // implement to update
    } else {

      // do some handle in case the item is null
    }
  }
Esempio n. 2
0
 public void contextChanged(ContextEvent event) {
   // Reading the location item id. I dont know if the best way is to pass the information as
   // Location.id,
   System.out.println("change occured");
   System.out.println("Current location: " + event.getItem().getId().toString());
 }