am 9b8bb2ac: am 535025ba: Remove freezeIterable() when data items are processed immediately
* commit '9b8bb2ace4dfa576889410961188e0b33a79831b':
Remove freezeIterable() when data items are processed immediately
diff --git a/wearable/wear/AgendaData/Application/src/main/java/com/example/android/wearable/agendadata/MainActivity.java b/wearable/wear/AgendaData/Application/src/main/java/com/example/android/wearable/agendadata/MainActivity.java
index 62dc349..34e327b 100644
--- a/wearable/wear/AgendaData/Application/src/main/java/com/example/android/wearable/agendadata/MainActivity.java
+++ b/wearable/wear/AgendaData/Application/src/main/java/com/example/android/wearable/agendadata/MainActivity.java
@@ -33,7 +33,6 @@
import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;
import com.google.android.gms.common.api.ResultCallback;
-import com.google.android.gms.common.data.FreezableUtils;
import com.google.android.gms.wearable.DataApi;
import com.google.android.gms.wearable.DataItem;
import com.google.android.gms.wearable.DataItemBuffer;
@@ -98,11 +97,7 @@
public void onResult(DataItemBuffer result) {
try {
if (result.getStatus().isSuccess()) {
- // Store the DataItem URIs in a List and release the buffer.
- // Then use these URIs to delete the DataItems.
- List<DataItem> dataItemList = FreezableUtils
- .freezeIterable(result);
- deleteDataItems(dataItemList);
+ deleteDataItems(result);
} else {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG,"onDeleteEventsClicked(): failed to get Data "
@@ -121,7 +116,7 @@
}
}
- private void deleteDataItems(final List<DataItem> dataItemList) {
+ private void deleteDataItems(final DataItemBuffer dataItemList) {
if (mGoogleApiClient.isConnected()) {
for (final DataItem dataItem : dataItemList) {
final Uri dataItemUri = dataItem.getUri();
diff --git a/wearable/wear/DataLayer/Application/src/main/java/com/example/android/wearable/datalayer/MainActivity.java b/wearable/wear/DataLayer/Application/src/main/java/com/example/android/wearable/datalayer/MainActivity.java
index 2a4a353..1c67c0e 100644
--- a/wearable/wear/DataLayer/Application/src/main/java/com/example/android/wearable/datalayer/MainActivity.java
+++ b/wearable/wear/DataLayer/Application/src/main/java/com/example/android/wearable/datalayer/MainActivity.java
@@ -216,6 +216,7 @@
@Override //DataListener
public void onDataChanged(DataEventBuffer dataEvents) {
LOGD(TAG, "onDataChanged: " + dataEvents);
+ // Need to freeze the dataEvents so they will exist later on the UI thread
final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents);
runOnUiThread(new Runnable() {
@Override
diff --git a/wearable/wear/DataLayer/Wearable/src/main/java/com/example/android/wearable/datalayer/DataLayerListenerService.java b/wearable/wear/DataLayer/Wearable/src/main/java/com/example/android/wearable/datalayer/DataLayerListenerService.java
index 18e7127..67dcef9 100644
--- a/wearable/wear/DataLayer/Wearable/src/main/java/com/example/android/wearable/datalayer/DataLayerListenerService.java
+++ b/wearable/wear/DataLayer/Wearable/src/main/java/com/example/android/wearable/datalayer/DataLayerListenerService.java
@@ -22,7 +22,6 @@
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
-import com.google.android.gms.common.data.FreezableUtils;
import com.google.android.gms.wearable.DataEvent;
import com.google.android.gms.wearable.DataEventBuffer;
import com.google.android.gms.wearable.MessageEvent;
@@ -59,7 +58,6 @@
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
LOGD(TAG, "onDataChanged: " + dataEvents);
- final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents);
if (!mGoogleApiClient.isConnected() || !mGoogleApiClient.isConnecting()) {
ConnectionResult connectionResult = mGoogleApiClient
.blockingConnect(30, TimeUnit.SECONDS);
@@ -71,7 +69,7 @@
}
// Loop through the events and send a message back to the node that created the data item.
- for (DataEvent event : events) {
+ for (DataEvent event : dataEvents) {
Uri uri = event.getDataItem().getUri();
String path = uri.getPath();
if (COUNT_PATH.equals(path)) {
diff --git a/wearable/wear/DataLayer/Wearable/src/main/java/com/example/android/wearable/datalayer/MainActivity.java b/wearable/wear/DataLayer/Wearable/src/main/java/com/example/android/wearable/datalayer/MainActivity.java
index e8c86ef..678e428 100644
--- a/wearable/wear/DataLayer/Wearable/src/main/java/com/example/android/wearable/datalayer/MainActivity.java
+++ b/wearable/wear/DataLayer/Wearable/src/main/java/com/example/android/wearable/datalayer/MainActivity.java
@@ -42,7 +42,6 @@
import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;
import com.google.android.gms.common.api.ResultCallback;
-import com.google.android.gms.common.data.FreezableUtils;
import com.google.android.gms.wearable.Asset;
import com.google.android.gms.wearable.CapabilityApi;
import com.google.android.gms.wearable.CapabilityInfo;
@@ -151,8 +150,7 @@
public void onDataChanged(DataEventBuffer dataEvents) {
LOGD(TAG, "onDataChanged(): " + dataEvents);
- final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents);
- for (DataEvent event : events) {
+ for (DataEvent event : dataEvents) {
if (event.getType() == DataEvent.TYPE_CHANGED) {
String path = event.getDataItem().getUri().getPath();
if (DataLayerListenerService.IMAGE_PATH.equals(path)) {
diff --git a/wearable/wear/Quiz/Application/src/main/java/com/example/android/wearable/quiz/MainActivity.java b/wearable/wear/Quiz/Application/src/main/java/com/example/android/wearable/quiz/MainActivity.java
index 171b8b4..de8eb74 100644
--- a/wearable/wear/Quiz/Application/src/main/java/com/example/android/wearable/quiz/MainActivity.java
+++ b/wearable/wear/Quiz/Application/src/main/java/com/example/android/wearable/quiz/MainActivity.java
@@ -325,6 +325,7 @@
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
+ // Need to freeze the dataEvents so they will exist later on the UI thread
final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents);
runOnUiThread(new Runnable() {
@Override
@@ -446,9 +447,7 @@
public void onResult(DataItemBuffer result) {
try {
if (result.getStatus().isSuccess()) {
- List<DataItem> dataItemList = FreezableUtils
- .freezeIterable(result);
- resetDataItems(dataItemList);
+ resetDataItems(result);
} else {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Reset quiz: failed to get Data Items to reset");
@@ -469,7 +468,7 @@
mNumSkipped = 0;
}
- private void resetDataItems(List<DataItem> dataItemList) {
+ private void resetDataItems(DataItemBuffer dataItemList) {
if (mGoogleApiClient.isConnected()) {
for (final DataItem dataItem : dataItemList) {
final Uri dataItemUri = dataItem.getUri();
diff --git a/wearable/wear/Quiz/Wearable/src/main/java/com/example/android/wearable/quiz/QuizListenerService.java b/wearable/wear/Quiz/Wearable/src/main/java/com/example/android/wearable/quiz/QuizListenerService.java
index 327c4b8..5a4b906 100644
--- a/wearable/wear/Quiz/Wearable/src/main/java/com/example/android/wearable/quiz/QuizListenerService.java
+++ b/wearable/wear/Quiz/Wearable/src/main/java/com/example/android/wearable/quiz/QuizListenerService.java
@@ -40,7 +40,6 @@
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
-import com.google.android.gms.common.data.FreezableUtils;
import com.google.android.gms.wearable.DataEvent;
import com.google.android.gms.wearable.DataEventBuffer;
import com.google.android.gms.wearable.DataItem;
@@ -80,8 +79,6 @@
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
- final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents);
-
GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this)
.addApi(Wearable.API)
.build();
@@ -93,7 +90,7 @@
return;
}
- for (DataEvent event : events) {
+ for (DataEvent event : dataEvents) {
if (event.getType() == DataEvent.TYPE_CHANGED) {
DataItem dataItem = event.getDataItem();
DataMap dataMap = DataMapItem.fromDataItem(dataItem).getDataMap();
diff --git a/wearable/wear/XYZTouristAttractions/Wearable/src/main/java/com/example/android/xyztouristattractions/service/ListenerService.java b/wearable/wear/XYZTouristAttractions/Wearable/src/main/java/com/example/android/xyztouristattractions/service/ListenerService.java
index 3908414..d228251 100644
--- a/wearable/wear/XYZTouristAttractions/Wearable/src/main/java/com/example/android/xyztouristattractions/service/ListenerService.java
+++ b/wearable/wear/XYZTouristAttractions/Wearable/src/main/java/com/example/android/xyztouristattractions/service/ListenerService.java
@@ -30,7 +30,6 @@
import com.example.android.xyztouristattractions.ui.AttractionsActivity;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
-import com.google.android.gms.common.data.FreezableUtils;
import com.google.android.gms.wearable.DataEvent;
import com.google.android.gms.wearable.DataEventBuffer;
import com.google.android.gms.wearable.DataMap;
@@ -54,9 +53,7 @@
public void onDataChanged(DataEventBuffer dataEvents) {
Log.d(TAG, "onDataChanged: " + dataEvents);
- final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents);
-
- for (DataEvent event : events) {
+ for (DataEvent event : dataEvents) {
if (event.getType() == DataEvent.TYPE_CHANGED
&& event.getDataItem() != null
&& Constants.ATTRACTION_PATH.equals(event.getDataItem().getUri().getPath())) {