本文整理汇总了Java中com.google.android.gms.wearable.DataMap.keySet方法的典型用法代码示例。如果您正苦于以下问题:Java DataMap.keySet方法的具体用法?Java DataMap.keySet怎么用?Java DataMap.keySet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.wearable.DataMap
的用法示例。
在下文中一共展示了DataMap.keySet方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateUiForConfigDataMap
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void updateUiForConfigDataMap(final DataMap config) {
boolean uiUpdated = false;
for (String configKey : config.keySet()) {
if (!config.containsKey(configKey)) {
continue;
}
if(configKey.equalsIgnoreCase(WatchFaceUtil.KEY_BACKGROUND_COLOR)) {
int color = config.getInt(configKey);
Log.d(TAG, "Found watch face config key: " + configKey + " -> " + color);
if (updateUiForKey(configKey, color)) {
uiUpdated = true;
}
}
else if(configKey.equalsIgnoreCase(WatchFaceUtil.KEY_SECOND_TIMEZONE)) {
String timezoneID = config.getString(configKey);
Log.d(TAG, "Found watch face config key: " + configKey + " -> " + timezoneID);
if (updateUiForKey(configKey, timezoneID)) {
uiUpdated = true;
}
}
}
adapter.notifyDataSetChanged();
}
示例2: onDataChanged
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
for (DataEvent event : dataEvents) {
if (event.getType() == DataEvent.TYPE_CHANGED) {
// Check the data path
String path = event.getDataItem().getUri().getPath();
if (WearableApi.SETTINGS.equals(path)) {
HashMap<String, String> newSettings = new HashMap<>();
DataMap dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();
for (String key : dataMap.keySet()) {
newSettings.put(key, dataMap.getString(key, null));
PreferencesUtil.putString(this, key, newSettings.get(key));
}
WearableApi.sendMessage(mGoogleApiClient, WearableApi.SETTINGS, PreferencesUtil.toString(newSettings), null);
sendStatus(mGoogleApiClient);
}
}
}
}
示例3: updateUiForConfigDataMap
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void updateUiForConfigDataMap(final DataMap config) {
for (String configKey : config.keySet()) {
if (!config.containsKey(configKey)) {
continue;
}
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Found watch face config key: " + configKey);
}
if (Constants.KEY_WEATHER_ID.equals(configKey)) {
int weatherId = config.getInt(configKey);
PreferencesUtil.savePrefs(SunshineWatchFace.this, Constants.KEY_WEATHER_ID, weatherId);
}
if (Constants.KEY_WEATHER_TEMP_MAX.equals(configKey)) {
int weatherTempMax = config.getInt(configKey);
mMaxTemp = weatherTempMax;
PreferencesUtil.savePrefs(SunshineWatchFace.this, Constants.KEY_WEATHER_TEMP_MAX, weatherTempMax);
}
if (Constants.KEY_WEATHER_TEMP_MIN.equals(configKey)) {
int weatherTempMin = config.getInt(configKey);
mMinTemp = weatherTempMin;
PreferencesUtil.savePrefs(SunshineWatchFace.this, Constants.KEY_WEATHER_TEMP_MIN, weatherTempMin);
}
if (Constants.KEY_WEATHER_UNIT.equals(configKey)) {
String weatherUnit = config.getString(configKey);
mWeatherUnit = weatherUnit;
PreferencesUtil.savePrefs(SunshineWatchFace.this, Constants.KEY_WEATHER_UNIT, weatherUnit);
}
}
}
示例4: updateUiForConfigDataMap
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void updateUiForConfigDataMap(final DataMap config) {
boolean uiUpdated = false;
for (String configKey : config.keySet()) {
if (!config.containsKey(configKey)) {
continue;
}
if(configKey.equalsIgnoreCase(WatchFaceUtil.KEY_BACKGROUND_COLOR)) {
int color = config.getInt(configKey);
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Found watch face config key: " + configKey + " -> " + color);
}
if (updateUiForKey(configKey, color)) {
uiUpdated = true;
}
}else if(configKey.equalsIgnoreCase(WatchFaceUtil.KEY_SECOND_TIMEZONE)) {
String timeZoneId = config.getString(configKey);
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Found watch face config key: " + configKey + " -> " + timeZoneId);
}
if (updateUiForKey(configKey, timeZoneId)) {
uiUpdated = true;
}
}
}
if (uiUpdated) {
invalidate();
}
}
示例5: updateUiForConfigDataMap
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void updateUiForConfigDataMap(final DataMap config) {
boolean uiUpdated = false;
for (String configKey : config.keySet()) {
if (!config.containsKey(configKey)) {
continue;
}
if (updateUiForKey(configKey, config)) {
uiUpdated = true;
}
}
if (uiUpdated) {
invalidate();
}
}
示例6: updateUiForConfigDataMap
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void updateUiForConfigDataMap(final DataMap config) {
for (String key : config.keySet()) {
if (!config.containsKey(key)) {
Log.w(TAG, "No value found for config key:" + key);
continue;
}
switch (key) {
case ConfigurationHelper.KEY_TIME_FORMAT:
switchTimeFormat.setChecked(config.getBoolean(key));
break;
case ConfigurationHelper.KEY_DATE_NAMES:
switchDateNames.setChecked(config.getBoolean(key));
break;
case ConfigurationHelper.KEY_SHOW_SUNRISE_SUNSET:
switchShowSunriseSunset.setChecked(config.getBoolean(key));
break;
case ConfigurationHelper.KEY_INTERLACE:
switchInterlace.setChecked(config.getBoolean(key));
break;
case ConfigurationHelper.KEY_ANTIALIAS_IN_AMBIENT_MODE:
switchAntialiasInAmbientMode.setChecked(config.getBoolean(key));
break;
case ConfigurationHelper.KEY_INVERT_BLACK_AND_WHITE:
switchInvertBlackAndWhite.setChecked(config.getBoolean(key));
break;
case ConfigurationHelper.KEY_DAY_NIGHT_MODE:
switchDayNightMode.setChecked(config.getBoolean(key));
break;
case ConfigurationHelper.KEY_TWO_COLOR_BACKGROUND:
switchTwoColorBackground.setChecked(config.getBoolean(key));
break;
case ConfigurationHelper.KEY_SHOW_GOOGLE_FIT_STEPS:
switchShowGoogleFitSteps.setChecked(config.getBoolean(key));
break;
case ConfigurationHelper.KEY_SHOW_UNREAD_NOTIFICATION_COUNT:
switchShowUnreadNotificationCount.setChecked(config.getBoolean(key));
break;
case ConfigurationHelper.KEY_ENABLED_SENSORS:
ArrayList<Integer> enabledSensors = config.getIntegerArrayList(key);
Log.d(TAG, "Config enabled sensors: " + enabledSensors.toString() + " Application/Device sensors: " + sensors.toString());
for (Integer sensor : sensors) {
Switch sensorSwitch = (Switch) findViewById(sensor);
if (enabledSensors.contains(sensor)) {
setSwitchChecked(sensorSwitch, true);
} else {
setSwitchChecked(sensorSwitch, false);
}
}
break;
default:
Log.w(TAG, "Ignoring unknown config key: " + key);
break;
}
}
}
示例7: updateUiForConfigDataMap
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void updateUiForConfigDataMap(final DataMap config) {
boolean uiUpdated = false;
for (String key : config.keySet()) {
if (!config.containsKey(key)) {
Log.w(TAG, "No value found for config key:" + key);
continue;
}
switch (key) {
case ConfigurationHelper.KEY_TIME_FORMAT:
watchFace.setTimeFormat24(config.getBoolean(key));
break;
case ConfigurationHelper.KEY_DATE_NAMES:
watchFace.setShowDateNamesFormat(config.getBoolean(key));
break;
case ConfigurationHelper.KEY_SHOW_SUNRISE_SUNSET:
watchFace.showSunriseSunsetTimes(config.getBoolean(key));
break;
case ConfigurationHelper.KEY_INTERLACE:
watchFace.shouldInterlace(config.getBoolean(key));
break;
case ConfigurationHelper.KEY_ANTIALIAS_IN_AMBIENT_MODE:
watchFace.shouldAntialiasInAmbientMode(config.getBoolean(key));
break;
case ConfigurationHelper.KEY_DAY_NIGHT_MODE:
watchFace.setDayNightMode(config.getBoolean(key));
break;
case ConfigurationHelper.KEY_TWO_COLOR_BACKGROUND:
watchFace.setTwoColorBackground(config.getBoolean(key));
break;
case ConfigurationHelper.KEY_SHOW_GOOGLE_FIT_STEPS:
watchFace.showGoogleFitSteps(config.getBoolean(key));
break;
case ConfigurationHelper.KEY_INVERT_BLACK_AND_WHITE:
case ConfigurationHelper.KEY_SHOW_UNREAD_NOTIFICATION_COUNT:
watchFace.setInvertBlackAndWhite(config.getBoolean(ConfigurationHelper.KEY_INVERT_BLACK_AND_WHITE));
setWatchFaceStyle(watchFaceStyleDefaultBuilder
.setShowUnreadCountIndicator(config.getBoolean(ConfigurationHelper.KEY_SHOW_UNREAD_NOTIFICATION_COUNT))
.setViewProtectionMode(config.getBoolean(ConfigurationHelper.KEY_INVERT_BLACK_AND_WHITE) ?
WatchFaceStyle.PROTECT_STATUS_BAR | WatchFaceStyle.PROTECT_HOTWORD_INDICATOR
: WatchFaceStyle.PROGRESS_MODE_NONE)
.build());
break;
case ConfigurationHelper.KEY_ENABLED_SENSORS:
// Save new config
setAvailableSensorTypes(config.getIntegerArrayList(key));
// If new available sensor are none clear all
if (availableSensorTypes.size() == 0) {
watchFace.removeSensorsRow();
break;
}
Boolean found = false;
for (Integer availableSensorType : availableSensorTypes) {
if (watchFace.hasSensorColumn(availableSensorType)) {
found = true;
}
}
// If the current column was not found add next
if (!found) {
addSensorColumn();
}
break;
default:
Log.w(TAG, "Ignoring unknown config key: " + key);
break;
}
uiUpdated = true;
}
if (uiUpdated) {
invalidate();
}
}
示例8: saveItem
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private static void saveItem(DataItem dataItem, SharedPreferences.Editor editor, Map<String, ?> allPrefs) {
DataMap dataMap = DataMapItem.fromDataItem(dataItem).getDataMap();
if (dataMap.keySet().isEmpty()) {
// Testing has shown that, when an item is deleted from the Data API, it
// will often come through as an empty TYPE_CHANGED rather than a TYPE_DELETED
deleteItem(dataItem.getUri(), editor, allPrefs);
} else {
for (String key : dataMap.keySet()) {
Object value = dataMap.get(key);
if (value == null) {
if ((allPrefs != null) && allPrefs.containsKey(key)) {
editor.remove(key);
}
continue;
}
if ((allPrefs != null) && value.equals(allPrefs.get(key))) {
// No change to value
continue;
}
if (key.equals(KEY_TIMESTAMP)) {
continue;
}
switch (value.getClass().getSimpleName()) {
case "Boolean": {
editor.putBoolean(key, (Boolean) value);
break;
}
case "Float": {
editor.putFloat(key, (Float) value);
break;
}
case "Integer": {
editor.putInt(key, (Integer) value);
break;
}
case "Long": {
editor.putLong(key, (Long) value);
break;
}
case "String": {
editor.putString(key, (String) value);
break;
}
case "Array": {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
@SuppressWarnings("unchecked")
Set<String> strings = new HashSet<>();
Collections.addAll(strings, (String[]) value);
editor.putStringSet(key, strings);
}
break;
}
}
}
}
}