当前位置: 首页>>代码示例>>Java>>正文


Java DataMap.keySet方法代码示例

本文整理汇总了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();
}
 
开发者ID:marcouberti,项目名称:adrenaline_watch_face,代码行数:26,代码来源:WatchFaceCompanionConfigActivity.java

示例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);
            }
        }
    }
}
 
开发者ID:pimpimmi,项目名称:LibreAlarm,代码行数:22,代码来源:DataLayerListenerService.java

示例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);
                }
            }
        }
 
开发者ID:mladenbabic,项目名称:Advanced_Android_Development_Wear,代码行数:37,代码来源:SunshineWatchFace.java

示例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();
    }
}
 
开发者ID:marcouberti,项目名称:adrenaline_watch_face,代码行数:30,代码来源:SonicBoomFace.java

示例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();
    }
}
 
开发者ID:passiondroid,项目名称:SunshineApp,代码行数:15,代码来源:WatchFace.java

示例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;
        }
    }
}
 
开发者ID:jimmykane,项目名称:Athletica,代码行数:56,代码来源:ConfigurationActivity.java

示例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();
    }
}
 
开发者ID:jimmykane,项目名称:Athletica,代码行数:75,代码来源:WatchFaceService.java

示例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;
                }
            }
        }
    }
}
 
开发者ID:StringMon,项目名称:prefsyncservice,代码行数:59,代码来源:PrefSyncService.java


注:本文中的com.google.android.gms.wearable.DataMap.keySet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。