本文整理汇总了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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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();
}
}
}
示例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", "");
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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);
}
}