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


Java DataMapItem类代码示例

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


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

示例1: onDataChanged

import com.google.android.gms.wearable.DataMapItem; //导入依赖的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: populateConfigurations

import com.google.android.gms.wearable.DataMapItem; //导入依赖的package包/类
/**
 * This method read the UART configurations from the DataApi and populates the adapter with them.
 */
private void populateConfigurations() {
	if (mGoogleApiClient.isConnected()) {
		final PendingResult<DataItemBuffer> results = Wearable.DataApi.getDataItems(mGoogleApiClient, Uri.parse("wear:" + Constants.UART.CONFIGURATIONS), DataApi.FILTER_PREFIX);
		results.setResultCallback(new ResultCallback<DataItemBuffer>() {
			@Override
			public void onResult(final DataItemBuffer dataItems) {
				final List<UartConfiguration> configurations = new ArrayList<>(dataItems.getCount());
				for (int i = 0; i < dataItems.getCount(); ++i) {
					final DataItem item = dataItems.get(i);
					final long id = ContentUris.parseId(item.getUri());
					final DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();
					final UartConfiguration configuration = new UartConfiguration(dataMap, id);
					configurations.add(configuration);
				}
				mAdapter.setConfigurations(configurations);
				dataItems.release();
			}
		});
	}
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:24,代码来源:UARTConfigurationsActivity.java

示例3: onDataChanged

import com.google.android.gms.wearable.DataMapItem; //导入依赖的package包/类
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
    LOGD(TAG, "onDataChanged: " + dataEvents + " for " + getPackageName());

    for (DataEvent event : dataEvents) {
        LOGD(TAG, "Uri is: " + event.getDataItem().getUri());
        DataMapItem mapItem = DataMapItem.fromDataItem(event.getDataItem());
        String path = event.getDataItem().getUri().getPath();
        if (event.getType() == DataEvent.TYPE_CHANGED) {
            if (PATH_RESPONSE.equals(path)) {
                // we have a response
                DataMap data = mapItem.getDataMap();
                saveFeedback(data);
            }
        } else if (event.getType() == DataEvent.TYPE_DELETED) {
            if (path.startsWith(SessionAlarmService.PATH_FEEDBACK)) {
                Uri uri = event.getDataItem().getUri();
                dismissLocalNotification(uri.getLastPathSegment());
            }
        }
    }
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:23,代码来源:FeedbackWearableListenerService.java

示例4: onDataChanged

import com.google.android.gms.wearable.DataMapItem; //导入依赖的package包/类
/**
 * This method is activated when a data is receive from the phone
 * @param dataEvents
 */
@Override
public void onDataChanged(DataEventBuffer dataEvents) {

    DataMap dataMap;
    for (DataEvent event : dataEvents) {
        // Check the data type
        if (event.getType() == DataEvent.TYPE_CHANGED) {
            // Check the data path
            dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();

            //get the new rule send by the phone
            CustomRules rule= getRuleFromMap(dataMap);

            //save the rule in the database
            RulesRepository.getInstance().insertOrUpdate(rule);

            //send the value to the activty to change the display of bar

            Intent messageIntent = new Intent();
            messageIntent.setAction(Intent.ACTION_SEND);
            messageIntent.putExtra(Const.KEY_BROADCASTdATA, dataMap.toBundle());
            LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
        }
    }
}
 
开发者ID:kflauri2312lffds,项目名称:Android_watch_magpie,代码行数:30,代码来源:ListenerSyncRule.java

示例5: onDataChanged

import com.google.android.gms.wearable.DataMapItem; //导入依赖的package包/类
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
    super.onDataChanged(dataEvents);

    for (DataEvent event : dataEvents) {
        if (event.getType() == DataEvent.TYPE_CHANGED) {
            // DataItem changed
            DataItem item = event.getDataItem();
            if (item.getUri().getPath().compareTo("/SHAKEINTENSITY") == 0) {
                DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();

                Log.e("Data Event", "value->"+dataMap.getString(SHAKE_INTENSITY_KEY));
                LocalStoreUtils.setShakeIntensity(dataMap.getString(SHAKE_INTENSITY_KEY), this);
            }
        }
    }

}
 
开发者ID:squareboat,项目名称:Excuser,代码行数:19,代码来源:DataLayerListenerService.java

