本文整理汇总了Java中com.google.android.gms.wearable.DataMap.putDataMapArrayList方法的典型用法代码示例。如果您正苦于以下问题:Java DataMap.putDataMapArrayList方法的具体用法?Java DataMap.putDataMapArrayList怎么用?Java DataMap.putDataMapArrayList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.wearable.DataMap
的用法示例。
在下文中一共展示了DataMap.putDataMapArrayList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onConfigurationAddedOrEdited
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
/**
* Synchronizes the UART configurations between handheld and wearables.
* Call this when configuration has been created or altered.
* @return pending result
*/
public PendingResult<DataApi.DataItemResult> onConfigurationAddedOrEdited(final long id, final UartConfiguration configuration) {
if (mGoogleApiClient == null || !mGoogleApiClient.isConnected())
return null;
final PutDataMapRequest mapRequest = PutDataMapRequest.create(Constants.UART.CONFIGURATIONS + "/" + id);
final DataMap map = mapRequest.getDataMap();
map.putString(Constants.UART.Configuration.NAME, configuration.getName());
final ArrayList<DataMap> commands = new ArrayList<>(UartConfiguration.COMMANDS_COUNT);
for (Command command : configuration.getCommands()) {
if (command != null && command.isActive()) {
final DataMap item = new DataMap();
item.putInt(Constants.UART.Configuration.Command.ICON_ID, command.getIconIndex());
item.putString(Constants.UART.Configuration.Command.MESSAGE, command.getCommand());
item.putInt(Constants.UART.Configuration.Command.EOL, command.getEolIndex());
commands.add(item);
}
}
map.putDataMapArrayList(Constants.UART.Configuration.COMMANDS, commands);
final PutDataRequest request = mapRequest.asPutDataRequest();
return Wearable.DataApi.putDataItem(mGoogleApiClient, request);
}
示例2: sendNextGestureData
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
/**
* Create new Data Request and send it to the phone
*/
private void sendNextGestureData() {
PutDataMapRequest dataMapRequest = getNewSensorsDataMapRequest();
DataMap dataMap = dataMapRequest.getDataMap();
List<GestureDataHolder.EventData> nextAccelerometerData = gestureDataHolder.pollNextAccelerometerData();
if (nextAccelerometerData.size() > 0){
dataMap.putDataMapArrayList("accelerometer", convertEventsToDataMapList(nextAccelerometerData));
}
List<GestureDataHolder.EventData> nextGyroscopeData = gestureDataHolder.pollNextGyroscopeData();
if (nextGyroscopeData.size() > 0){
dataMap.putDataMapArrayList("gyroscope", convertEventsToDataMapList(nextGyroscopeData));
}
dataSender.sendData(dataMapRequest);
}
示例3: 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);
}
}
}
示例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);
}
}
示例5: pushMeasure
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void pushMeasure() {
counter = 0;
//max size of data is 200 entry so the target device will have time to proceed.
maxSize = 200;
int index = 0;
//get all the measure
List<Measure> allMeasure = MeasuresRepository.getInstance().getAll();
//prepare the data container
int datasize=allMeasure.size();
while (index < datasize) {
try {
Thread.sleep(sleepTime);
} catch (InterruptedException ex) {
}
DataMap data_container = new DataMap();
//create the arrayList that will contains all data
ArrayList<DataMap> containerList = new ArrayList<>();
for (int i = index; i < datasize; i++) {
index++;
counter++;
Measure aMeasure = allMeasure.get(i);
DataMap data = generateDataMap(aMeasure);
containerList.add(data);
if (counter >= maxSize) {
counter = 0;
break;
}
}
//add the list to the data_container
data_container.putDataMapArrayList(Const.KEY_MEASURE_DATA, containerList);
//send the data container to the data layer
new SendToDataLayerThread(googleClient, Const.PATH_PUSH_MEASURE, data_container).start();
}
}
示例6: 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;
}
示例7: 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;
}
示例8: resendData
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
public static void resendData(Context context, int battery) {//KS
Log.d("BgSendQueue", "resendData enter battery=" + battery);
long startTime = new Date().getTime() - (60000 * 60 * 24);
Intent messageIntent = new Intent();
messageIntent.setAction(Intent.ACTION_SEND);
messageIntent.putExtra("message", "ACTION_G5BG");
BgReading last_bg = BgReading.last();
if (last_bg != null) {
Log.d("BgSendQueue", "resendData last_bg.timestamp:" + JoH.dateTimeText(last_bg.timestamp));
}
List<BgReading> graph_bgs = BgReading.latestForGraph(60, startTime);
BgGraphBuilder bgGraphBuilder = new BgGraphBuilder(context.getApplicationContext());
if (!graph_bgs.isEmpty()) {
Log.d("BgSendQueue", "resendData graph_bgs size=" + graph_bgs.size());
final ArrayList<DataMap> dataMaps = new ArrayList<>(graph_bgs.size());
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
DataMap entries = dataMap(last_bg, sharedPrefs, bgGraphBuilder, context, battery);
for (BgReading bg : graph_bgs) {
dataMaps.add(dataMap(bg, sharedPrefs, bgGraphBuilder, context, battery));
}
entries.putDataMapArrayList("entries", dataMaps);
if (sharedPrefs.getBoolean("extra_status_line", false)) {
//messageIntent.putExtra("extra_status_line", extraStatusLine(sharedPrefs));
entries.putString("extra_status_line", extraStatusLine(sharedPrefs));
}
Log.d("BgSendQueue", "resendData entries=" + entries);
messageIntent.putExtra("data", entries.toBundle());
DataMap stepsDataMap = getSensorSteps(sharedPrefs);
if (stepsDataMap != null) {
messageIntent.putExtra("steps", stepsDataMap.toBundle());
}
LocalBroadcastManager.getInstance(context).sendBroadcast(messageIntent);
}
}
示例9: getTreatments
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
public static DataMap getTreatments(long startTime) {
Treatments last = Treatments.last();
if (last != null) {
Log.d(TAG, "getTreatments last.timestamp:" + JoH.dateTimeText(last.timestamp));
}
List<Treatments> graph = Treatments.latestForGraph(60, startTime);
if (!graph.isEmpty()) {
Log.d(TAG, "getTreatments graph size=" + graph.size());
final ArrayList<DataMap> dataMaps = new ArrayList<>(graph.size());
DataMap entries = null;
//if (includeTreatment(last)) entries = dataMapForWatchface(last);
for (Treatments data : graph) {
if (includeTreatment(data)) {
if (entries == null) {
entries = dataMapForWatchface(data);
dataMaps.add(dataMapForWatchface(data));
}
else
dataMaps.add(dataMapForWatchface(data));
}
}
if (entries != null) {
entries.putDataMapArrayList("entries", dataMaps);
Log.d(TAG, "getTreatments entries=" + entries);
}
return entries;
}
else return null;
}
示例10: getCalibrations
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
public static DataMap getCalibrations(long startTime) {
Calibration last = Calibration.last();
if (last != null) {
Log.d(TAG, "getCalibrations last.timestamp:" + JoH.dateTimeText(last.timestamp));
}
List<Calibration> graph = Calibration.latestForGraph(60, startTime, Long.MAX_VALUE);
//calibrations = Calibration.latestForGraph(numValues, start - (3 * Constants.DAY_IN_MS), end);
if (!graph.isEmpty()) {
Log.d(TAG, "getCalibrations graph size=" + graph.size());
final ArrayList<DataMap> dataMaps = new ArrayList<>(graph.size());
DataMap entries = null;
//if (last.slope_confidence != 0) entries = dataMapForWatchface(last);
for (Calibration data : graph) {
if (data.slope_confidence != 0) {
if (entries == null) {
entries = dataMapForWatchface(data);
dataMaps.add(dataMapForWatchface(data));
}
else
dataMaps.add(dataMapForWatchface(data));
}
}
if (entries != null) {
entries.putDataMapArrayList("entries", dataMaps);
Log.d(TAG, "getCalibrations entries=" + entries);
}
return entries;
}
else return null;
}
示例11: resendData
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void resendData() {
if (googleApiClient != null && !googleApiClient.isConnected() && !googleApiClient.isConnecting()) {
googleApiConnect();
}
long startTime = System.currentTimeMillis() - (long) (60000 * 60 * 5.5);
BgReading last_bg = DatabaseHelper.lastBg();
if (last_bg == null) return;
List<BgReading> graph_bgs = MainApp.getDbHelper().getBgreadingsDataFromTime(startTime, true);
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
if (!graph_bgs.isEmpty()) {
DataMap entries = dataMapSingleBG(last_bg, glucoseStatus);
if (entries == null) {
ToastUtils.showToastInUiThread(this, getString(R.string.noprofile));
return;
}
final ArrayList<DataMap> dataMaps = new ArrayList<>(graph_bgs.size());
for (BgReading bg : graph_bgs) {
DataMap dataMap = dataMapSingleBG(bg, glucoseStatus);
if (dataMap != null) {
dataMaps.add(dataMap);
}
}
entries.putDataMapArrayList("entries", dataMaps);
new SendToDataLayerThread(WEARABLE_DATA_PATH, googleApiClient).execute(entries);
}
sendPreferences();
sendBasals();
sendStatus();
}
示例12: getWearHeartSensorData
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
public static synchronized DataMap getWearHeartSensorData(int count, long last_send_time, int min_count) {
UserError.Log.d(TAG, "getWearHeartSensorData last_send_time:" + JoH.dateTimeText(last_send_time));
if ((count !=0) || (JoH.ratelimit("heartrate-datamap",5))) {
HeartRate last_log = HeartRate.last();
if (last_log != null) {
UserError.Log.d(TAG, "getWearHeartSensorData last_log.timestamp:" + JoH.dateTimeText((long) last_log.timestamp));
} else {
UserError.Log.d(TAG, "getWearHeartSensorData HeartRate.last() = null:");
return null;
}
if (last_log != null && last_send_time <= last_log.timestamp) {//startTime
long last_send_success = last_send_time;
UserError.Log.d(TAG, "getWearHeartSensorData last_send_time < last_bg.timestamp:" + JoH.dateTimeText((long) last_log.timestamp));
List<HeartRate> logs = HeartRate.latestForGraph(count, last_send_time);
if (!logs.isEmpty() && logs.size() > min_count) {
DataMap entries = dataMap(last_log);
final ArrayList<DataMap> dataMaps = new ArrayList<>(logs.size());
for (HeartRate log : logs) {
dataMaps.add(dataMap(log));
last_send_success = (long) log.timestamp;
}
entries.putLong("time", JoH.tsl()); // MOST IMPORTANT LINE FOR TIMESTAMP
entries.putDataMapArrayList("entries", dataMaps);
UserError.Log.i(TAG, "getWearHeartSensorData SYNCED up to " + JoH.dateTimeText(last_send_success) + " count = " + logs.size());
return entries;
} else
UserError.Log.i(TAG, "getWearHeartSensorData SYNCED up to " + JoH.dateTimeText(last_send_success) + " count = 0");
}
return null;
} else {
UserError.Log.d(TAG,"Ratelimitted getWearHeartSensorData");
return null;
}
}
示例13: getWearStepSensorData
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private synchronized DataMap getWearStepSensorData(int count, long last_send_time, int min_count) {//final int sensorType, final int accuracy, final long timestamp, final float[] values) {
forceGoogleApiConnect();
Log.d(TAG, "getWearStepSensorData last_send_time:" + JoH.dateTimeText(last_send_time));
PebbleMovement last_log = PebbleMovement.last();
if (last_log != null) {
Log.d(TAG, "getWearStepSensorData last_log.timestamp:" + JoH.dateTimeText((long) last_log.timestamp));
}
else {
Log.d(TAG, "getWearStepSensorData PebbleMovement.last() = null:");
}
if (last_log != null && last_send_time <= last_log.timestamp) {//startTime
long last_send_success = last_send_time;
Log.d(TAG, "getWearStepSensorData last_send_time < last_bg.timestamp:" + JoH.dateTimeText((long) last_log.timestamp));
List<PebbleMovement> logs = PebbleMovement.latestForGraph(count, last_send_time);
if (!logs.isEmpty() && logs.size() > min_count) {
//Log.d(TAG, "getWearStepSensorData count = " + logs.size());
DataMap entries = dataMap(last_log);
final ArrayList<DataMap> dataMaps = new ArrayList<>(logs.size());
for (PebbleMovement log : logs) {
dataMaps.add(dataMap(log));
last_send_success = (long)log.timestamp;
//Log.d(TAG, "getWearStepSensorData set last_send_sucess:" + JoH.dateTimeText(last_send_success) + " pw.metric: " + log.metric + " pw.timestamp: " + JoH.dateTimeText(log.timestamp));
}
entries.putLong("time", new Date().getTime()); // MOST IMPORTANT LINE FOR TIMESTAMP
entries.putDataMapArrayList("entries", dataMaps);
//Log.d(TAG, "getWearStepSensorData entries:" + entries);
Log.i(TAG, "getWearStepSensorData SYNCED steps up to " + JoH.dateTimeText(last_send_success) + " count = " + logs.size());
return entries;
} else
Log.i(TAG, "getWearStepSensorData SYNCED steps up to " + JoH.dateTimeText(last_send_success) + " count = 0");
}
return null;
}
示例14: getWearTreatmentsData
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private synchronized DataMap getWearTreatmentsData(int count, long last_send_time, int min_count) {
forceGoogleApiConnect();
Log.d(TAG, "getWearTreatmentsData last_send_time:" + JoH.dateTimeText(last_send_time) + " max count=" + count + " min_count=" + min_count);
Treatments last_log = Treatments.lastSystime();
if (last_log != null) {
Log.d(TAG, "getWearTreatmentsData last systimestamp: " + last_log.systimestamp + " " + JoH.dateTimeText((long) last_log.systimestamp));
}
if (last_log != null && last_log.systimestamp > 0 && last_send_time <= last_log.systimestamp) {//startTime
long last_send_success = last_send_time;
Log.d(TAG, "getWearTreatmentsData last_send_time < last_log.timestamp:" + JoH.dateTimeText((long) last_log.systimestamp));
List<Treatments> logs = Treatments.latestForGraphSystime(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 (Treatments log : logs) {
dataMaps.add(dataMap(log));
last_send_success = (long)log.systimestamp;
//Log.d(TAG, "getWearTreatmentsData set last_send_sucess:" + JoH.dateTimeText(last_send_sucess) + " Log:" + log.toString());
}
entries.putLong("time", new Date().getTime()); // MOST IMPORTANT LINE FOR TIMESTAMP
entries.putDataMapArrayList("entries", dataMaps);
Log.i(TAG, "getWearTreatmentsData SYNCED treatments up to " + JoH.dateTimeText(last_send_success) + " count = " + logs.size());
return entries;
} else
Log.i(TAG, "getWearTreatmentsData SYNCED treatments up to " + JoH.dateTimeText(last_send_success) + " count = 0");
}
return null;
}
示例15: pushRules
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
/**
* Pushes the rules to the smartphon
*/
private void pushRules()
{
counter = 0;
maxSize = 200;
int index = 0;
sleepTime=1000;
//get all the measure
List<CustomRules> rulesList = RulesRepository.getInstance().getAll();
//prepare the data container
int datasize=rulesList.size();
while (index < datasize) {
try {
Thread.sleep(sleepTime);
} catch (InterruptedException ex) {
}
DataMap data_container = new DataMap();
//create the arrayList that will contains all data
ArrayList<DataMap> containerList = new ArrayList<>();
for (int i = index; i < datasize; i++) {
index++;
counter++;
CustomRules aRule = rulesList.get(i);
DataMap data = generateDataMap(aRule);
containerList.add(data);
if (counter >= maxSize) {
counter = 0;
break;
}
}
//add the list to the data_container
data_container.putDataMapArrayList(Const.KEY_MEASURE_DATA, containerList);
//send the data container to the data layer
new SendToDataLayerThread(googleClient, Const.PATH_PUSH_RULE, data_container).start();
}
}