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


Java FreezableUtils类代码示例

本文整理汇总了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));
            }
        }
    }
}
 
开发者ID:LadyViktoria,项目名称:wearDrip,代码行数:18,代码来源:ListenerService.java

示例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);
        }
    }
}
 
开发者ID:rampage128,项目名称:hombot-control,代码行数:19,代码来源:WearRequestEngine.java

示例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));
            }
        }
    }
}
 
开发者ID:tajchert,项目名称:SpritzerWear,代码行数:19,代码来源:ListenerService.java

示例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();
            }
        }
    }
}
 
开发者ID:google,项目名称:climb-tracker,代码行数:23,代码来源:WearDataLayerListenerService.java

示例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);
            }
        }
    }
}
 
开发者ID:devmil,项目名称:parrot-zik-2-supercharge,代码行数:27,代码来源:NotificationListenerService.java

示例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);

        }

    }
}
 
开发者ID:Cedgetec,项目名称:SchulinfoApp-android,代码行数:20,代码来源:DataLayerListenerService.java

示例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);
        }
    }
}
 
开发者ID:googlesamples,项目名称:io2015-codelabs,代码行数:19,代码来源:ListenerService.java

示例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;
        }
    }
  }
}
 
开发者ID:jimblackler,项目名称:YourPhotosWatch,代码行数:27,代码来源:BaseWatchService.java

示例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());
            }
        }
    }
}
 
开发者ID:jpettersson,项目名称:wearify,代码行数:23,代码来源:DataLayerListenerService.java

示例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()));
                }
            }
        }
    });
}
 
开发者ID:mauimauer,项目名称:AndroidWearable-Samples,代码行数:21,代码来源:MainActivity.java

示例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);
                }
            }
        }
    }
}
 
开发者ID:tajchert,项目名称:WearBankCode,代码行数:22,代码来源:DataLayerListenerService.java

示例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()));
                }
            }
        }
    });
}
 
开发者ID:fusheng1209,项目名称:GetSensorData,代码行数:22,代码来源:MainActivity.java

示例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);
                    }
                });

            }

        }
    }
}
 
开发者ID:ToxicBakery,项目名称:LollipopDemo,代码行数:25,代码来源:DemoWearActivity.java

示例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);
    }
}
 
开发者ID:tobiasheine,项目名称:BitcoinWatcher,代码行数:12,代码来源:BitcoinPriceChangeListener.java

示例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();
                }
            }
        });
}
 
开发者ID:emmby,项目名称:easy-a,代码行数:30,代码来源:MainActivity.java


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