Java 类com.google.android.gms.wearable.DataClient 实例源码

项目:muzei    文件:ArtworkCacheIntentService.java   
@Override
protected void onHandleIntent(Intent intent) {
    boolean foundArtwork = false;
    DataClient dataClient = Wearable.getDataClient(this);
    // Read all DataItems
    try {
        DataItemBuffer dataItemBuffer = Tasks.await(dataClient.getDataItems());
        Iterator<DataItem> dataItemIterator = dataItemBuffer.singleRefIterator();
        while (dataItemIterator.hasNext()) {
            DataItem dataItem = dataItemIterator.next();
            foundArtwork = foundArtwork || processDataItem(dataClient, dataItem);
        }
        dataItemBuffer.release();
    } catch (ExecutionException|InterruptedException e) {
        Log.e(TAG, "Error getting all data items", e);
    }
    if (foundArtwork) {
        // Enable the Full Screen Activity and Artwork Complication Provider Service only if we've found artwork
        enableComponents(FullScreenActivity.class, ArtworkComplicationProviderService.class);
    }
    if (!foundArtwork && intent != null &&
            intent.getBooleanExtra(SHOW_ACTIVATE_NOTIFICATION_EXTRA, false)) {
        ActivateMuzeiIntentService.maybeShowActivateMuzeiNotification(this);
    } else {
        ActivateMuzeiIntentService.clearNotifications(this);
    }
}