コード例 #1
0
  @Override
  public void getAlarmSettings(IDeviceReadable device, ICallback<AlarmSettingModel> callback) {

    this._callback = callback;
    MeteorSingleton.getInstance().setCallback(this);
    _subscriptionId =
        MeteorSingleton.getInstance()
            .subscribe("alarmSettingsForDevice", new Object[] {device.getId()});
  }
コード例 #2
0
  @Override
  public void getDeviceFeatures(
      IDeviceReadable device, final ICallback<List<IDeviceFeatureReadable>> callback) {
    MeteorSingleton.getInstance()
        .call(
            "implementedDeviceFeaturesForDevice",
            new Object[] {device.getId()},
            new ResultListener() {
              @Override
              public void onSuccess(String s) {
                System.out.println("SUCCESS: #1");
                System.out.println(s);
                ArrayList<IDeviceFeatureReadable> devFetList =
                    new ArrayList<IDeviceFeatureReadable>();
                JsonArray devFeatureListJSON = _parser.parse(s).getAsJsonArray();
                for (int i = 0; i < devFeatureListJSON.size(); i++) {
                  JsonObject devFetJSON = devFeatureListJSON.get(i).getAsJsonObject();
                  String id = devFetJSON.getAsJsonPrimitive("_id").getAsString();
                  String type = devFetJSON.getAsJsonPrimitive("feature_type").getAsString();

                  devFetList.add(new DeviceFeatureModel(id, type));
                }

                callback.callback(null, devFetList);
              }

              @Override
              public void onError(String s, String s1, String s2) {
                System.out.println("ERROR: #1");
                System.out.println(s);
                System.out.println(s1);
                System.out.println(s2);
              }
            });
  }
コード例 #3
0
 @Override
 public void setAlarmSettings(
     IDeviceReadable device, AlarmSettingModel settings, ICallback<Boolean> callback) {
   JsonObject jsonAlarmSettings = settingsModelToJson(settings);
   String json = _gson.toJson(jsonAlarmSettings);
   MeteorSingleton.getInstance().call("pushAlarmSettings", new Object[] {device.getId(), json});
 }
コード例 #4
0
  @Override
  public void pushAlarmTrigger(
      IDeviceReadable device, IDataTriggerReadable triggerModel, final ICallback<String> callback) {
    JsonObject jsonTrigger = triggerModelToJson(triggerModel);
    String json = _gson.toJson(jsonTrigger);
    MeteorSingleton.getInstance()
        .call(
            "pushDataTriggers",
            new Object[] {device.getId(), json},
            new ResultListener() {

              @Override
              public void onSuccess(String s) {
                callback.callback(null, "Successfully created the data trigger.");
              }

              @Override
              public void onError(String s, String s1, String s2) {
                callback.callback(null, "Error occurred creating the data trigger.");
              }
            });
  }
コード例 #5
0
 @Override
 public void unRegisterAsCallback() {
   MeteorSingleton.getInstance().unsubscribe(_subscriptionId);
   MeteorSingleton.getInstance().unsetCallback(this);
 }