本文整理匯總了Java中com.google.android.gms.wearable.DataEventBuffer.close方法的典型用法代碼示例。如果您正苦於以下問題:Java DataEventBuffer.close方法的具體用法?Java DataEventBuffer.close怎麽用?Java DataEventBuffer.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.android.gms.wearable.DataEventBuffer
的用法示例。
在下文中一共展示了DataEventBuffer.close方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onDataChanged
import com.google.android.gms.wearable.DataEventBuffer; //導入方法依賴的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));
}
}
}
}
示例2: onDataChanged
import com.google.android.gms.wearable.DataEventBuffer; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
Log.d(TAG, "onDataChanged");
final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents);
dataEvents.close();
for (DataEvent event : events) {
Uri uri = event.getDataItem().getUri();
String path = uri.getPath();
if (Tools.WEAR_PATH.equals(path)) {
DataMapItem item = DataMapItem.fromDataItem(event.getDataItem());
byte[] realmAsset = item.getDataMap().getByteArray(Tools.DATA_ASSET_FILE);
if(realmAsset != null){
toFile(realmAsset);
getBaseContext().sendBroadcast(new Intent(Tools.DATA_STORY_CHANGED));
}
}
}
}
示例3: onDataChanged
import com.google.android.gms.wearable.DataEventBuffer; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
Log.d(TAG, "onDataChanged: " + dataEvents);
final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents);
dataEvents.close();
for (DataEvent event : events) {
Log.d(TAG, "Event: " + event.getDataItem().toString());
Uri uri = event.getDataItem().getUri();
String path = uri.getPath();
if (path.equals(Path.GRADE_SYSTEM)) {
DataMapItem dataMapItem = DataMapItem.fromDataItem(event.getDataItem());
String gradeSystem = dataMapItem.getDataMap().getString(Path.GRADE_SYSTEM_KEY);
if (gradeSystem != null) {
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putString(Path.PREF_GRAD_SYSTEM_TYPE, gradeSystem);
editor.commit();
}
}
}
}
示例4: onDataChanged
import com.google.android.gms.wearable.DataEventBuffer; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
super.onDataChanged(dataEvents);
final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents);
dataEvents.close();
if (!mGoogleApiClient.isConnected()) {
ConnectionResult connectionResult = mGoogleApiClient
.blockingConnect(30, TimeUnit.SECONDS);
if (!connectionResult.isSuccess()) {
Log.e(TAG, "Service failed to connect to GoogleApiClient.");
return;
}
}
for(DataEvent event : events) {
if(event.getType() == DataEvent.TYPE_CHANGED) {
String path = event.getDataItem().getUri().getPath();
if(DataInterface.PATH_NOTIFICATION.equals(path)) {
DataMapItem dataMapItem = DataMapItem.fromDataItem(event.getDataItem());
updateOrShowNotification(dataMapItem);
}
}
}
}
示例5: onDataChanged
import com.google.android.gms.wearable.DataEventBuffer; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
ArrayList<DataEvent> dataEvents1 = FreezableUtils.freezeIterable(dataEvents);
dataEvents.close();
for (DataEvent event : dataEvents1) {
DataItem dataItem = event.getDataItem();
String[] parts = dataItem.getUri().getPath().split("/");
switch (parts[1]) {
case "image":
String photoId = parts[2];
switch (event.getType()) {
case DataEvent.TYPE_CHANGED:
photos.put(photoId, dataItem);
// Show new image immediately (even in ambient mode).
updateImage(dataItem);
extraWake();
break;
case DataEvent.TYPE_DELETED:
photos.remove(photoId);
if (currentPhoto.equals(photoId))
setEmptyBackground();
break;
}
}
}
}
示例6: onDataChanged
import com.google.android.gms.wearable.DataEventBuffer; //導入方法依賴的package包/類
@Override // DataApi.DataListener
public void onDataChanged(DataEventBuffer dataEvents) {
try {
for (DataEvent dataEvent : dataEvents) {
if (dataEvent.getType() != DataEvent.TYPE_CHANGED) {
continue;
}
DataItem dataItem = dataEvent.getDataItem();
if (!dataItem.getUri().getPath().equals(
DigitalWatchFaceUtil.PATH_WITH_FEATURE)) {
continue;
}
DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
DataMap config = dataMapItem.getDataMap();
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Config DataItem updated:" + config);
}
updateUiForConfigDataMap(config);
}
} finally {
dataEvents.close();
}
}
示例7: onDataChanged
import com.google.android.gms.wearable.DataEventBuffer; //導入方法依賴的package包/類
/**
* Listen for DataItems added/deleted from the geofence service running on the companion.
*/
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "onDataChanged: " + dataEvents + " for " + getPackageName());
}
for (DataEvent event : dataEvents) {
if (event.getType() == DataEvent.TYPE_DELETED) {
cancelNotificationForDataItem(event.getDataItem());
} else if (event.getType() == DataEvent.TYPE_CHANGED) {
// The user has entered a geofence - post a notification!
String geofenceId = DataMap.fromByteArray(event.getDataItem().getData())
.getString(KEY_GEOFENCE_ID);
postNotificationForGeofenceId(geofenceId, event.getDataItem().getUri());
}
}
dataEvents.close();
}
示例8: onDataChanged
import com.google.android.gms.wearable.DataEventBuffer; //導入方法依賴的package包/類
@Override //DataListener
public void onDataChanged(DataEventBuffer dataEvents) {
LOGD(TAG, "onDataChanged: " + dataEvents);
final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents);
dataEvents.close();
runOnUiThread(new Runnable() {
@Override
public void run() {
for (DataEvent event : events) {
if (event.getType() == DataEvent.TYPE_CHANGED) {
mDataItemListAdapter.add(
new Event("DataItem Changed", event.getDataItem().toString()));
} else if (event.getType() == DataEvent.TYPE_DELETED) {
mDataItemListAdapter.add(
new Event("DataItem Deleted", event.getDataItem().toString()));
}
}
}
});
}
示例9: onDataChanged
import com.google.android.gms.wearable.DataEventBuffer; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
Log.d(TAG, "onDataChanged");
final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents);
dataEvents.close();
for (DataEvent event : events) {
Uri uri = event.getDataItem().getUri();
String path = uri.getPath();
if (Tools.WEAR_PATH.equals(path)) {
DataMapItem item = DataMapItem.fromDataItem(event.getDataItem());
String codeText = item.getDataMap().getString(Tools.WEAR_KEY_BANKS_CODE);
if(codeText != null) {
String contentArr [] = codeText.split("<<>>");
codeText = contentArr[0];
if(codeText != null && !codeText.equals("")){
makeNotification(codeText);
}
}
}
}
}
示例10: onDataChanged
import com.google.android.gms.wearable.DataEventBuffer; //導入方法依賴的package包/類
@Override //DataListener
public void onDataChanged(DataEventBuffer dataEvents) {
LOGD(TAG, "onDataChanged: " + dataEvents);
final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents);
dataEvents.close();
runOnUiThread(new Runnable() {
@Override
public void run() {
for (DataEvent event : events) {
if (event.getType() == DataEvent.TYPE_CHANGED) {
// mDataItemListAdapter.clear();
// mDataItemListAdapter.notifyDataSetChanged();
// mDataItemListAdapter.add( new Event("Mobile DataItem Changed",event.getDataItem().toString()));
} else if (event.getType() == DataEvent.TYPE_DELETED) {
mDataItemListAdapter.add(
new Event("DataItem Deleted", event.getDataItem().toString()));
}
}
}
});
}
示例11: onDataChanged
import com.google.android.gms.wearable.DataEventBuffer; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents);
dataEvents.close();
for (DataEvent event : events) {
if (event.getType() == DataEvent.TYPE_CHANGED) {
String path = event.getDataItem().getUri().getPath();
if (IMAGE_PATH.equals(path)) {
DataMapItem dataMapItem = DataMapItem.fromDataItem(event.getDataItem());
Asset photo = dataMapItem.getDataMap()
.getAsset(IMAGE_KEY);
final Bitmap bitmap = loadBitmapFromAsset(googleApiClient, photo);
handler.post(new Runnable() {
@Override
public void run() {
imageView.setImageBitmap(bitmap);
}
});
}
}
}
}
示例12: onDataChanged
import com.google.android.gms.wearable.DataEventBuffer; //導入方法依賴的package包/類
@Override // DataApi.DataListener
public void onDataChanged(DataEventBuffer dataEvents) {
try {
for (DataEvent dataEvent : dataEvents) {
if (dataEvent.getType() != DataEvent.TYPE_CHANGED) {
continue;
}
DataItem dataItem = dataEvent.getDataItem();
Log.d(TAG, "onDataChanged: Path" + dataItem.getUri().getPath());
if (!dataItem.getUri().getPath().equals(
Constants.PATH_WEATHER_DATA)) {
continue;
}
DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
DataMap config = dataMapItem.getDataMap();
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Config DataItem updated:" + config);
}
updateUiForConfigDataMap(config);
}
} finally {
dataEvents.close();
}
}
示例13: onDataChanged
import com.google.android.gms.wearable.DataEventBuffer; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
Log.d(TAG, "onDataChanged: ");
try {
for (DataEvent dataEvent : dataEvents) {
if (dataEvent.getType() != DataEvent.TYPE_CHANGED) {
continue;
}
DataItem dataItem = dataEvent.getDataItem();
Log.d(TAG, "path: " + dataItem.getUri().getPath());
if (!dataItem.getUri().getPath().equals(Constants.PATH_WEATHER_DATA)) {
continue;
}
DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
DataMap config = dataMapItem.getDataMap();
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Config DataItem updated:" + config);
}
DigitalWatchFaceUtil.overwriteKeysInConfigDataMap(mGoogleApiClient, config, Constants.PATH_WEATHER_DATA);
}
} finally {
dataEvents.close();
}
}
開發者ID:mladenbabic,項目名稱:Advanced_Android_Development_Wear,代碼行數:30,代碼來源:ConfigDataListenerService.java
示例14: onDataChanged
import com.google.android.gms.wearable.DataEventBuffer; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
Log.d(TAG, "onDataChanged data path: numEvents:" + dataEvents.getCount());
for (DataEvent event : dataEvents) {
if (event.getType() == DataEvent.TYPE_CHANGED) {
String path = event.getDataItem().getUri().getPath();
if (path.equals("/new_tweets")) {
storeTweets(event.getDataItem());
} else if (path.equals(Constants.PATH_MARK_READ)) {
markAllRead();
} else if (path.equals(Constants.GENERIC_CONFIG_PATH)) {
DataMapItem mapDataItem = DataMapItem.fromDataItem(event.getDataItem());
DataMap data = mapDataItem.getDataMap();
if (data.containsKey(Constants.KEY_POCKET_CONNECTED)) {
Log.d(TAG, "pocket connected");
settings.edit().putBoolean(Constants.KEY_POCKET_CONNECTED,
data.getBoolean(Constants.KEY_POCKET_CONNECTED)).apply();
}
if (data.containsKey(Constants.KEY_NOTIFY_FREQUENCY)) {
settings.edit().putInt(Constants.KEY_NOTIFY_FREQUENCY, Constants.DEFAULT_NOTIFY_FREQUENCY).apply();
}
}
}
}
dataEvents.close();
}
示例15: onDataChanged
import com.google.android.gms.wearable.DataEventBuffer; //導入方法依賴的package包/類
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
Log.d(TAG, "New D8 Release Date comes!");
try {
for (DataEvent dataEvent : dataEvents) {
if (dataEvent.getType() != DataEvent.TYPE_CHANGED) {
continue;
}
DataItem dataItem = dataEvent.getDataItem();
if (!dataItem.getUri().getPath().equals(UPDATE_D8_RELEASE_DATA)) {
continue;
}
DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
DataMap dataMap = dataMapItem.getDataMap();
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Config DataItem updated:" + dataMap);
}
mCurCritical = dataMap.getInt("CurrentCritical");
mCurMajor = dataMap.getInt("CurrentMajor");
mFromYesterdayCritical = dataMap.getInt("fromYesterdayCritical");
mFromYesterdayMajor = dataMap.getInt("fromYesterdayMajor");
mEstimate = dataMap.getString("Estimate");
Log.d(TAG, "Project Status Current Criticals: " + mCurCritical);
Log.d(TAG, "Project Status Current Majors: " + mCurMajor);
Log.d(TAG, "Project Status from Yesterday Critical: " + mFromYesterdayCritical);
Log.d(TAG, "Project Status from Yesterday Major: " + mFromYesterdayMajor);
Log.d(TAG, "D8 Release Date Estimate: " + mEstimate);
invalidate();
}
} finally {
dataEvents.close();
}
}