當前位置: 首頁>>代碼示例>>Java>>正文


Java DataMap.getInt方法代碼示例

本文整理匯總了Java中com.google.android.gms.wearable.DataMap.getInt方法的典型用法代碼示例。如果您正苦於以下問題:Java DataMap.getInt方法的具體用法?Java DataMap.getInt怎麽用?Java DataMap.getInt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.android.gms.wearable.DataMap的用法示例。


在下文中一共展示了DataMap.getInt方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onDataChanged

import com.google.android.gms.wearable.DataMap; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
    Log.d(LOG_TAG, " in data changed");
    for (DataEvent event : dataEvents) {
        if (event.getType() == DataEvent.TYPE_CHANGED) {
            // DataItem changed
            DataItem item = event.getDataItem();
            if (item.getUri().getPath().compareTo(WEATHER_PATH) == 0) {
                DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();
                weather_id = dataMap.getInt(WEATHER_ID);
                high_temp = dataMap.getDouble(HIGH_TEMP);
                low_temp = dataMap.getDouble(LOW_TEMP);
            }
        } else if (event.getType() == DataEvent.TYPE_DELETED) {
            // DataItem deleted
        }
    }
    invalidate();
}
 
開發者ID:rashikaranpuria,項目名稱:ubiquitous,代碼行數:20,代碼來源:MyWatchFace.java

示例2: onDataChanged

import com.google.android.gms.wearable.DataMap; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {

    for (int i = 0; i < dataEvents.getCount(); i++) {
        DataEvent event = dataEvents.get(i);

        if (event.getType() == DataEvent.TYPE_CHANGED &&
                event.getDataItem().getUri().getPath().equals(APP_DATA_UPDATE_REQUEST)) {
            DataMap dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();

            Asset asset = dataMap.getAsset("dataIcon");
            WatchFaceService.highTemp = dataMap.getInt("dataHigh");
            WatchFaceService.lowTemp = dataMap.getInt("dataLow");

            doLoadBitmap(asset);
        }
    }
}
 
開發者ID:hieple7985,項目名稱:nano-go-ubiquitous,代碼行數:19,代碼來源:SunshineWearListenerService.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: syncSensorData

import com.google.android.gms.wearable.DataMap; //導入方法依賴的package包/類
private void syncSensorData(DataMap dataMap, Context context) {//KS
    Log.d(TAG, "syncSensorData");
    if (dataMap != null) {
        String uuid = dataMap.getString("uuid");
        Log.d(TAG, "syncSensorData add Sensor for uuid=" + uuid);
        long started_at = dataMap.getLong("started_at");
        Integer latest_battery_level = dataMap.getInt("latest_battery_level");
        String sensor_location = dataMap.getString("sensor_location");
        Sensor.InitDb(context);//ensure database has already been initialized
        if (uuid != null && !uuid.isEmpty()) {
            Log.d(TAG, "syncSensorData add Sensor for uuid=" + uuid + " timestamp=" + started_at + " timeString=" +  JoH.dateTimeText(started_at));
            Sensor sensor = Sensor.getByUuid(uuid);
            if (sensor == null) {
                Log.d(TAG, "syncSensorData createUpdate new Sensor...");
                Sensor.createUpdate(started_at, 0, latest_battery_level, sensor_location, uuid);
                Sensor newsensor = Sensor.currentSensor();
                if (newsensor != null) {
                    Log.d(TAG, "syncSensorData createUpdate Sensor with uuid=" + uuid + " started at=" + started_at);
                } else
                    Log.d(TAG, "syncSensorData Failed to createUpdate new Sensor for uuid=" + uuid);
            } else
                Log.d(TAG, "syncSensorData Sensor already exists with uuid=" + uuid);
        }
    }
}
 
開發者ID:NightscoutFoundation,項目名稱:xDrip,代碼行數:26,代碼來源:ListenerService.java

示例5: onDataChanged

import com.google.android.gms.wearable.DataMap; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEventBuffer) {
    Log.d(TAG, "onDataChanged");
    for (DataEvent event : dataEventBuffer) {
        if (event.getType() == DataEvent.TYPE_CHANGED) {
            // DataItem changed
            DataItem item = event.getDataItem();
            String path = item.getUri().getPath();
            Log.d(TAG, "path: " + path);

            if (path.equals(REQ_PATH)) {
                DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();

                mWeatherId = dataMap.getInt(KEY_WEATHER_ID);
                mMaxTemperature = dataMap.getDouble(KEY_TEMP_MAX);
                mMinTemperature = dataMap.getDouble(KEY_TEMP_MIN);
                mLocation = dataMap.getString(KEY_LOCATION);

                invalidate();
            }
        }
    }

    dataEventBuffer.release();
}
 
開發者ID:pmatushkin,項目名稱:Sunshine.Wear,代碼行數:26,代碼來源:SunshineWatchFace.java

示例6: onDataChanged

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

    Log.d("test", "onDataChanged is called !!!");

    for (DataEvent event : dataEventBuffer) {
        DataItem item = event.getDataItem();
        if (item.getUri().getPath().compareTo("/weather") == 0) {
            DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();
            if (dataMap.getInt("highTemp") != 0) {
                int highTemp_notformatted = dataMap.getInt("highTemp");
                highTemp = "" + highTemp_notformatted + "°";

                Log.d("Test", "hight Temp: " + highTemp);
            }
            if (dataMap.getInt("lowTemp") != 0) {
                int lowTemp_notformatted = dataMap.getInt("lowTemp");
                lowTemp = "" + lowTemp_notformatted + "°";

                Log.d("Test", "low Temp: " + lowTemp);
            }
            if (dataMap.getInt("weatherId") != 0) {
                weatherId = dataMap.getInt("weatherId");

                Log.d("Test", "weatherId: " + weatherId);
            }
            invalidate();
        } else {
            Log.d("test", "Can not parse data sent from mobile");
        }
    }
}
 
