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


Java DataMap.containsKey方法代码示例

本文整理汇总了Java中com.google.android.gms.wearable.DataMap.containsKey方法的典型用法代码示例。如果您正苦于以下问题:Java DataMap.containsKey方法的具体用法?Java DataMap.containsKey怎么用?Java DataMap.containsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.gms.wearable.DataMap的用法示例。


在下文中一共展示了DataMap.containsKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: triggerAccelerometerUpdate

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void triggerAccelerometerUpdate(DataMap dataMap){

        final String ACCELEROMETER_KEY = "accelerometer";

        if (dataMap.containsKey(ACCELEROMETER_KEY)){
            ArrayList<DataMap> accelerometerDataArrayList = dataMap.getDataMapArrayList(ACCELEROMETER_KEY);

            for (DataMap accelerometerDataMap : accelerometerDataArrayList){

                float[] values = accelerometerDataMap.getFloatArray("values");

                AccelerometerData data = new AccelerometerData();
                data.x = values[0];
                data.y = values[1];
                data.z = values[2];

                accelerometerSensorEvents.dataEvent.trigger(data);
            }
        }
    }
 
开发者ID:ibm-wearables-sdk-for-mobile,项目名称:ibm-wearables-android-sdk,代码行数:21,代码来源:AndroidWear.java

示例2: processData

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void processData(DataItem item) {
    if (START_ACTIVITY_PATH.equals(item.getUri().getPath())) {
        DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();

        if (dataMap.containsKey("max")) {
            mWatchMaxTemp = dataMap.getString("max");
        }

        if (dataMap.containsKey("min")) {
            mWatchMinTemp = dataMap.getString("min");
        }
        if (dataMap.containsKey("id")) {
            int resid=getArtResourceForWeatherCondition(dataMap.getInt("id"));
            mWatchBitmap=  BitmapFactory.decodeResource(getResources(), resid);
            mWatchBitmap=Bitmap.createScaledBitmap(mWatchBitmap, (int) mTextPaint.getTextSize(), (int)mTextPaint.getTextSize(), false);
        }
        mWatchTemp=mWatchMaxTemp+" "+mWatchMinTemp;
    }
}
 
开发者ID:oscarbujinkan,项目名称:Go-Ubiquitous,代码行数:20,代码来源:SunshineWatchFace.java

示例3: 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

示例4: onDataChanged

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
@Override
public void onDataChanged(DataEventBuffer dataEventBuffer) {


    for (DataEvent dataEvent:dataEventBuffer){
        if (dataEvent.getType()==DataEvent.TYPE_CHANGED){
            DataMap dataMap= DataMapItem.fromDataItem(dataEvent.getDataItem()).getDataMap();
            String path=dataEvent.getDataItem().getUri().getPath();
            if (path.equals(NOTIFICATION_PATH)){

                if (dataMap.containsKey(HIGH_TEMP_KEY)){
                    mHighTemp = dataMap.getString(HIGH_TEMP_KEY);
                }else{
                    mHighTemp=NOT_FOUND_HIGH_TEMP;
                }


                if (dataMap.containsKey(LOW_TEMP_KEY)){
                    mLowTemp = dataMap.getString(LOW_TEMP_KEY);
                }else{
                    mLowTemp=NOT_FOUND_LOW_TEMP;
                }

                if (dataMap.containsKey(WEATHER_ID_KEY)){
                    mWeatherId = dataMap.getInt(WEATHER_ID_KEY);
                }else{
                    mWeatherId=NOT_FOUND_WEATHER_ID;
                }

                saveReceivedValues();
            }
        }
    }
}
 
开发者ID:gmontoya2483,项目名称:GoUbiquitous,代码行数:35,代码来源:WatchInterfaceService.java

示例5: 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

