當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。