当前位置: 首页>>代码示例>>Java>>正文


Java DataMap.putLong方法代码示例

本文整理汇总了Java中com.google.android.gms.wearable.DataMap.putLong方法的典型用法代码示例。如果您正苦于以下问题:Java DataMap.putLong方法的具体用法?Java DataMap.putLong怎么用?Java DataMap.putLong使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.gms.wearable.DataMap的用法示例。


在下文中一共展示了DataMap.putLong方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateDataMap

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private DataMap generateDataMap(CustomRules aRule)
{
    DataMap dataMap=new DataMap();
    dataMap.putLong(Const.KEY_CURRENTTIMESTAMP,System.currentTimeMillis());
    dataMap.putLong(Const.KEY_RULE_ID,aRule.getId());
    dataMap.putString(Const.KEY_RULE_CATEGORY,aRule.getCategory());
    dataMap.putString(Const.KEY_RULE_CONSTRAINT1,aRule.getConstraint_1());
    dataMap.putString(Const.KEY_RULE_CONSTRAINT2,aRule.getConstraint_2());
    dataMap.putString(Const.KEY_RULE_CONSTRAINT3,aRule.getConstraint_3());

    //if null, we send the number -100000. We will have to check on the other side
    dataMap.putDouble(Const.KEY_RULE_VAL1_MIN, formatValue(aRule.getVal_1_min()));
    dataMap.putDouble(Const.KEY_RULE_VAL1_MAX,formatValue(aRule.getVal_1_max()));
    dataMap.putDouble(Const.KEY_RULE_VAL2_MIN,formatValue(aRule.getVal_2_min()));
    dataMap.putDouble(Const.KEY_RULE_VAL2_MAX, formatValue(aRule.getVal_2_max()));

    return dataMap;

}
 
开发者ID:kflauri2312lffds,项目名称:Android_watch_magpie,代码行数:20,代码来源:PushMeasureThread.java

示例2: prepareDataMap

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
/**
 * Used when a user update a rule. It will be send to the watch
 * @param rule : The current rule we want to send though a datamap (container)
 * @return The datamap that contain the rule
 */
private DataMap prepareDataMap(CustomRules rule)
{
    //create the value container
    DataMap dataContainer=new DataMap();

    //insert the rule value
    dataContainer.putLong(Const.KEY_RULE_ID,rule.getId());
    dataContainer.putString(Const.KEY_RULE_CATEGORY,rule.getCategory());
    dataContainer.putString(Const.KEY_RULE_CONSTRAINT1,rule.getConstraint_1());
    dataContainer.putString(Const.KEY_RULE_CONSTRAINT2,rule.getConstraint_2());
    dataContainer.putString(Const.KEY_RULE_CONSTRAINT3,rule.getConstraint_3());

    dataContainer.putDouble(Const.KEY_RULE_VAL1_MIN,formatDataMapValue( rule.getVal_1_min()));
    dataContainer.putDouble(Const.KEY_RULE_VAL1_MAX,formatDataMapValue(rule.getVal_1_max()));
    dataContainer.putDouble(Const.KEY_RULE_VAL2_MIN,formatDataMapValue(rule.getVal_2_min()));
    dataContainer.putDouble(Const.KEY_RULE_VAL2_MAX,formatDataMapValue(rule.getVal_2_max()));
    dataContainer.putLong(Const.KEY_CURRENTTIMESTAMP,System.currentTimeMillis());

    return dataContainer;
}
 
开发者ID:kflauri2312lffds,项目名称:Android_watch_magpie,代码行数:26,代码来源:Fragment_display_settings.java

示例3: sendData

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void sendData() {
    ArrayList<Double> tempValues = ForecastFragment.getTempValues();
    Log.v("TAG", tempValues.size()+"");
    final DataMap dataMap = new DataMap();
    dataMap.putDouble("max", tempValues.get(0));
    dataMap.putDouble("min", tempValues.get(1));
    dataMap.putInt("icon", ForecastFragment.getIconId());
    dataMap.putLong("timestamp", System.currentTimeMillis());

    new Thread( new Runnable() {
        @Override
        public void run() {
            PutDataMapRequest dataMapRequest = PutDataMapRequest.create(MOBILE_MESSAGE_PATH).setUrgent();
            dataMapRequest.getDataMap().putAll(dataMap);
            PutDataRequest request = dataMapRequest.asPutDataRequest();

            DataApi.DataItemResult result = Wearable.DataApi.putDataItem(mApiClient, request).await();
            if(result.getStatus().isSuccess()){
                Log.v("TAG", "Sent successfully");
            }else {
                Log.v("TAG", "Failed to send");
            }
        }
    }).start();
}
 