開發者ID:changja88,項目名稱:Android_Sunshine_Watch,代碼行數:33,代碼來源:MyWatchFace.java

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

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

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

示例10: setWatchStatus

import com.google.android.gms.wearable.DataMap; //導入方法依賴的package包/類
public static void setWatchStatus(DataMap dataMap) {
    lastStateWatch = dataMap.getString("lastState", "");
    last_transmitter_DataWatch = new TransmitterData();
    last_transmitter_DataWatch.timestamp = dataMap.getLong("timestamp", 0);
    mStaticStateWatch = dataMap.getInt("mStaticState", 0);
    last_battery_level_watch = dataMap.getInt("last_battery_level", -1);
    retry_time_watch = dataMap.getLong("retry_time", 0);
    failover_time_watch = dataMap.getLong("failover_time", 0);
    static_last_hexdump_watch = dataMap.getString("static_last_hexdump", "");
    static_last_sent_hexdump_watch = dataMap.getString("static_last_sent_hexdump", "");
}
 
開發者ID:NightscoutFoundation,項目名稱:xDrip,代碼行數:12,代碼來源:DexCollectionService.java

示例11: onReceive

import com.google.android.gms.wearable.DataMap; //導入方法依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
    final PowerManager.WakeLock wl = JoH.getWakeLock("circle-message-receiver", 60000);
    try {
        DataMap dataMap;
        Bundle bundle = intent.getBundleExtra("msg");
        if (bundle != null) {
            dataMap = DataMap.fromBundle(bundle);
            String msg = dataMap.getString("msg", "");
            int length = dataMap.getInt("length", 0);
            JoH.static_toast(xdrip.getAppContext(), msg, length);
        }
        bundle = intent.getBundleExtra("steps");
        if (bundle != null) {
            dataMap = DataMap.fromBundle(bundle);
            if (mTimeStepsRcvd <= dataMap.getLong("steps_timestamp", 0)) {
                mStepsCount = dataMap.getInt("steps", 0);
                mTimeStepsRcvd = dataMap.getLong("steps_timestamp", 0);
            }
        }
        bundle = intent.getBundleExtra("data");
        if (bundle != null) {
            dataMap = DataMap.fromBundle(bundle);
            setSgvLevel((int) dataMap.getLong("sgvLevel"));
            Log.d(TAG, "CircleWatchface sgv level : " + getSgvLevel());
            setSgvString(dataMap.getString("sgvString"));
            Log.d(TAG, "CircleWatchface sgv string : " + getSgvString());
            setRawString(dataMap.getString("rawString"));
            setDelta(dataMap.getString("delta"));
            setDatetime(dataMap.getDouble("timestamp"));
            mExtraStatusLine = dataMap.getString("extra_status_line");
            addToWatchSet(dataMap);


            //start animation?
            // dataMap.getDataMapArrayList("entries") == null -> not on "resend data".
            if (sharedPrefs.getBoolean("animation", false) && dataMap.getDataMapArrayList("entries") == null && (getSgvString().equals("100") || getSgvString().equals("5.5") || getSgvString().equals("5,5"))) {
                startAnimation();
            }

            prepareLayout();
            prepareDrawTime();
            invalidate();
        }
        //status
        bundle = intent.getBundleExtra("status");
        if (bundle != null) {
            dataMap = DataMap.fromBundle(bundle);
            setStatusString(dataMap.getString("externalStatusString"));

            prepareLayout();
            prepareDrawTime();
            invalidate();
        }
    } finally {
        JoH.releaseWakeLock(wl);
    }
}
 
開發者ID:NightscoutFoundation,項目名稱:xDrip,代碼行數:59,代碼來源:CircleWatchface.java

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

示例13: decodeInteractionTypeMessage

import com.google.android.gms.wearable.DataMap; //導入方法依賴的package包/類
public static int decodeInteractionTypeMessage(DataItem dataItem) {
    int interactionBitfield = InteractionType.NONE;
    if (MESSAGE_TYPE.INTERACTION_TYPE.equals(getMessageType(dataItem))) {
        DataMap dataMap = DataMap.fromByteArray(dataItem.getData());
        interactionBitfield =  dataMap.getInt(VALUE_STR);
    }

    return interactionBitfield;
}
 
開發者ID:Parrot-Developers,項目名稱:DronesWear,代碼行數:10,代碼來源:Message.java

示例14: decodeActionTypeMessage

import com.google.android.gms.wearable.DataMap; //導入方法依賴的package包/類
public static int decodeActionTypeMessage(DataItem dataItem) {
    int actionType = -1;
    if (MESSAGE_TYPE.ACTION_TYPE.equals(getMessageType(dataItem))) {
        DataMap dataMap = DataMap.fromByteArray(dataItem.getData());
        actionType =  dataMap.getInt(VALUE_STR);
    }

    return actionType;
}
 
開發者ID:Parrot-Developers,項目名稱:DronesWear,代碼行數:10,代碼來源:Message.java

示例15: Command

import com.google.android.gms.wearable.DataMap; //導入方法依賴的package包/類
Command(final DataMap dataMap) {
	icon = Icon.values()[dataMap.getInt(Constants.UART.Configuration.Command.ICON_ID)];
	command = dataMap.getString(Constants.UART.Configuration.Command.MESSAGE);
	eol = Eol.values()[dataMap.getInt(Constants.UART.Configuration.Command.EOL)];
}
 
開發者ID:runtimeco,項目名稱:Android-DFU-App,代碼行數:6,代碼來源:Command.java


注:本文中的com.google.android.gms.wearable.DataMap.getInt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。