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