开发者ID:sahilandroid19,项目名称:WearApp,代码行数:26,代码来源:MessageListenerService.java

示例4: sendAlertTypeData

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void sendAlertTypeData() {//KS
    try {
        forceGoogleApiConnect();
        List <AlertType> alerts = AlertType.getAllActive();
        if (alerts != null) {
            if (wear_integration) {
                Log.d(TAG, "sendAlertTypeData latest count = " + alerts.size());
                final DataMap entries = new DataMap();
                final ArrayList<DataMap> dataMaps = new ArrayList<>(alerts.size());
                for (AlertType alert : alerts) {
                    if (alert != null) {
                        dataMaps.add(dataMap(alert, "alert"));
                    }
                }
                entries.putLong("time", new Date().getTime()); // MOST IMPORTANT LINE FOR TIMESTAMP
                entries.putDataMapArrayList("entries", dataMaps);
                new SendToDataLayerThread(WEARABLE_ALERTTYPE_DATA_PATH, googleApiClient).executeOnExecutor(xdrip.executor, entries);
            } else
                Log.d(TAG, "sendAlertTypeData latest count = 0");
        }
    } catch (NullPointerException e) {
        Log.e(TAG, "Nullpointer exception in sendAlertTypeData: " + e);
    }
}
 
开发者ID:NightscoutFoundation,项目名称:xDrip,代码行数:25,代码来源:WatchUpdaterService.java

示例5: resendData

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void resendData() {
    Log.d(TAG, "resendData ENTER");
    forceGoogleApiConnect();
    Log.d(TAG, "resendData googleApiClient connected ENTER");
    long startTime = new Date().getTime() - (60000 * 60 * 24);
    BgReading last_bg = BgReading.last();
    if (last_bg != null) {
        List<BgReading> graph_bgs = BgReading.latestForGraph(60, startTime);
        BgGraphBuilder bgGraphBuilder = new BgGraphBuilder(getApplicationContext());
        if (!graph_bgs.isEmpty()) {
            final int battery = PowerStateReceiver.getBatteryLevel(getApplicationContext());
            DataMap entries = dataMap(last_bg, mPrefs, bgGraphBuilder, battery);
            final ArrayList<DataMap> dataMaps = new ArrayList<>(graph_bgs.size());
            for (BgReading bg : graph_bgs) {
                dataMaps.add(dataMap(bg, mPrefs, bgGraphBuilder, battery));
            }
            entries.putLong("time", new Date().getTime()); // MOST IMPORTANT LINE FOR TIMESTAMP
            entries.putDataMapArrayList("entries", dataMaps);
            if (mPrefs.getBoolean("extra_status_line", false)) {
                entries.putString("extra_status_line", Home.extraStatusLine());
            }

            new SendToDataLayerThread(WEARABLE_DATA_PATH, googleApiClient).executeOnExecutor(xdrip.executor, entries);
        }
    }
}
 
开发者ID:jamorham,项目名称:xDrip-plus,代码行数:27,代码来源:WatchUpdaterService.java

示例6: sendPrefSettings

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void sendPrefSettings() {//KS

        Log.d(TAG, "sendPrefSettings enter");
        forceGoogleApiConnect();
        DataMap dataMap = new DataMap();
        boolean enable_wearG5 = mPrefs.getBoolean("enable_wearG5", false);
        boolean force_wearG5 = mPrefs.getBoolean("force_wearG5", false);
        String node_wearG5 = mPrefs.getString("node_wearG5", "");
        String dex_txid = mPrefs.getString("dex_txid", "ABCDEF");
        boolean show_wear_treatments = mPrefs.getBoolean("show_wear_treatments", false);

        if (localnode == null || (localnode != null && localnode.isEmpty())) setLocalNodeName();
        Log.d(TAG, "sendPrefSettings enable_wearG5: " + enable_wearG5 + " force_wearG5:" + force_wearG5 + " node_wearG5:" + node_wearG5 + " localnode:" + localnode + " dex_txid:" + dex_txid + " show_wear_treatments:" + show_wear_treatments);
        dataMap.putLong("time", new Date().getTime()); // MOST IMPORTANT LINE FOR TIMESTAMP
        dataMap.putBoolean("enable_wearG5", enable_wearG5);
        dataMap.putBoolean("force_wearG5", force_wearG5);
        if (force_wearG5) {
            dataMap.putString("node_wearG5", localnode);
        } else {
            if (node_wearG5.equals(localnode)) {
                dataMap.putString("node_wearG5", "");
            } else {
                dataMap.putString("node_wearG5", node_wearG5);
            }
        }
        dataMap.putString("dex_txid", dex_txid);
        dataMap.putInt("bridge_battery", mPrefs.getInt("bridge_battery", -1));//Used in DexCollectionService
        dataMap.putInt("nfc_sensor_age", mPrefs.getInt("nfc_sensor_age", -1));//Used in DexCollectionService for LimiTTer
        dataMap.putBoolean("bg_notifications_watch", mPrefs.getBoolean("bg_notifications", false));
        dataMap.putBoolean("persistent_high_alert_enabled_watch", mPrefs.getBoolean("persistent_high_alert_enabled", false));
        dataMap.putBoolean("show_wear_treatments", show_wear_treatments);
        sendData(WEARABLE_PREF_DATA_PATH, dataMap.toByteArray());

        SharedPreferences.Editor prefs = PreferenceManager.getDefaultSharedPreferences(this).edit();
        if (!node_wearG5.equals(dataMap.getString("node_wearG5", ""))) {
            Log.d(TAG, "sendPrefSettings save to SharedPreferences - node_wearG5:" + dataMap.getString("node_wearG5", ""));
            prefs.putString("node_wearG5", dataMap.getString("node_wearG5", ""));
            prefs.commit();
        }
    }
 