示例6: trigerHeartRateUpdate

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void trigerHeartRateUpdate(DataMap dataMap) {
    final String HEART_RATE_KEY = "heartrate";

    if (dataMap.containsKey(HEART_RATE_KEY)){
        float heartRate = dataMap.getFloat(HEART_RATE_KEY);

        HeartRateData data = new HeartRateData(heartRate);
        heartRateSensorEvents.dataEvent.trigger(data);
    }
}
 
开发者ID:ibm-wearables-sdk-for-mobile,项目名称:ibm-wearables-android-sdk,代码行数:11,代码来源:AndroidWear.java

示例7: 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

示例8: onDataChanged

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
@Override
public void onDataChanged(DataEventBuffer dataEventBuffer) {
   for (DataEvent dataEvent : dataEventBuffer) {
        if (dataEvent.getType() == DataEvent.TYPE_CHANGED){
            DataItem dataItem = dataEvent.getDataItem();
            if (dataItem.getUri().getPath().equals(KEY_PATH)) {
                DataMap dataMap = DataMapItem.fromDataItem(dataItem).getDataMap();

                if (dataMap.containsKey(KEY_WEATHER_ID)) {

                    int weatherId = dataMap.getInt(KEY_WEATHER_ID);
                    Drawable b = getResources().getDrawable(getArtResourceForWeatherCondition(weatherId));
                    Bitmap icon = ((BitmapDrawable) b).getBitmap();
                    float scaledWidth = (mMaxTempPaint.getTextSize() / icon.getHeight()) * icon.getWidth();
                    mWeatherArt = Bitmap.createScaledBitmap(icon, (int) scaledWidth, (int) mMaxTempPaint.getTextSize(), true);
                }

                if (dataMap.containsKey(KEY_MAX_TEMP)) {
                    mMaxTemp = dataMap.getString(KEY_MAX_TEMP);
                }
                if (dataMap.containsKey(KEY_MIN_TEMP)) {
                    mMinTemp = dataMap.getString(KEY_MIN_TEMP);
                }

                Log.d(LOG_TAG, "weatherId" +dataMap.getInt(KEY_WEATHER_ID));
                Log.d(LOG_TAG, "mMaxTemp" +dataMap.getString(KEY_MAX_TEMP));
                Log.d(LOG_TAG, "mMinTemp" +dataMap.getString(KEY_MIN_TEMP));
                invalidate();
            }
        }
    }
}
 
开发者ID:jenniferlimtan,项目名称:UdacityProject6,代码行数:33,代码来源:SunshineWatchFace.java

示例9: 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

示例10: addIntKeyIfMissing

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void addIntKeyIfMissing(DataMap config, String key, int color) {
    if (!config.containsKey(key)) {
        config.putInt(key, color);
    }
}
 
开发者ID:mladenbabic,项目名称:Advanced_Android_Development_Wear,代码行数:6,代码来源:SunshineWatchFace.java

示例11: addBooleanKeyIfMissing

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void addBooleanKeyIfMissing(DataMap config, String key, boolean value) {
    if (!config.containsKey(key)) {
        config.putBoolean(key, value);
    }
}
 
开发者ID:mladenbabic,项目名称:Advanced_Android_Development_Wear,代码行数:6,代码来源:SunshineWatchFace.java

示例12: addStringKeyIfMissing

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void addStringKeyIfMissing(DataMap config, String key, String value) {
    if (!config.containsKey(key)) {
        config.putString(key, value);
    }
}
 
开发者ID:mladenbabic,项目名称:Advanced_Android_Development_Wear,代码行数:6,代码来源:SunshineWatchFace.java

示例13: 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);
            }
        }
    }
 
开发者ID:ibm-wearables-sdk-for-mobile,项目名称:ibm-wearables-android-sdk,代码行数:22,代码来源:AndroidWear.java

示例14: 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

示例15: addBooleanKeyIfMissing

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private static void addBooleanKeyIfMissing(DataMap config, String key, Boolean value) {
    if (!config.containsKey(key)) {
        config.putBoolean(key, value);
    }
}
 
开发者ID:jimmykane,项目名称:Athletica,代码行数:6,代码来源:ConfigurationHelper.java


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