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


Java DataMap.getLong方法代码示例

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


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

示例1: loadBasalsAndTemps

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void loadBasalsAndTemps(DataMap dataMap) {
    ArrayList<DataMap> temps = dataMap.getDataMapArrayList("temps");
    if (temps != null) {
        tempWatchDataList = new ArrayList<>();
        for (DataMap temp : temps) {
            TempWatchData twd = new TempWatchData();
            twd.startTime = temp.getLong("starttime");
            twd.startBasal =  temp.getDouble("startBasal");
            twd.endTime = temp.getLong("endtime");
            twd.endBasal = temp.getDouble("endbasal");
            twd.amount = temp.getDouble("amount");
            tempWatchDataList.add(twd);
        }
    }
    ArrayList<DataMap> basals = dataMap.getDataMapArrayList("basals");
    if (basals != null) {
        basalWatchDataList = new ArrayList<>();
        for (DataMap basal : basals) {
            BasalWatchData bwd = new BasalWatchData();
            bwd.startTime = basal.getLong("starttime");
            bwd.endTime = basal.getLong("endtime");
            bwd.amount = basal.getDouble("amount");
            basalWatchDataList.add(bwd);
        }
    }
}
 
开发者ID:MilosKozak,项目名称:AndroidAPS,代码行数:27,代码来源:NOChart.java

示例2: syncSensorData

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void syncSensorData(DataMap dataMap, Context context) {//KS
    Log.d(TAG, "syncSensorData");
    if (dataMap != null) {
        String uuid = dataMap.getString("uuid");
        Log.d(TAG, "syncSensorData add Sensor for uuid=" + uuid);
        long started_at = dataMap.getLong("started_at");
        Integer latest_battery_level = dataMap.getInt("latest_battery_level");
        String sensor_location = dataMap.getString("sensor_location");
        Sensor.InitDb(context);//ensure database has already been initialized
        if (uuid != null && !uuid.isEmpty()) {
            Log.d(TAG, "syncSensorData add Sensor for uuid=" + uuid + " timestamp=" + started_at + " timeString=" +  JoH.dateTimeText(started_at));
            Sensor sensor = Sensor.getByUuid(uuid);
            if (sensor == null) {
                Log.d(TAG, "syncSensorData createUpdate new Sensor...");
                Sensor.createUpdate(started_at, 0, latest_battery_level, sensor_location, uuid);
                Sensor newsensor = Sensor.currentSensor();
                if (newsensor != null) {
                    Log.d(TAG, "syncSensorData createUpdate Sensor with uuid=" + uuid + " started at=" + started_at);
                } else
                    Log.d(TAG, "syncSensorData Failed to createUpdate new Sensor for uuid=" + uuid);
            } else
                Log.d(TAG, "syncSensorData Sensor already exists with uuid=" + uuid);
        }
    }
}
 
开发者ID:NightscoutFoundation,项目名称:xDrip,代码行数:26,代码来源:ListenerService.java

示例3: syncFieldData

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void syncFieldData(DataMap dataMap) {
    String dex_txid = dataMap.getString("dex_txid", "");
    byte[] G5_BATTERY_MARKER = dataMap.getByteArray(G5CollectionService.G5_BATTERY_MARKER);
    byte[] G5_FIRMWARE_MARKER = dataMap.getByteArray(G5CollectionService.G5_FIRMWARE_MARKER);
    if (dex_txid != null && dex_txid.equals(mPrefs.getString("dex_txid", "default"))) {
        if (G5_BATTERY_MARKER != null) {
            long watch_last_battery_query = dataMap.getLong(G5CollectionService.G5_BATTERY_FROM_MARKER);
            long phone_last_battery_query = PersistentStore.getLong(G5CollectionService.G5_BATTERY_FROM_MARKER + dex_txid);
            if (watch_last_battery_query > phone_last_battery_query) {
                G5CollectionService.setStoredBatteryBytes(dex_txid, G5_BATTERY_MARKER);
                PersistentStore.setLong(G5CollectionService.G5_BATTERY_FROM_MARKER + dex_txid, watch_last_battery_query);
                G5CollectionService.getBatteryStatusNow = false;
                Ob1G5CollectionService.getBatteryStatusNow = false;
            }
        }
        if (G5_FIRMWARE_MARKER != null) {
            G5CollectionService.setStoredFirmwareBytes(dex_txid, G5_FIRMWARE_MARKER);
        }
    }
}
 
开发者ID:NightscoutFoundation,项目名称:xDrip,代码行数:21,代码来源:WatchUpdaterService.java