开发者ID:jamorham,项目名称:xDrip-plus,代码行数:41,代码来源:ListenerService.java

示例7: convertEventsToDataMapList

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
/**+
 * 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;
}
 
开发者ID:ibm-wearables-sdk-for-mobile,项目名称:ibm-wearables-android-sdk,代码行数:18,代码来源:DataManager.java

示例8: getWearTransmitterData

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private synchronized DataMap getWearTransmitterData(int count, long last_send_time, int min_count) {//KS
    forceGoogleApiConnect();

    Log.d(TAG, "getWearTransmitterData last_send_time:" + JoH.dateTimeText(last_send_time));

    TransmitterData last_bg = TransmitterData.last();
    if (last_bg != null) {
        Log.d(TAG, "getWearTransmitterData last_bg.timestamp:" + JoH.dateTimeText(last_bg.timestamp));
    }

    if (last_bg != null && last_send_time <= last_bg.timestamp) {//startTime
        long last_send_success = last_send_time;
        Log.d(TAG, "getWearTransmitterData last_send_time < last_bg.timestamp:" + JoH.dateTimeText(last_bg.timestamp));
        List<TransmitterData> graph_bgs = TransmitterData.latestForGraphAsc(count, last_send_time);
        if (!graph_bgs.isEmpty() && graph_bgs.size() > min_count) {
            //Log.d(TAG, "getWearTransmitterData count = " + graph_bgs.size());
            DataMap entries = dataMap(last_bg);
            final ArrayList<DataMap> dataMaps = new ArrayList<>(graph_bgs.size());
            for (TransmitterData bg : graph_bgs) {
                dataMaps.add(dataMap(bg));
                last_send_success = bg.timestamp;
                //Log.d(TAG, "getWearTransmitterData bg getId:" + bg.getId() + " raw_data:" + bg.raw_data + " filtered_data:" + bg.filtered_data + " timestamp:" + bg.timestamp + " uuid:" + bg.uuid);
            }
            entries.putLong("time", new Date().getTime()); // MOST IMPORTANT LINE FOR TIMESTAMP
            entries.putDataMapArrayList("entries", dataMaps);
            Log.i(TAG, "getWearTransmitterData SYNCED BGs up to " + JoH.dateTimeText(last_send_success) + " count = " + graph_bgs.size());
            return entries;
        } else
            Log.i(TAG, "getWearTransmitterData SYNCED BGs up to " + JoH.dateTimeText(last_send_success) + " count = 0");
    }
    return null;
}
 
开发者ID:NightscoutFoundation,项目名称:xDrip,代码行数:33,代码来源:ListenerService.java

示例9: sendPersistentStore

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private synchronized void sendPersistentStore() {
    if (DexCollectionType.getDexCollectionType().equals(DexCollectionType.DexcomG5)) {
        DataMap dataMap = new DataMap();
        String dex_txid = mPrefs.getString("dex_txid", "ABCDEF");
        dataMap.putByteArray(G5_BATTERY_MARKER, PersistentStore.getBytes(G5_BATTERY_MARKER + dex_txid));
        dataMap.putLong(G5_BATTERY_FROM_MARKER, PersistentStore.getLong(G5_BATTERY_FROM_MARKER + dex_txid));
        dataMap.putString("dex_txid", dex_txid);

        dataMap.putByteArray(G5_FIRMWARE_MARKER, PersistentStore.getBytes(G5_FIRMWARE_MARKER + dex_txid));
        dataMap.putString("dex_txid", dex_txid);
        sendData(WEARABLE_G5BATTERY_PAYLOAD, dataMap.toByteArray());
    }
}
 
开发者ID:jamorham,项目名称:xDrip-plus,代码行数:14,代码来源:ListenerService.java

示例10: sendReplyMsg

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private synchronized void sendReplyMsg (String msg, long last_timestamp, String path, boolean showToast, int length) {
    Log.d(TAG, "sendReplyMsg msg=" + msg);
    DataMap dataMap = new DataMap();
    dataMap.putString("msg", msg);
    dataMap.putLong("last_timestamp", last_timestamp);
    dataMap.putString("action_path", path);//eg. START_COLLECTOR_PATH
    Log.d(TAG, "sendReplyMsg dataMap=" + dataMap);
    if (showToast) {
        sendLocalToast(msg, length);
    }
    sendData(WEARABLE_REPLYMSG_PATH, dataMap.toByteArray());
}
 
开发者ID:NightscoutFoundation,项目名称:xDrip,代码行数:13,代码来源:ListenerService.java

示例11: sendSyncRequested

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private synchronized void sendSyncRequested (String path, long syncLogsRequested) {
    if (syncLogsRequested > 0) syncLogsRequested--;
    Log.d(TAG, "sendSyncRequested syncLogsRequested=" + syncLogsRequested);
    DataMap dataMap = new DataMap();
    dataMap.putLong("timestamp", System.currentTimeMillis());
    dataMap.putLong("syncLogsRequested", syncLogsRequested);
    sendData(path, dataMap.toByteArray());
}
 
开发者ID:NightscoutFoundation,项目名称:xDrip,代码行数:9,代码来源:ListenerService.java

示例12: getWatchStatus

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
public static DataMap getWatchStatus() {
    DataMap dataMap = new DataMap();
    dataMap.putString("lastState", lastState);
    if (last_transmitter_Data != null) dataMap.putLong("timestamp", last_transmitter_Data.timestamp);
    dataMap.putInt("mStaticState", mStaticState);
    dataMap.putInt("last_battery_level", last_battery_level);
    dataMap.putLong("retry_time", retry_time);
    dataMap.putLong("failover_time", failover_time);
    dataMap.putString("static_last_hexdump", static_last_hexdump);
    dataMap.putString("static_last_sent_hexdump", static_last_sent_hexdump);
    return dataMap;
}
 
开发者ID:NightscoutFoundation,项目名称:xDrip,代码行数:13,代码来源:DexCollectionService.java

示例13: getSensorSteps

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
public static DataMap getSensorSteps(SharedPreferences prefs) {
    Log.d("BgSendQueue", "getSensorSteps");
    DataMap dataMap = new DataMap();
    final long t = System.currentTimeMillis();
    final PebbleMovement pm = PebbleMovement.last();
    final boolean show_steps = prefs.getBoolean("showSteps", true);
    final boolean show_heart_rate = prefs.getBoolean("showHeartRate", true);
    final boolean use_wear_health = prefs.getBoolean("use_wear_health", true);
    if (use_wear_health || show_steps) {
        boolean sameDay = pm != null ? ListenerService.isSameDay(t, pm.timestamp) : false;
        if (!sameDay) {
            dataMap.putInt("steps", 0);
            dataMap.putLong("steps_timestamp", t);
            Log.d("BgSendQueue", "getSensorSteps isSameDay false t=" + JoH.dateTimeText(t));
        }
        else {
            dataMap.putInt("steps", pm.metric);
            dataMap.putLong("steps_timestamp", pm.timestamp);
            Log.d("BgSendQueue", "getSensorSteps isSameDay true pm.timestamp=" + JoH.dateTimeText(pm.timestamp) + " metric=" + pm.metric);
        }
    }

    if (use_wear_health && show_heart_rate) {
        final HeartRate lastHeartRateReading = HeartRate.last();
        if (lastHeartRateReading != null) {
            dataMap.putInt("heart_rate", lastHeartRateReading.bpm);
            dataMap.putLong("heart_rate_timestamp", lastHeartRateReading.timestamp);
        }
    }
    return dataMap;
}
 
开发者ID:jamorham,项目名称:xDrip-plus,代码行数:32,代码来源:BgSendQueue.java

示例14: getWearLogData

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private synchronized DataMap getWearLogData(int count, long last_send_time, int min_count, long syncLogsRequested) {
    forceGoogleApiConnect();

    Log.d(TAG, "getWearLogData last_send_time:" + JoH.dateTimeText(last_send_time) + " max count=" + count + " min_count=" + min_count + " syncLogsRequested=" + syncLogsRequested);

    UserError last_log = UserError.last();
    if (last_log != null) {
        Log.d(TAG, "getWearLogData last_log.timestamp:" + JoH.dateTimeText((long) last_log.timestamp));
    }

    if (last_log != null && last_send_time <= last_log.timestamp) {//startTime
        long last_send_success = last_send_time;
        Log.d(TAG, "getWearLogData last_send_time < last_bg.timestamp:" + JoH.dateTimeText((long) last_log.timestamp));
        List<UserError> logs = UserError.latestAsc(count, last_send_time);
        if (!logs.isEmpty() && logs.size() > min_count) {
            //Log.d(TAG, "getWearLogData count = " + logs.size());
            DataMap entries = dataMap(last_log);
            final ArrayList<DataMap> dataMaps = new ArrayList<>(logs.size());
            for (UserError log : logs) {
                dataMaps.add(dataMap(log));
                last_send_success = (long)log.timestamp;
                //Log.d(TAG, "getWearLogData set last_send_sucess:" + JoH.dateTimeText(last_send_sucess) + " Log:" + log.toString());
            }
            entries.putLong("time", new Date().getTime()); // MOST IMPORTANT LINE FOR TIMESTAMP
            entries.putLong("syncLogsRequested", syncLogsRequested);
            entries.putDataMapArrayList("entries", dataMaps);
            Log.i(TAG, "getWearLogData SYNCED logs up to " + JoH.dateTimeText(last_send_success) + " count = " + logs.size() + " syncLogsRequested=" + syncLogsRequested);
            return entries;
        } else
            Log.i(TAG, "getWearLogData SYNCED logs up to " + JoH.dateTimeText(last_send_success) + " count = 0" + " syncLogsRequested=" + syncLogsRequested);
    }
    return null;
}
 
开发者ID:jamorham,项目名称:xDrip-plus,代码行数:34,代码来源:ListenerService.java

示例15: dataMapSingleBG

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private DataMap dataMapSingleBG(BgReading lastBG, GlucoseStatus glucoseStatus) {
    String units = MainApp.getConfigBuilder().getProfileUnits();

    Double lowLine = SafeParse.stringToDouble(mPrefs.getString("low_mark", "0"));
    Double highLine = SafeParse.stringToDouble(mPrefs.getString("high_mark", "0"));

    //convert to mg/dl
    if (!units.equals(Constants.MGDL)) {
        lowLine *= Constants.MMOLL_TO_MGDL;
        highLine *= Constants.MMOLL_TO_MGDL;

    }

    if (lowLine < 1) {
        lowLine = OverviewPlugin.bgTargetLow;
    }

    if (highLine < 1) {
        highLine = OverviewPlugin.bgTargetHigh;
    }

    long sgvLevel = 0l;
    if (lastBG.value > highLine) {
        sgvLevel = 1;
    } else if (lastBG.value < lowLine) {
        sgvLevel = -1;
    }
    DataMap dataMap = new DataMap();

    int battery = getBatteryLevel(getApplicationContext());
    dataMap.putString("sgvString", lastBG.valueToUnitsToString(units));
    dataMap.putDouble("timestamp", lastBG.date);
    if (glucoseStatus == null) {
        dataMap.putString("slopeArrow", "");
        dataMap.putString("delta", "");
        dataMap.putString("avgDelta", "");
    } else {
        dataMap.putString("slopeArrow", slopeArrow(glucoseStatus.delta));
        dataMap.putString("delta", deltastring(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units));
        dataMap.putString("avgDelta", deltastring(glucoseStatus.avgdelta, glucoseStatus.avgdelta * Constants.MGDL_TO_MMOLL, units));
    }
    dataMap.putString("battery", "" + battery);
    dataMap.putLong("sgvLevel", sgvLevel);
    dataMap.putInt("batteryLevel", (battery >= 30) ? 1 : 0);
    dataMap.putDouble("sgvDouble", lastBG.value);
    dataMap.putDouble("high", highLine);
    dataMap.putDouble("low", lowLine);
    return dataMap;
}
 
开发者ID:MilosKozak,项目名称:AndroidAPS,代码行数:50,代码来源:WatchUpdaterService.java


注:本文中的com.google.android.gms.wearable.DataMap.putLong方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。