當前位置: 首頁>>代碼示例>>Java>>正文


Java DataEventBuffer.close方法代碼示例

本文整理匯總了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));
            }
        }
    }
}
 
開發者ID:LadyViktoria,項目名稱:wearDrip,代碼行數:18,代碼來源:ListenerService.java

示例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));
            }
        }
    }
}
 
開發者ID:tajchert,項目名稱:SpritzerWear,代碼行數:19,代碼來源:ListenerService.java

示例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();
            }
        }
    }
}
 
開發者ID:google,項目名稱:climb-tracker,代碼行數:23,代碼來源:WearDataLayerListenerService.java

示例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);
            }
        }
    }
}
 
開發者ID:devmil,項目名稱:parrot-zik-2-supercharge,代碼行數:27,代碼來源:NotificationListenerService.java

示例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;
        }
    }
  }
}
 
開發者ID:jimblackler,項目名稱:YourPhotosWatch,代碼行數:27,代碼來源:BaseWatchService.java

示例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();
    }
}
 
開發者ID:AndroidAvanzato,項目名稱:Capitolo6,代碼行數:26,代碼來源:DigitalWatchFaceService.java

示例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();
}
 
開發者ID:mauimauer,項目名稱:AndroidWearable-Samples,代碼行數:21,代碼來源:HomeListenerService.java

示例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()));
                }
            }
        }
    });
}
 
開發者ID:mauimauer,項目名稱:AndroidWearable-Samples,代碼行數:21,代碼來源:MainActivity.java

示例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);
                }
            }
        }
    }
}
 
開發者ID:tajchert,項目名稱:WearBankCode,代碼行數:22,代碼來源:DataLayerListenerService.java

示例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()));
                }
            }
        }
    });
}
 
開發者ID:fusheng1209,項目名稱:GetSensorData,代碼行數:22,代碼來源:MainActivity.java

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

            }

        }
    }
}
 
開發者ID:ToxicBakery,項目名稱:LollipopDemo,代碼行數:25,代碼來源:DemoWearActivity.java

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

}
 
開發者ID:mladenbabic,項目名稱:Advanced_Android_Development_Wear,代碼行數:28,代碼來源:SunshineWatchFace.java

示例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();
}
 
開發者ID:glanceable,項目名稱:GlanceTweet,代碼行數:28,代碼來源:TweetReceiverService.java

示例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();
  }
}
 
開發者ID:INsReady,項目名稱:ReleaseWatch,代碼行數:36,代碼來源:D8ReleaseWatchFaceService.java


注:本文中的com.google.android.gms.wearable.DataEventBuffer.close方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。