Android Open Source - Sensoria Sensor Utils






From Project

Back to project page Sensoria.

License

The source code is released under:

MIT License

If you think the Android project Sensoria listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.grocs.sensors.common;
//w  w w  .  j  a  v  a 2  s.c  om
import java.util.Collection;

import android.hardware.Sensor;

/**
 * Utility class collection some util fucntions for Sensor / SensorData
 */
public class SensorUtils {

    /**
     */
    static SensorData retrieveSensor(SensorData[] sensors, Sensor sensor) {
        for (SensorData sd : sensors) {
            if (sd.getSensor().equals(sensor)) {
                return sd;
            }
        }
        return null;
    }

    /**
     */
    static SensorData retrieveSensor(SensorData[] sensors, String name) {
        for (SensorData sd : sensors) {
            if (sd.getSensor().getName().equals(name)) {
                return sd;
            }
        }
        return null;
    }

    public static ISensorDescription getDescription(final int type) {
        return SensorDescriptions.getDescription(type);
    }

    static int getNrOfExpectedValues(final Sensor sensor) {
        final ISensorDescription description = SensorDescriptions
                .getDescription(sensor.getType());
        return description.getValueDescriptions().length;
    }

    static int getMaxNrOfExpectedValues() {
        int maxNr = 0;
        for (ISensorDescription desc : SensorDescriptions.getDescriptions()) {
            maxNr = Math.max(maxNr, desc.getValueDescriptions().length);
        }
        return maxNr;
    }

    /**
     * private constructor for utility class.
     */
    private SensorUtils() {
    }
}




Java Source Code List

com.grocs.sensors.common.FloatConvertor.java
com.grocs.sensors.common.ISensorData.java
com.grocs.sensors.common.ISensorDescription.java
com.grocs.sensors.common.SensorCollector.java
com.grocs.sensors.common.SensorConstants.java
com.grocs.sensors.common.SensorDataComparator.java
com.grocs.sensors.common.SensorDataManagerListener.java
com.grocs.sensors.common.SensorDataManager.java
com.grocs.sensors.common.SensorData.java
com.grocs.sensors.common.SensorDescriptions.java
com.grocs.sensors.common.SensorFilter.java
com.grocs.sensors.common.SensorUtils.java
com.grocs.sensors.common.TestFloatConvertor.java
com.grocs.sensors.ui.ActivityDetail.java
com.grocs.sensors.ui.Activity.java
com.grocs.sensors.ui.EntryAdapter.java
com.grocs.sensors.ui.FloatFormatter.java
com.grocs.sensors.ui.SensorEntryComparator.java
com.grocs.sensors.ui.SensorEntry.java
com.grocs.sensors.ui.SensorPreferenceActivity.java
com.grocs.sensors.ui.TestFloatFormatter.java