示例4: onDataChanged

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
@Override
public void onDataChanged(DataEventBuffer dataEventBuffer) {
    Log.d(LOG_TAG, "Weather data has been changed!");
    for (DataEvent event : dataEventBuffer) {
        DataItem item = event.getDataItem();
        if (WEATHER_DATA_PATH.equals(item.getUri().getPath())) {
            DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();
            double high = dataMap.getDouble(WEATHER_DATA_HIGH);
            double low = dataMap.getDouble(WEATHER_DATA_LOW);
            long id = dataMap.getLong(WEATHER_DATA_ID);

            mWeather = (int) Math.round(high) + "/" +  (int) Math.round(low);
            mWeatherId = (int) id;

            loadIconForWeatherId();

            SharedPreferences preferences = getSharedPreferences(PREFERENCES, MODE_PRIVATE);
            SharedPreferences.Editor editor = preferences.edit();
            editor.putString(KEY_WEATHER, mWeather);
            editor.putInt(KEY_WEATHER_ID, mWeatherId);
            editor.apply();
        }
    }
}
 
开发者ID:DmitryMalkovich,项目名称:go-ubiquitous,代码行数:25,代码来源:SunshineWatchFace.java

示例5: setWatchStatus

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
public static void setWatchStatus(DataMap dataMap) {
    lastStateWatch = dataMap.getString("lastState", "");
    last_transmitter_DataWatch = new TransmitterData();
    last_transmitter_DataWatch.timestamp = dataMap.getLong("timestamp", 0);
    mStaticStateWatch = dataMap.getInt("mStaticState", 0);
    last_battery_level_watch = dataMap.getInt("last_battery_level", -1);
    retry_time_watch = dataMap.getLong("retry_time", 0);
    failover_time_watch = dataMap.getLong("failover_time", 0);
    static_last_hexdump_watch = dataMap.getString("static_last_hexdump", "");
    static_last_sent_hexdump_watch = dataMap.getString("static_last_sent_hexdump", "");
}
 
开发者ID:NightscoutFoundation,项目名称:xDrip,代码行数:12,代码来源:DexCollectionService.java

示例6: syncTreatmentsData

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private synchronized void syncTreatmentsData(DataMap dataMap, boolean bBenchmark) {
    Log.d(TAG, "syncTreatmentsData");

    ArrayList<DataMap> entries = dataMap.getDataMapArrayList("entries");
    long timeOfLastEntry = 0;
    if (entries != null) {
        Log.d(TAG, "syncTreatmentsData count=" + entries.size());
        for (DataMap entry : entries) {
            if (entry != null) {
                Log.d(TAG, "syncTreatmentsData entry=" + entry);
                String record = entry.getString("entry");
                if (record != null && record.length() > 1) {
                    Log.d(TAG, "Received wearable: voice payload: " + record);
                    long timestamp = entry.getLong("timestamp");
                    if (timestamp <= PersistentStore.getLong(LAST_RECORD_TIMESTAMP)) {
                        Log.e(TAG,"Ignoring repeated or older sync timestamp");
                        continue;
                    }
                    final long since = JoH.msSince(timestamp);
                    if ((since < 0) || (since > Constants.HOUR_IN_MS * 72)) {
                        JoH.static_toast_long("Rejecting wear treatment as time out of range!");
                        UserError.Log.e(TAG, "Rejecting wear treatment due to time: " + record + " since: " + since);
                    } else {
                        if (record.contains("uuid null")) {
                            Log.e(TAG,"Skipping xx uuid null record!");
                            continue;
                        }
                        receivedText(getApplicationContext(), record);
                        PersistentStore.setLong(LAST_RECORD_TIMESTAMP, timestamp);
                    }
                    Log.d(TAG, "syncTreatmentsData add Table record=" + record);
                    timeOfLastEntry = (long) timestamp + 1;
                    Log.d(TAG, "syncTreatmentsData WATCH treatments timestamp=" + JoH.dateTimeText(timestamp));
                }
            }
        }
        sendDataReceived(DATA_ITEM_RECEIVED_PATH,"DATA_RECEIVED_LOGS count=" + entries.size(), timeOfLastEntry, bBenchmark?"BM":"TREATMENTS", -1);
    }
}
 
开发者ID:NightscoutFoundation,项目名称:xDrip,代码行数:40,代码来源:WatchUpdaterService.java

示例7: setWatchStatus

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
public static void setWatchStatus(DataMap dataMap) {
    lastStateWatch = dataMap.getString("lastState", "");
    static_last_timestamp_watch = dataMap.getLong("timestamp", 0);
}
 
开发者ID:NightscoutFoundation,项目名称:xDrip,代码行数:5,代码来源:G5BaseService.java

