AI2 Component  (Version nb184)
Hygrometer.java
Go to the documentation of this file.
1 // -*- mode: java; c-basic-offset: 2; -*-
2 // Copyright 2019 MIT, All rights reserved
3 // Released under the Apache License, Version 2.0
4 // http://www.apache.org/licenses/LICENSE-2.0
5 
6 
7 package com.google.appinventor.components.runtime;
8 
16 
17 import android.hardware.Sensor;
18 
23 @DesignerComponent(version = YaVersion.HYGROMETER_COMPONENT_VERSION,
24  description = "A sensor component that can measure the relative ambient air humidity. " +
25  "Most Android devices do not have this sensor.",
26  category = ComponentCategory.SENSORS,
27  nonVisible = true,
28  iconName = "images/hygrometer.png")
29 @SimpleObject
30 public class Hygrometer extends SingleValueSensor {
36  public Hygrometer(ComponentContainer container) {
37  super(container.$form(), Sensor.TYPE_RELATIVE_HUMIDITY);
38  }
39 
40  @Override
41  protected void onValueChanged(float value) {
43  }
44 
50  @SimpleEvent(
51  description = "Called when a change is detected in the ambient air humidity (expressed as a percentage).")
52  public void HumidityChanged(float humidity) {
53  EventDispatcher.dispatchEvent(this, "HumidityChanged", humidity);
54  }
55 
63  @SimpleProperty(description = "The relative ambient humidity as a percentage, if the sensor is available " +
64  "and enabled.")
65  public float Humidity() {
66  return getValue();
67  }
68 }
com.google.appinventor.components.runtime.EventDispatcher
Definition: EventDispatcher.java:22
com.google.appinventor.components.common.YaVersion
Definition: YaVersion.java:14
com.google.appinventor.components.annotations.DesignerProperty
Definition: DesignerProperty.java:25
com.google.appinventor.components
com.google.appinventor.components.annotations.DesignerComponent
Definition: DesignerComponent.java:22
com.google.appinventor.components.annotations.SimpleEvent
Definition: SimpleEvent.java:20
com.google.appinventor.components.runtime.SingleValueSensor.getValue
float getValue()
Definition: SingleValueSensor.java:191
com.google.appinventor.components.runtime.SingleValueSensor
Definition: SingleValueSensor.java:27
com.google.appinventor.components.runtime.Hygrometer.HumidityChanged
void HumidityChanged(float humidity)
Definition: Hygrometer.java:52
com.google.appinventor.components.runtime.EventDispatcher.dispatchEvent
static boolean dispatchEvent(Component component, String eventName, Object...args)
Definition: EventDispatcher.java:188
com.google.appinventor.components.annotations.SimpleProperty
Definition: SimpleProperty.java:23
com.google.appinventor.components.runtime.ComponentContainer
Definition: ComponentContainer.java:16
com.google.appinventor.components.common
Definition: ComponentCategory.java:7
com.google.appinventor.components.common.ComponentCategory
Definition: ComponentCategory.java:48
com.google.appinventor.components.runtime.Hygrometer
Definition: Hygrometer.java:30
com.google.appinventor.components.runtime.Hygrometer.Hygrometer
Hygrometer(ComponentContainer container)
Definition: Hygrometer.java:36
com.google.appinventor.components.annotations.SimpleObject
Definition: SimpleObject.java:23
com.google
com
com.google.appinventor.components.runtime.SingleValueSensor.value
float value
Definition: SingleValueSensor.java:33
com.google.appinventor.components.runtime.ComponentContainer.$form
Form $form()
com.google.appinventor.components.runtime.Hygrometer.Humidity
float Humidity()
Definition: Hygrometer.java:65
com.google.appinventor.components.runtime.Hygrometer.onValueChanged
void onValueChanged(float value)
Definition: Hygrometer.java:41
com.google.appinventor.components.annotations
com.google.appinventor