當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。