Exemplo n.º 1
0
 public void setVolumeDown(Config params) {
   boolean executed =
       executeCommand(
           "set volume down",
           params); // executes the developer level command associated with 'set channel' action
   if (executed) {
     if (volume.getValue() != volume.getMin()) {
       volume.setValue(volume.getValue() - 1);
       // TODO: set the TV graphical representation
       // setView(1); //points to the second element in the XML views array (light on image)
       setChanged(true);
     }
   }
 }
Exemplo n.º 2
0
 public void setChannelDown(Config params) {
   boolean executed =
       executeCommand(
           "set channel down",
           params); // executes the developer level command associated with 'set channel' action
   if (executed) {
     if (channel.getValue() != channel.getMin()) {
       channel.setValue(channel.getValue() - 1);
       powered.setValue(
           true); // select a channel turn on the tv automatically. This is for coherence.
       // TODO: set the TV graphical representation
       // setView(1); //points to the second element in the XML views array (light on image)
       setChanged(true);
     }
   }
 }
Exemplo n.º 3
0
  @Override
  public void init() {

    // linking this property with the behavior defined in the XML
    volume = new RangedIntBehaviorLogic((RangedIntBehavior) getPojo().getBehavior("volume"));
    volume.addListener(
        new RangedIntBehaviorLogic.Listener() {
          @Override
          public void onLowerBoundValue(Config params, boolean fireCommand) {
            // turnPowerOff(params);
            onRangeValue(volume.getMin(), params, fireCommand);
          }

          @Override
          public void onUpperBoundValue(Config params, boolean fireCommand) {
            // turnPowerOn(params);
            onRangeValue(volume.getMax(), params, fireCommand);
          }

          @Override
          public void onRangeValue(int rangeValue, Config params, boolean fireCommand) {
            if (fireCommand) {
              executeSetVolume(rangeValue, params);
            } else {
              setVolume(rangeValue);
            }
          }
        });
    registerBehavior(volume);

    // linking this property with the behavior defined in the XML
    channel = new RangedIntBehaviorLogic((RangedIntBehavior) getPojo().getBehavior("channel"));

    channel.addListener(
        new RangedIntBehaviorLogic.Listener() {
          @Override
          public void onLowerBoundValue(Config params, boolean fireCommand) {
            onRangeValue(channel.getMin(), params, fireCommand);
          }

          @Override
          public void onUpperBoundValue(Config params, boolean fireCommand) {
            onRangeValue(channel.getMax(), params, fireCommand);
          }

          @Override
          public void onRangeValue(int rangeValue, Config params, boolean fireCommand) {
            if (fireCommand) {
              executeSetChannel(rangeValue, params);
            } else {
              setChannel(rangeValue);
            }
          }
        });
    registerBehavior(channel);

    // linking this property with the behavior defined in the XML
    input = new ListBehaviorLogic((ListBehavior) getPojo().getBehavior("input"));
    input.addListener(
        new ListBehaviorLogic.Listener() {
          @Override
          public void selectedChanged(Config params, boolean fireCommand) {
            if (fireCommand) {
              executeSetInput(params);
            } else {
              setInput(params.getProperty("value"));
            }
          }
        });
    registerBehavior(input);

    // linking this powered property with the muted behavior defined in the XML
    muted = new BooleanBehaviorLogic((BooleanBehavior) getPojo().getBehavior("muted"));
    muted.addListener(
        new BooleanBehaviorLogic.Listener() {
          @Override
          public void onTrue(Config params, boolean fireCommand) {
            if (fireCommand) {
              executeSetMuteOn(params);
            } else {
              setMuteOn();
            }
          }

          @Override
          public void onFalse(Config params, boolean fireCommand) {
            if (fireCommand) {
              executeSetMuteOff(params);
            } else {
              setMuteOff();
            }
          }
        });
    registerBehavior(muted);

    // linking this powered property with the avSelection behavior defined in the XML
    avSelection = new ListBehaviorLogic((ListBehavior) getPojo().getBehavior("avselection"));
    avSelection.addListener(
        new ListBehaviorLogic.Listener() {
          @Override
          public void selectedChanged(Config params, boolean fireCommand) {
            if (fireCommand) {
              executeSetAVSelection(params);
            } else {
              setAVSelection(params.getProperty("value"));
            }
          }
        });
    registerBehavior(avSelection);

    // linking this powered property with the screenMode behavior defined in the XML
    screenMode = new ListBehaviorLogic((ListBehavior) getPojo().getBehavior("screenMode"));
    screenMode.addListener(
        new ListBehaviorLogic.Listener() {
          // TODO: in the kuro the screen modes available depends of the source.
          @Override
          public void selectedChanged(Config params, boolean fireCommand) {
            if (fireCommand) {
              executeSetScreenMode(params);
            } else {
              setScreenMode(params.getProperty("value"));
            }
          }
        });
    registerBehavior(screenMode);
    super.init();
  }
Exemplo n.º 4
0
 public void setChannel(int rangeValue) {
   if (channel.getValue() != rangeValue) {
     channel.setValue(rangeValue);
     setChanged(true);
   }
 }
Exemplo n.º 5
0
 public void setVolume(int rangeValue) {
   if (volume.getValue() != rangeValue) {
     volume.setValue(rangeValue);
     setChanged(true);
   }
 }