Java Code Examples for com.google.android.gms.wearable.DataMap#putFloatArray()

The following examples show how to use com.google.android.gms.wearable.DataMap#putFloatArray() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WearUtilTest.java    From AndroidAPS with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * It tests if mock for bundleToDataMap is sane,
 * because original impl. of bundleToDataMap
 * uses DataMap.fromBundle which need Android SDK runtime
 */
@Test
public void bundleToDataMapTest() throws Exception {
    // GIVEN
    DataMap refMap = new DataMap();
    refMap.putString("ala", "ma kota");
    refMap.putInt("why", 42);
    refMap.putFloatArray("list", new float[]{0.45f, 3.2f, 6.8f});

    // WHEN
    WearUtilMocker.prepareMockNoReal();
    Bundle bundle = BundleMock.mock(refMap);
    DataMap gotMap = WearUtil.bundleToDataMap(bundle);

    // THEN
    assertThat(gotMap, is(refMap));
}
 
Example 2
Source File: DataManager.java    From ibm-wearables-android-sdk with Apache License 2.0 5 votes vote down vote up
/**+
 * Convert the sensors event to data that will be sent to the phone
 * @param eventsList all the events to convert
 * @return converted list
 */
private ArrayList<DataMap> convertEventsToDataMapList(List<GestureDataHolder.EventData> eventsList){
    ArrayList<DataMap> dataMapsList = new ArrayList<>();

    for (GestureDataHolder.EventData event : eventsList){
        DataMap eventDataMap = new DataMap();
        eventDataMap.putLong("timeStamp", event.timestamp);
        eventDataMap.putFloatArray("values", event.values);
        dataMapsList.add(eventDataMap);
    }

    return dataMapsList;
}
 
Example 3
Source File: Message.java    From DronesWear with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static PendingResult<DataApi.DataItemResult> sendAcceleroMessage(AccelerometerData accelerometerData, GoogleApiClient googleApiClient) {
    PutDataMapRequest dataMapRequest = PutDataMapRequest.create(ACC_PATH);
    acceleroMessageUri = dataMapRequest.getUri();
    DataMap dataMap = dataMapRequest.getDataMap();
    //Data set
    dataMap.putFloatArray(VALUE_STR, new float[]{accelerometerData.getAccX(), accelerometerData.getAccY(), accelerometerData.getAccZ()});

    // Data Push
    PutDataRequest request = dataMapRequest.asPutDataRequest();
    PendingResult<DataApi.DataItemResult> pendingResult = Wearable.DataApi.putDataItem(googleApiClient, request);

    return pendingResult;
}
 
Example 4
Source File: Message.java    From DronesWear with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static PendingResult<DataApi.DataItemResult> sendJoystickMessage(JoystickData joystickData, GoogleApiClient googleApiClient) {
    PutDataMapRequest dataMapRequest = PutDataMapRequest.create(JOYSTICK_PATH);
    joystickMessageUri = dataMapRequest.getUri();
    DataMap dataMap = dataMapRequest.getDataMap();
    //Data set
    dataMap.putFloatArray(VALUE_STR, new float[]{joystickData.getPercentX(), joystickData.getPercentY()});

    // Data Push
    PutDataRequest request = dataMapRequest.asPutDataRequest();
    PendingResult<DataApi.DataItemResult> pendingResult = Wearable.DataApi.putDataItem(googleApiClient, request);

    return pendingResult;
}
 
Example 5
Source File: DataBundleUtil.java    From android_external_GmsLib with Apache License 2.0 4 votes vote down vote up
@Override
void store(DataMap dataMap, String key, float[] value) {
    dataMap.putFloatArray(key, value);
}