本文整理匯總了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();
}
示例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);
}
}
}
示例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();
}
示例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);
}
}
}
示例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();
}
示例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");
}
}
}
示例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();
}
}
}
}
示例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);
}
}
}
示例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();
}
}
示例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", "");
}
示例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);
}
}
示例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();
}
}
}
}
示例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;
}
示例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;
}
示例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)];
}