Search in sources :

Example 76 with DataMap

use of com.google.android.gms.wearable.DataMap in project android_packages_apps_GmsCore by microg.

the class WearableLocationService method onMessageReceived.

@Override
public void onMessageReceived(MessageEvent messageEvent) {
    if (messageEvent.getPath().equals(PATH_LOCATION_REQUESTS)) {
        DataMap dataMap = DataMap.fromByteArray(messageEvent.getData());
        onLocationRequests(messageEvent.getSourceNodeId(), readLocationRequestList(dataMap, this), dataMap.getBoolean("TRIGGER_UPDATE", false));
    } else if (messageEvent.getPath().equals(PATH_CAPABILITY_QUERY)) {
        onCapabilityQuery(messageEvent.getSourceNodeId());
    }
}
Also used : DataMap(com.google.android.gms.wearable.DataMap)

Example 77 with DataMap

use of com.google.android.gms.wearable.DataMap in project Memento-Calendar by alexstyl.

the class ContactEventsProviderService method createComplicationData.

private ComplicationData createComplicationData(DataItem item, int dataType) {
    DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();
    long date = dataMap.getLong(SharedConstants.KEY_DATE);
    ArrayList<String> namesList = dataMap.getStringArrayList(SharedConstants.KEY_CONTACTS_NAMES);
    return createComplicationData(dataType, date, namesList);
}
Also used : DataMap(com.google.android.gms.wearable.DataMap)

Example 78 with DataMap

use of com.google.android.gms.wearable.DataMap in project ETSMobile-Android2 by ApplETS.

the class Seances method putData.

public DataMap putData() {
    DataMap map = new DataMap();
    map.putString("dateDebut", dateDebut);
    map.putString("dateFin", dateFin);
    map.putString("coursGroupe", coursGroupe);
    map.putString("nomActivite", nomActivite);
    map.putString("local", local);
    map.putString("descriptionActivite", descriptionActivite);
    map.putString("libelleCours", libelleCours);
    return map;
}
Also used : DataMap(com.google.android.gms.wearable.DataMap)

Example 79 with DataMap

use of com.google.android.gms.wearable.DataMap in project Memento-Calendar by alexstyl.

the class ContactEventsActivity method displayDataItem.

private void displayDataItem(DataItem item) {
    DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();
    long date = dataMap.getLong(SharedConstants.KEY_DATE);
    CharSequence dateString = formatDate(date);
    ArrayList<String> namesList = dataMap.getStringArrayList(SharedConstants.KEY_CONTACTS_NAMES);
    dateText.setText(dateString);
    namesText.setText(StringUtils.join(namesList, "\n"));
    emptyText.setVisibility(View.GONE);
    eventContainer.setVisibility(View.VISIBLE);
}
Also used : DataMap(com.google.android.gms.wearable.DataMap)

Example 80 with DataMap

use of com.google.android.gms.wearable.DataMap in project xDrip by NightscoutFoundation.

the class ListenerService method syncBgData.