示例6: onDataChanged

import com.google.android.gms.wearable.DataMapItem; //导入依赖的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

示例7: onDataChanged

import com.google.android.gms.wearable.DataMapItem; //导入依赖的package包/类
@Override // DataApi.DataListener
public void onDataChanged(DataEventBuffer dataEvents) {
    Log.d(TAG, "Data changed");
    for (DataEvent dataEvent : dataEvents) {
        if (dataEvent.getType() != DataEvent.TYPE_CHANGED) {
            continue;
        }

        DataItem dataItem = dataEvent.getDataItem();
        if (!dataItem.getUri().getPath().equals(
                ConfigurationHelper.PATH_WITH_FEATURE)) {
            continue;
        }

        DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
        DataMap config = dataMapItem.getDataMap();
        Log.d(TAG, "Config DataItem updated:" + config);
        // This can happen from this method more often when phone changes
        updateUiForConfigDataMap(config);
    }
}
 
开发者ID:jimmykane,项目名称:Athletica,代码行数:22,代码来源:WatchFaceService.java

示例8: processData

import com.google.android.gms.wearable.DataMapItem; //导入依赖的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

示例9: onDataChanged

import com.google.android.gms.wearable.DataMapItem; //导入依赖的package包/类
@Override // DataApi.DataListener
public void onDataChanged(DataEventBuffer dataEvents) {
    for (DataEvent dataEvent : dataEvents) {
        if (dataEvent.getType() != DataEvent.TYPE_CHANGED) {
            continue;
        }

        DataItem dataItem = dataEvent.getDataItem();
        if (!dataItem.getUri().getPath().equals(
                WatchFaceUtil.PATH_WITH_FEATURE)) {
            continue;
        }

        DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
        DataMap config = dataMapItem.getDataMap();
        Log.d(TAG, "Config DataItem updated:" + config);

        updateUiForConfigDataMap(config);
    }
}
 
开发者ID:marcouberti,项目名称:adrenaline_watch_face,代码行数:21,代码来源:SonicBoomFace.java

示例10: onDataChanged

import com.google.android.gms.wearable.DataMapItem; //导入依赖的package包/类
@Override // DataApi.DataListener
public void onDataChanged(DataEventBuffer dataEvents) {
    Log.d(TAG,"onDataChanged "+dataEvents);
    for (DataEvent dataEvent : dataEvents) {
        if (dataEvent.getType() != DataEvent.TYPE_CHANGED) {
            continue;
        }

        DataItem dataItem = dataEvent.getDataItem();
        if (!dataItem.getUri().getPath().equals(WatchFaceUtil.PATH_WITH_FEATURE)) {
            continue;
        }

        DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
        DataMap config = dataMapItem.getDataMap();
        Log.d(TAG, "Config DataItem updated:" + config);

        updateUiForConfigDataMap(config);
    }
}
 
开发者ID:marcouberti,项目名称:adrenaline_watch_face,代码行数:21,代码来源:WatchFaceCompanionConfigActivity.java

示例11: onDataChanged

import com.google.android.gms.wearable.DataMapItem; //导入依赖的package包/类
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
    final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents);
    dataEvents.close();
    for (DataEvent event : events) {
        Uri uri = event.getDataItem().getUri();
        String path = uri.getPath();
        if (WEAR_PATH.equals(path)) {
            DataMapItem item = DataMapItem.fromDataItem(event.getDataItem());
            byte[] realmAsset = item.getDataMap().getByteArray(DATA_ASSET_FILE);
            if (realmAsset != null) {
                toFile(realmAsset);
                getBaseContext().sendBroadcast(new Intent(DATA_STORY_CHANGED));
            }
        }
    }
}
 
开发者ID:LadyViktoria,项目名称:wearDrip,代码行数:18,代码来源:ListenerService.java

示例12: onDataChanged

import com.google.android.gms.wearable.DataMapItem; //导入依赖的package包/类
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
    super.onDataChanged(dataEvents);
    DataMap dataMap = new DataMap();

    for(DataEvent dataEvent : dataEvents){
        if(dataEvent.getType()==DataEvent.TYPE_CHANGED){
            String path = dataEvent.getDataItem().getUri().getPath();

            if(path.equalsIgnoreCase(MOBILE_MESSAGE_PATH)){
                dataMap = DataMapItem.fromDataItem(dataEvent.getDataItem()).getDataMap();
            }
        }
    }

    Intent messageIntent = new Intent();
    messageIntent.setAction(Intent.ACTION_SEND);
    messageIntent.putExtra("datamap", dataMap.toBundle());
    LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
}
 
