本文整理汇总了Java中com.google.android.gms.common.data.FreezableUtils类的典型用法代码示例。如果您正苦于以下问题:Java FreezableUtils类的具体用法?Java FreezableUtils怎么用?Java FreezableUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FreezableUtils类属于com.google.android.gms.common.data包,在下文中一共展示了FreezableUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onDataChanged
import com.google.android.gms.common.data.FreezableUtils; //导入依赖的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.common.data.FreezableUtils; //导入依赖的package包/类
@Override
public void onDataChanged(DataEventBuffer dataEventBuffer) {
final List<DataEvent> events = FreezableUtils.freezeIterable(dataEventBuffer);
for(DataEvent event : events) {
if (WearMessages.MESSAGE_BOT_LIST.equalsIgnoreCase(event.getDataItem().getUri().getPath())) {
final DataMap map = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();
ArrayList<DataMap> botList = map.getDataMapArrayList(WearMessages.MAPENTRY_BOT_LIST);
WearBot[] bots = new WearBot[botList.size()];
for (int i = 0; i < botList.size(); i++) {
bots[i] = new WearBot(botList.get(i));
}
getListener().updateBotList(bots);
}
}
}
示例3: onDataChanged
import com.google.android.gms.common.data.FreezableUtils; //导入依赖的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));
}
}
}
}
示例4: onDataChanged
import com.google.android.gms.common.data.FreezableUtils; //导入依赖的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();
}
}
}
}
示例5: onDataChanged
import com.google.android.gms.common.data.FreezableUtils; //导入依赖的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);
}
}
}
}
示例6: onDataChanged
import com.google.android.gms.common.data.FreezableUtils; //导入依赖的package包/类
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
final ArrayList<DataEvent> events = FreezableUtils
.freezeIterable(dataEvents);
for (DataEvent event : events) {
DataItem item = event.getDataItem();
String path = item.getUri().getPath();
Log.d("ggvp", "received data for " + path);
if(event.getType() == DataEvent.TYPE_CHANGED && path.equals("/filters")) {
DataMap map = DataMapItem.fromDataItem(item).getDataMap();
ArrayList<String> filters = map.getStringArrayList("filters");
WearApp.APP.updateFilters(filters);
}
}
}
示例7: onDataChanged
import com.google.android.gms.common.data.FreezableUtils; //导入依赖的package包/类
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
Log.d(TAG, "onDataChanged: " + dataEvents);
final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents);
for (DataEvent event : events) {
if (event.getType() == DataEvent.TYPE_CHANGED
&& event.getDataItem() != null
&& Constants.ATTRACTION_PATH.equals(event.getDataItem().getUri().getPath())) {
DataMapItem dataMapItem = DataMapItem.fromDataItem(event.getDataItem());
ArrayList<DataMap> attractionsData =
dataMapItem.getDataMap().getDataMapArrayList(Constants.EXTRA_ATTRACTIONS);
showNotification(dataMapItem.getUri(), attractionsData);
}
}
}
示例8: onDataChanged
import com.google.android.gms.common.data.FreezableUtils; //导入依赖的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;
}
}
}
}
示例9: onDataChanged
import com.google.android.gms.common.data.FreezableUtils; //导入依赖的package包/类
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
Log.i(TAG, "onDataChanged: " + dataEvents);
final List<DataEvent> events = FreezableUtils
.freezeIterable(dataEvents);
// Loop through the events and send a message
// to the node that created the data item.
for (DataEvent event : events) {
Log.i(TAG, event.toString());
if(event.getType() == DataEvent.TYPE_CHANGED) {
String path = event.getDataItem().getUri().getPath();
if (path.equals(PLAYLISTS_PATH)) {
DataMap dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();
Log.v("myTag", "DataMap received on watch: " + dataMap.toString());
writeFile(dataMap.toByteArray());
}
}
}
}
示例10: onDataChanged
import com.google.android.gms.common.data.FreezableUtils; //导入依赖的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()));
}
}
}
});
}
示例11: onDataChanged
import com.google.android.gms.common.data.FreezableUtils; //导入依赖的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);
}
}
}
}
}
示例12: onDataChanged
import com.google.android.gms.common.data.FreezableUtils; //导入依赖的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()));
}
}
}
});
}
示例13: onDataChanged
import com.google.android.gms.common.data.FreezableUtils; //导入依赖的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);
}
});
}
}
}
}
示例14: onDataChanged
import com.google.android.gms.common.data.FreezableUtils; //导入依赖的package包/类
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
super.onDataChanged(dataEvents);
final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents);
for (final DataEvent event : events) {
final BitcoinPrice bitcoinPrice = getBitcoinPriceFromDataEvent(event);
storage.storePrice(bitcoinPrice);
}
}
示例15: updateList
import com.google.android.gms.common.data.FreezableUtils; //导入依赖的package包/类
private void updateList() {
// Retrieve the complete list of dataitems using DataApi
// .getDataItems. Because this may involve a network sync and
// may take some time, get the results back in a ResultCallback
// at a later time.
Wearable.DataApi.getDataItems(googleApiClient).setResultCallback(
new ResultCallback<DataItemBuffer>() {
@Override
public void onResult(DataItemBuffer dataItems) {
try {
// Before you start using dataItems,
// you must "freeze" them to make sure they
// don't change while you are iterating over them.
List<DataItem> items
= FreezableUtils.freezeIterable(dataItems);
// Update the adapter with the new items.
adapter.setResults(items);
Log.d("MainActivity", "adapter.setResults");
} finally {
// Always release the dataItems when you are
// through.
dataItems.release();
}
}
});
}