private synchronized void syncBgData(DataMap dataMap, Context context) {
    // KS
    Log.d(TAG, "syncBGData");
    boolean changed = false;
    int battery = dataMap.getInt("battery");
    ArrayList<DataMap> entries = dataMap.getDataMapArrayList("entries");
    Log.d(TAG, "syncBGData add BgReading Table battery=" + battery);
    if (entries != null) {
        Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().registerTypeAdapter(Date.class, new DateTypeAdapter()).serializeSpecialFloatingPointValues().create();
        Log.d(TAG, "syncBGData add BgReading Table entries count=" + entries.size());
        // ensure database has already been initialized
        Sensor.InitDb(context);
        Sensor sensor = Sensor.currentSensor();
        if (sensor != null) {
            for (DataMap entry : entries) {
                if (entry != null) {
                    String bgrecord = entry.getString("bgs");
                    if (bgrecord != null) {
                        BgReading bgData = gson.fromJson(bgrecord, BgReading.class);
                        /*    // TODO this is a hack to use display glucose but it is incomplete regarding delta
                            if (bgData.dg_mgdl > 0) {
                                bgData.calculated_value = bgData.dg_mgdl;
                                bgData.calculated_value_slope = bgData.dg_slope;
                                // TODO delta missing???
                            }
*/
                        BgReading exists = BgReading.getForTimestampExists(bgData.timestamp);
                        exists = exists != null ? exists : BgReading.findByUuid(bgData.uuid);
                        String calibrationUuid = entry.getString("calibrationUuid");
                        if (exists != null) {
                            Log.d(TAG, "syncBGData BG already exists for uuid=" + bgData.uuid + " timestamp=" + bgData.timestamp + " timeString=" + JoH.dateTimeText(bgData.timestamp));
                            Log.d(TAG, "syncBGData exists timeString=" + JoH.dateTimeText(exists.timestamp) + "  exists.calibration.uuid=" + exists.calibration.uuid + " exists=" + exists.toS());
                            exists.filtered_calculated_value = bgData.filtered_calculated_value;
                            exists.calculated_value = bgData.calculated_value;
                            exists.hide_slope = bgData.hide_slope;
                            exists.filtered_data = bgData.filtered_data;
                            exists.raw_data = bgData.raw_data;
                            exists.raw_calculated = bgData.raw_calculated;
                            exists.calculated_value_slope = bgData.calculated_value_slope;
                            exists.age_adjusted_raw_value = bgData.age_adjusted_raw_value;
                            exists.calibration_flag = bgData.calibration_flag;
                            exists.ignoreForStats = bgData.ignoreForStats;
                            exists.time_since_sensor_started = bgData.time_since_sensor_started;
                            exists.ra = bgData.ra;
                            exists.rb = bgData.rb;
                            exists.rc = bgData.rc;
                            exists.a = bgData.a;
                            exists.b = bgData.b;
                            exists.c = bgData.c;
                            exists.noise = bgData.noise;
                            exists.time_since_sensor_started = bgData.time_since_sensor_started;
                            Calibration calibration = Calibration.byuuid(calibrationUuid);
                            calibration = calibration != null ? calibration : Calibration.byuuid(exists.calibration_uuid);
                            if (calibration != null) {
                                exists.calibration = calibration;
                                exists.calibration_uuid = calibration.uuid;
                                exists.sensor = sensor;
                                exists.sensor_uuid = sensor.uuid;
                                if (exists.calculated_value != bgData.calculated_value) {
                                    changed = true;
                                }
                                exists.save();
                            } else {
                                Log.e(TAG, "syncBGData existing BgReading calibrationUuid not found by byuuid; calibrationUuid=" + calibrationUuid + " bgData.calibration_uuid=" + bgData.calibration_uuid + " bgData.uuid=" + bgData.uuid + " timeString=" + JoH.dateTimeText(bgData.timestamp));
                            }
                        } else {
                            Calibration calibration = Calibration.byuuid(calibrationUuid);
                            calibration = calibration != null ? calibration : Calibration.byuuid(bgData.calibration_uuid);
                            if (calibration != null) {
                                Log.d(TAG, "syncBGData add BG; does NOT exist for uuid=" + bgData.uuid + " timestamp=" + bgData.timestamp + " timeString=" + JoH.dateTimeText(bgData.timestamp));
                                bgData.calibration = calibration;
                                bgData.calibration_uuid = calibration.uuid;
                                bgData.sensor = sensor;
                                bgData.sensor_uuid = sensor.uuid;
                                changed = true;
                                bgData.save();
                            } else {
                                Log.e(TAG, "syncBGData new BgReading calibrationUuid not found by byuuid; calibrationUuid=" + calibrationUuid + " bgData.calibration_uuid=" + bgData.calibration_uuid + " bgData.uuid=" + bgData.uuid + " timeString=" + JoH.dateTimeText(bgData.timestamp));
                            }
                        }
                    }
                }
            }
        } else {
            Log.d(TAG, "syncBGData No Active Sensor!! Request WEARABLE_INITDB_PATH");
            sendData(WEARABLE_INITDB_PATH, null);
        }
    }
    if (changed) {
        // otherwise, wait for doBackground ACTION_RESEND
        Log.d(TAG, "syncBGData BG data has changed, refresh watchface, phone battery=" + battery);
        resendData(getApplicationContext(), battery);
        CustomComplicationProviderService.refresh();
    } else
        Log.d(TAG, "syncBGData BG data has NOT changed, do not refresh watchface, phone battery=" + battery);
}
Also used : DateTypeAdapter(com.google.gson.internal.bind.DateTypeAdapter) GsonBuilder(com.google.gson.GsonBuilder) Gson(com.google.gson.Gson) BgReading(com.eveningoutpost.dexdrip.Models.BgReading) Calibration(com.eveningoutpost.dexdrip.Models.Calibration) DataMap(com.google.android.gms.wearable.DataMap) Sensor(com.eveningoutpost.dexdrip.Models.Sensor)

Aggregations

DataMap (com.google.android.gms.wearable.DataMap)147 Date (java.util.Date)38 ArrayList (java.util.ArrayList)36 Gson (com.google.gson.Gson)18 Intent (android.content.Intent)17 GsonBuilder (com.google.gson.GsonBuilder)16 DateTypeAdapter (com.google.gson.internal.bind.DateTypeAdapter)16 BgReading (com.eveningoutpost.dexdrip.Models.BgReading)12 Sensor (com.eveningoutpost.dexdrip.Models.Sensor)12 PendingIntent (android.app.PendingIntent)11 Context (android.content.Context)8 Calibration (com.eveningoutpost.dexdrip.Models.Calibration)8 Treatments (com.eveningoutpost.dexdrip.Models.Treatments)8 Bundle (android.os.Bundle)6 HeartRate (com.eveningoutpost.dexdrip.Models.HeartRate)6 Paint (android.graphics.Paint)5 BloodTest (com.eveningoutpost.dexdrip.Models.BloodTest)5 BroadcastReceiver (android.content.BroadcastReceiver)4 SharedPreferences (android.content.SharedPreferences)4 Point (android.graphics.Point)4