开发者ID:sahilandroid19,项目名称:WearApp,代码行数:21,代码来源:DataListenerService.java

示例13: getDataItem

import com.google.android.gms.wearable.DataMapItem; //导入依赖的package包/类
/**
 * This methods gets the string data from the wear DataApi and uses gson to deserialize json to a bundles object.
 *
 * @param googleApiClient a connected googleApiClient
 * @param nodeId          the node to get the data from
 * @return Observable that emits Bundles
 */
private static Observable<Bundles> getDataItem(final GoogleApiClient googleApiClient, final String nodeId) {
    return Observable.create(new Observable.OnSubscribe<Bundles>() {
        @Override
        public void call(final Subscriber<? super Bundles> subscriber) {
            final PendingResult<DataApi.DataItemResult> dataItem = Wearable.DataApi.getDataItem(googleApiClient, DatalayerUtil.getUriForDataItem(nodeId, DATA_PATH));
            dataItem.setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
                @Override
                public void onResult(@NonNull DataApi.DataItemResult dataItemResult) {
                    if (dataItemResult.getDataItem() == null) {
                        subscriber.onError(new Throwable("No data"));
                        return;
                    }
                    String string = DataMapItem.fromDataItem(dataItemResult.getDataItem()).getDataMap().getString(BUNDLE_KEY);
                    Bundles bundles = new Gson().fromJson(string, Bundles.class);
                    subscriber.onNext(bundles);
                    subscriber.onCompleted();
                }
            });
        }
    }).observeOn(Schedulers.io());
}
 
开发者ID:T-MobileNL,项目名称:Smartwatch,代码行数:29,代码来源:WearDataHelper.java

示例14: onDataChanged

import com.google.android.gms.wearable.DataMapItem; //导入依赖的package包/类
@Override
public void onDataChanged(DataEventBuffer dataEvents) {//KS does not seem to get triggered; therefore use OnMessageReceived instead

    DataMap dataMap;

    for (DataEvent event : dataEvents) {

        if (event.getType() == DataEvent.TYPE_CHANGED) {

            String path = event.getDataItem().getUri().getPath();

            switch (path) {
                case WEARABLE_PREF_DATA_PATH:
                    dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();
                    if (dataMap != null) {
                        Log.d(TAG, "onDataChanged WEARABLE_PREF_DATA_PATH dataMap=" + dataMap);
                        syncPrefData(dataMap);
                    }
                    break;
                default:
                    Log.d(TAG, "Unknown wearable path: " + path);
                    break;
            }
        }
    }
}
 
开发者ID:NightscoutFoundation,项目名称:xDrip,代码行数:27,代码来源:WatchUpdaterService.java

示例15: onDataChanged

import com.google.android.gms.wearable.DataMapItem; //导入依赖的package包/类
@Override
public void onDataChanged(DataEventBuffer dataEventBuffer) {
    Log.d(LOG_TAG, "Weather data has been changed!");
    for (DataEvent event : dataEventBuffer) {
        DataItem item = event.getDataItem();
        if (WEATHER_DATA_PATH.equals(item.getUri().getPath())) {
            DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();
            double high = dataMap.getDouble(WEATHER_DATA_HIGH);
            double low = dataMap.getDouble(WEATHER_DATA_LOW);
            long id = dataMap.getLong(WEATHER_DATA_ID);

            mWeather = (int) Math.round(high) + "/" +  (int) Math.round(low);
            mWeatherId = (int) id;

            loadIconForWeatherId();

            SharedPreferences preferences = getSharedPreferences(PREFERENCES, MODE_PRIVATE);
            SharedPreferences.Editor editor = preferences.edit();
            editor.putString(KEY_WEATHER, mWeather);
            editor.putInt(KEY_WEATHER_ID, mWeatherId);
            editor.apply();
        }
    }
}
 
开发者ID:DmitryMalkovich,项目名称:go-ubiquitous,代码行数:25,代码来源:SunshineWatchFace.java


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