本文整理汇总了Java中com.google.android.gms.wearable.DataMap.getDataMapArrayList方法的典型用法代码示例。如果您正苦于以下问题:Java DataMap.getDataMapArrayList方法的具体用法?Java DataMap.getDataMapArrayList怎么用?Java DataMap.getDataMapArrayList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.wearable.DataMap
的用法示例。
在下文中一共展示了DataMap.getDataMapArrayList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: addToWatchSet
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
public void addToWatchSet(DataMap dataMap) {
if (d) Log.d(TAG, "addToWatchSet bgDataList.size()=" + bgDataList.size());
ArrayList<DataMap> entries = dataMap.getDataMapArrayList("entries");
if (entries != null) {
if (d) Log.d(TAG, "addToWatchSet entries.size()=" + entries.size());
for (DataMap entry : entries) {
addDataMap(entry);
}
} else {
addDataMap(dataMap);
}
for (int i = 0; i < bgDataList.size(); i++) {
if (bgDataList.get(i).timestamp < (new Date().getTime() - (1000 * 60 * 60 * 5))) {
bgDataList.remove(i); //Get rid of anything more than 5 hours old
break;
}
}
}
示例3: addToWatchSet
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
public void addToWatchSet(DataMap dataMap) {
Log.d(TAG, "addToWatchSet bgDataList.size()=" + bgDataList.size());
ArrayList<DataMap> entries = dataMap.getDataMapArrayList("entries");
if (entries != null) {
Log.d(TAG, "addToWatchSet entries.size()=" + entries.size());
for (DataMap entry : entries) {
addDataMap(entry);
}
} else {
addDataMap(dataMap);
}
for (int i = 0; i < bgDataList.size(); i++) {
if (bgDataList.get(i).timestamp < (new Date().getTime() - (1000 * 60 * 60 * 5))) {
Log.d(TAG, "addToWatchSet Remove bgDataList.get(i).timestamp: " + JoH.dateTimeText((long)bgDataList.get(i).timestamp)+ " i: " + i);
bgDataList.remove(i); //Get rid of anything more than 5 hours old
}
}
}
示例4: addToWatchSet
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
public void addToWatchSet(DataMap dataMap) {
Log.d(TAG, "addToWatchSet bgDataList.size()=" + bgDataList.size());
ArrayList<DataMap> entries = dataMap.getDataMapArrayList("entries");
if (entries != null) {
Log.d(TAG, "addToWatchSet entries.size()=" + entries.size());
for (DataMap entry : entries) {
addDataMap(entry);
}
} else {
addDataMap(dataMap);
}
for (int i = 0; i < bgDataList.size(); i++) {
if (bgDataList.get(i).timestamp < (new Date().getTime() - (1000 * 60 * 60 * 5))) {
bgDataList.remove(i); //Get rid of anything more than 5 hours old
break;
}
}
Collections.sort(bgDataList);
}
示例5: UartConfiguration
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
public UartConfiguration(final DataMap dataMap, final long id) {
name = dataMap.getString(Constants.UART.Configuration.NAME);
final ArrayList<DataMap> maps = dataMap.getDataMapArrayList(Constants.UART.Configuration.COMMANDS);
commands = new Command[maps.size()];
for (int i = 0; i < maps.size(); ++i) {
commands[i] = new Command(maps.get(i));
}
this.id = id;
}
示例6: onDataChanged
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
DataMap dataMap;
for (DataEvent event : dataEvents) {
// Check the data type
if (event.getType() == DataEvent.TYPE_CHANGED) {
// Check the data path
String path = event.getDataItem().getUri().getPath();
dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();
//get the data array list
ArrayList<DataMap> containerList=dataMap.getDataMapArrayList(Const.KEY_MEASURE_DATA);
//extract data and save each value
for (DataMap aData : containerList)
{
CustomRules rule= extractRulesFromDataMap(aData);
RulesRepository.getInstance().insertOrUpdate(rule);
}
// Broadcast DataMap contents to wearable activity for display
//Prepare data to send to the activity
Bundle bundle=new Bundle();
bundle.putString(Const.KEY_MESSAGE_TYPE,getString(R.string.sync_rules));
Intent messageIntent = new Intent();
messageIntent.setAction(Intent.ACTION_SEND);
messageIntent.putExtra(Const.BUNDLE_DATA, bundle);
//send info to activity
LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
}
}
}
示例7: onDataChanged
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
DataMap dataMap;
for (DataEvent event : dataEvents) {
// Check the data type
if (event.getType() == DataEvent.TYPE_CHANGED) {
// Check the data path
String path = event.getDataItem().getUri().getPath();
dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();
//get the data array list
ArrayList<DataMap> containerList=dataMap.getDataMapArrayList(Const.KEY_MEASURE_DATA);
//extract data and save each value
for (DataMap aData : containerList)
{
Alertes alerte= extractAlertFromDatamap(aData);
AlertesRepository.getINSTANCE().insertOrReplace(alerte);
}
// Broadcast DataMap contents to wearable activity for display
Bundle bundle=new Bundle();
bundle.putString(Const.KEY_MESSAGE_TYPE,getString(R.string.sync_alertes));
Intent messageIntent = new Intent();
messageIntent.setAction(Intent.ACTION_SEND);
messageIntent.putExtra(Const.BUNDLE_DATA, bundle);
//send info to activity
LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
}
}
}
示例8: onDataChanged
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
DataMap dataMap;
for (DataEvent event : dataEvents) {
// Check the data type
if (event.getType() == DataEvent.TYPE_CHANGED) {
// Check the data path
String path = event.getDataItem().getUri().getPath();
// if (path.equals(Const.PATH_PUSH_MEASURE)) {}
dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();
//get the data array list
ArrayList<DataMap>containerList=dataMap.getDataMapArrayList(Const.KEY_MEASURE_DATA);
//extract data and save each value
for (DataMap aData : containerList)
{
Measure measure=extractMeasureFromDataMap(aData);
MeasuresRepository.getInstance().insertOrReplace(measure);
}
// Broadcast DataMap contents to wearable activity for display
//Prepare data to send to the activity
Bundle bundle=new Bundle();
bundle.putString(Const.KEY_MESSAGE_TYPE,getString(R.string.sync_measures));
Intent messageIntent = new Intent();
messageIntent.setAction(Intent.ACTION_SEND);
messageIntent.putExtra(Const.BUNDLE_DATA, bundle);
//send info to activity
LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
}
}
}
示例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);
}
}
示例10: addToWatchSetTreats
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
public void addToWatchSetTreats(DataMap dataMap, ArrayList<BgWatchData> dataList) {
if (d) Log.d(TAG, "addToWatchSetTreats dataList.size()=" + (dataList != null ? dataList.size() : "0"));
dataList.clear();//necessary since treatments, bloodtest and calibrations can be deleted/invalidated
ArrayList<DataMap> entries = dataMap.getDataMapArrayList("entries");
if (entries != null) {
if (d) Log.d(TAG, "addToWatchSetTreats entries.size()=" + entries.size() + " entries=" + entries);
for (DataMap entry : entries) {
addDataMapTreats(entry, dataList);
}
}
if (d) Log.d(TAG, "addToWatchSetTreats dataList.size()=" + dataList.size());
}
示例11: syncStepSensorData
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private synchronized void syncStepSensorData(DataMap dataMap, boolean bBenchmark) {
Log.d(TAG, "syncStepSensorData");
ArrayList<DataMap> entries = dataMap.getDataMapArrayList("entries");
long timeOfLastEntry = 0;
Log.d(TAG, "syncStepSensorData add to Table" );
if (entries != null) {
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Date.class, new DateTypeAdapter())
.serializeSpecialFloatingPointValues()
.create();
StepCounter pm = StepCounter.last();
Log.d(TAG, "syncStepSensorData add Table entries count=" + entries.size());
for (DataMap entry : entries) {
if (entry != null) {
Log.d(TAG, "syncStepSensorData add Table entry=" + entry);
String record = entry.getString("entry");
if (record != null) {
Log.d(TAG, "syncStepSensorData add Table record=" + record);
StepCounter data = gson.fromJson(record, StepCounter.class);
if (data != null) {
timeOfLastEntry = (long) data.timestamp + 1;
Log.d(TAG, "syncStepSensorData add Entry Wear=" + data.toString());
Log.d(TAG, "syncStepSensorData WATCH data.metric=" + data.metric + " timestamp=" + JoH.dateTimeText((long) data.timestamp));
if (!bBenchmark)
data.saveit();
}
}
}
}
sendDataReceived(DATA_ITEM_RECEIVED_PATH,"DATA_RECEIVED_LOGS count=" + entries.size(), timeOfLastEntry, bBenchmark?"BM":"STEP", -1);
}
}
示例12: syncHeartSensorData
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private synchronized void syncHeartSensorData(DataMap dataMap, boolean bBenchmark) {
Log.d(TAG, "syncHeartSensorData");
ArrayList<DataMap> entries = dataMap.getDataMapArrayList("entries");
long timeOfLastEntry = 0;
Log.d(TAG, "syncHeartSensorData add to Table" );
if (entries != null) {
final Gson gson = JoH.defaultGsonInstance();
//final HeartRate pm = HeartRate.last();
Log.d(TAG, "syncHeartSensorData add Table entries count=" + entries.size());
for (DataMap entry : entries) {
if (entry != null) {
Log.d(TAG, "syncHeartSensorData add Table entry=" + entry);
String record = entry.getString("entry");
if (record != null) {
Log.d(TAG, "syncHeartSensorData add Table record=" + record);
final HeartRate data = gson.fromJson(record, HeartRate.class);
if (data != null) {
timeOfLastEntry = (long) data.timestamp + 1;
Log.d(TAG, "syncHeartSensorData add Entry Wear=" + data.toString() + " "+record);
Log.d(TAG, "syncHeartSensorData WATCH data.metric=" + data.bpm + " timestamp=" + JoH.dateTimeText((long) data.timestamp));
if (!bBenchmark)
data.saveit();
}
}
}
}
sendDataReceived(DATA_ITEM_RECEIVED_PATH,"DATA_RECEIVED_LOGS count=" + entries.size(), timeOfLastEntry, bBenchmark?"BM":"HEART", -1);
}
}
示例13: 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);
}
}
示例14: triggerGyroscopeUpdate
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void triggerGyroscopeUpdate(DataMap dataMap) {
final String GYROSCOPE_KEY = "gyroscope";
if (dataMap.containsKey(GYROSCOPE_KEY)){
ArrayList<DataMap> gyroscopeDataArrayList = dataMap.getDataMapArrayList(GYROSCOPE_KEY);
for (DataMap gyroscopeDataMap : gyroscopeDataArrayList){
float[] values = gyroscopeDataMap.getFloatArray("values");
GyroscopeData data = new GyroscopeData();
data.x = values[0];
data.y = values[1];
data.z = values[2];
gyroscopeSensorEvents.dataEvent.trigger(data);
}
}
}
示例15: syncTransmitterData
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private synchronized void syncTransmitterData(DataMap dataMap, boolean bBenchmark) {//KS
Log.d(TAG, "syncTransmitterData");
ArrayList<DataMap> entries = dataMap.getDataMapArrayList("entries");
long timeOfLastBG = 0;
Log.d(TAG, "syncTransmitterData add BgReading Table" );
if (entries != null) {
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Date.class, new DateTypeAdapter())
.serializeSpecialFloatingPointValues()
.create();
int idx = 0;
int count = entries.size();
Log.d(TAG, "syncTransmitterData add BgReading Table entries count=" + count);
for (DataMap entry : entries) {
if (entry != null) {
//Log.d(TAG, "syncTransmitterData add BgReading Table entry=" + entry);
idx++;
String bgrecord = entry.getString("bgs");
if (bgrecord != null) {//for (TransmitterData bgData : bgs) {
//Log.d(TAG, "syncTransmitterData add TransmitterData Table bgrecord=" + bgrecord);
TransmitterData bgData = gson.fromJson(bgrecord, TransmitterData.class);
//TransmitterData bgData = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create().fromJson(bgrecord, TransmitterData.class);
TransmitterData exists = TransmitterData.getForTimestamp(bgData.timestamp);
TransmitterData uuidexists = TransmitterData.findByUuid(bgData.uuid);
timeOfLastBG = bgData.timestamp + 1;
if (exists != null || uuidexists != null) {
Log.d(TAG, "syncTransmitterData BG already exists for uuid=" + bgData.uuid + " timestamp=" + bgData.timestamp + " timeString=" + JoH.dateTimeText(bgData.timestamp) + " raw_data=" + bgData.raw_data);
} else {
Log.d(TAG, "syncTransmitterData add BG; does NOT exist for uuid=" + bgData.uuid + " timestamp=" + bgData.timestamp + " timeString=" + JoH.dateTimeText(bgData.timestamp) + " raw_data=" + bgData.raw_data);
if (!bBenchmark) {
bgData.save();
//Check
if (TransmitterData.findByUuid(bgData.uuid) != null)
Log.d(TAG, "syncTransmitterData: TransmitterData was saved for uuid:" + bgData.uuid);
else {
Log.e(TAG, "syncTransmitterData: TransmitterData was NOT saved for uuid:" + bgData.uuid);
return;
}
//KS the following is from G5CollectionService processNewTransmitterData()
Sensor sensor = Sensor.currentSensor();
if (sensor == null) {
Log.e(TAG, "syncTransmitterData: No Active Sensor, Data only stored in Transmitter Data");
return;
}
//TODO : LOG if unfiltered or filtered values are zero
Sensor.updateBatteryLevel(sensor, bgData.sensor_battery_level);
Log.i(TAG, "syncTransmitterData: BG timestamp create " + Long.toString(bgData.timestamp));//android.util.Log.i
BgReading bgExists;
//KS TODO wear implements limited alerts, therefore continue to process all alerts on phone for last entry
if (count > 1 && idx < count) {
bgExists = BgReading.create(bgData.raw_data, bgData.filtered_data, this, bgData.timestamp, true);//Disable Notifications for bulk insert
}
else {
bgExists = BgReading.create(bgData.raw_data, bgData.filtered_data, this, bgData.timestamp);
}
if (bgExists != null)
Log.d(TAG, "syncTransmitterData BG GSON saved BG: " + bgExists.toS());
else
Log.e(TAG, "syncTransmitterData BG GSON NOT saved");
}
}
}
}
}
sendDataReceived(DATA_ITEM_RECEIVED_PATH,"DATA_RECEIVED_BGS count=" + entries.size(), timeOfLastBG, bBenchmark?"BM":"BG", -1);
}
}