示例8: syncLogData

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private synchronized void syncLogData(DataMap dataMap, boolean bBenchmark) {//KS
    Log.d(TAG, "syncLogData");
    long watch_syncLogsRequested = dataMap.getLong("syncLogsRequested", -1);
    ArrayList<DataMap> entries = dataMap.getDataMapArrayList("entries");
    long timeOfLastEntry = 0;
    int saved = 0;
    if (entries != null) {

        Gson gson = new GsonBuilder()
                .excludeFieldsWithoutExposeAnnotation()
                .registerTypeAdapter(Date.class, new DateTypeAdapter())
                .serializeSpecialFloatingPointValues()
                .create();

        Log.d(TAG, "syncLogData add Table entries count=" + entries.size() + " watch_syncLogsRequested=" + watch_syncLogsRequested);
        for (DataMap entry : entries) {
            if (entry != null) {
                String record = entry.getString("entry");
                if (record != null) {
                    UserError data = gson.fromJson(record, UserError.class);
                    if (data != null) {
                        timeOfLastEntry = (long) data.timestamp + 1;
                        if (data.shortError != null && !data.shortError.isEmpty()) { //add wear prefix
                            if (!data.shortError.startsWith("wear")) {
                                data.shortError = mPrefs.getString("wear_logs_prefix", "wear") + data.shortError;
                            }
                        }
                        UserError exists = UserError.getForTimestamp(data);
                        if (exists == null && !bBenchmark) {
                            data.save();
                            saved++;
                        }
                        else {
                            //Log.d(TAG, "syncLogData Log entry already exists with shortError=" + data.shortError + " timestamp=" + JoH.dateTimeText((long)data.timestamp));
                        }
                    }
                }
            }
        }
        if (saved>0) {
            Log.d(TAG, "syncLogData Saved timeOfLastEntry=" + JoH.dateTimeText(timeOfLastEntry) + " saved=" + saved);
        }
        else {
            Log.d(TAG, "syncLogData No records saved due to being duplicates! timeOfLastEntry=" + JoH.dateTimeText(timeOfLastEntry) + " count=" + entries.size());
        }
        sendDataReceived(DATA_ITEM_RECEIVED_PATH, "DATA_RECEIVED_LOGS count=" + entries.size(), timeOfLastEntry, bBenchmark ? "BM" : "LOG", watch_syncLogsRequested);
    }
}
 
开发者ID:NightscoutFoundation,项目名称:xDrip,代码行数:49,代码来源:WatchUpdaterService.java

示例9: onReceive

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    final PowerManager.WakeLock wl = JoH.getWakeLock("circle-message-receiver", 60000);
    try {
        DataMap dataMap;
        Bundle bundle = intent.getBundleExtra("msg");
        if (bundle != null) {
            dataMap = DataMap.fromBundle(bundle);
            String msg = dataMap.getString("msg", "");
            int length = dataMap.getInt("length", 0);
            JoH.static_toast(xdrip.getAppContext(), msg, length);
        }
        bundle = intent.getBundleExtra("steps");
        if (bundle != null) {
            dataMap = DataMap.fromBundle(bundle);
            if (mTimeStepsRcvd <= dataMap.getLong("steps_timestamp", 0)) {
                mStepsCount = dataMap.getInt("steps", 0);
                mTimeStepsRcvd = dataMap.getLong("steps_timestamp", 0);
            }
        }
        bundle = intent.getBundleExtra("data");
        if (bundle != null) {
            dataMap = DataMap.fromBundle(bundle);
            setSgvLevel((int) dataMap.getLong("sgvLevel"));
            Log.d(TAG, "CircleWatchface sgv level : " + getSgvLevel());
            setSgvString(dataMap.getString("sgvString"));
            Log.d(TAG, "CircleWatchface sgv string : " + getSgvString());
            setRawString(dataMap.getString("rawString"));
            setDelta(dataMap.getString("delta"));
            setDatetime(dataMap.getDouble("timestamp"));
            mExtraStatusLine = dataMap.getString("extra_status_line");
            addToWatchSet(dataMap);


            //start animation?
            // dataMap.getDataMapArrayList("entries") == null -> not on "resend data".
            if (sharedPrefs.getBoolean("animation", false) && dataMap.getDataMapArrayList("entries") == null && (getSgvString().equals("100") || getSgvString().equals("5.5") || getSgvString().equals("5,5"))) {
                startAnimation();
            }

            prepareLayout();
            prepareDrawTime();
            invalidate();
        }
        //status
        bundle = intent.getBundleExtra("status");
        if (bundle != null) {
            dataMap = DataMap.fromBundle(bundle);
            setStatusString(dataMap.getString("externalStatusString"));

            prepareLayout();
            prepareDrawTime();
            invalidate();
        }
    } finally {
        JoH.releaseWakeLock(wl);
    }
}
 
开发者ID:jamorham,项目名称:xDrip-plus,代码行数:59,代码来源:CircleWatchface.java


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