Exemplo n.º 1
0
        async Task DeleteDataItems(DataItemBuffer dataItems)
		{
			if (mGoogleApiClient.IsConnected) {
				// Store the DataItem URIs in a List and close the bugger. Then we use these URIs to delete the DataItems.
				var dataItemList = new List<IDataItem> ();
                dataItemList.AddRange (dataItems);
				dataItems.Close ();

				if (dataItemList.Count > 0) {
					foreach (var dataItem in dataItemList) {
						Android.Net.Uri dataItemUri = dataItem.Uri;
						// In a real calendar application, this might delete the corresponding calendar event from the calendar
						// data provider. In this sample, we simply delete the
						// DataItem, but leave the phone's calendar data intact
						
                        var deleteResult = await WearableClass.DataApi.DeleteDataItemsAsync (mGoogleApiClient, dataItemUri);
						if (deleteResult.Status.IsSuccess) {
							AppendLog ("Successfully deleted data item: " + dataItemUri);
						} else {
							AppendLog ("Failed to delete data item: " + dataItemUri);
						}
					}
				} else {
					AppendLog ("There are no data items");
				}
			} else {
				Log.Error (Constants.TAG, "Failed to delete data items" + " - Client disconnected from Google Play Services");
			}
		}
Exemplo n.º 2
0
        private void DeleteDataItems(DataItemBuffer dataItems)
        {
            if (mGoogleApiClient.IsConnected)
            {
                // Store the DataItem URIs in a List and close the bugger. Then we use these URIs to delete the DataItems.
                var freezableItems = FreezableUtils.FreezeIterable(dataItems);
                var dataItemList   = new List <IDataItem> ();
                for (int i = 0; i < freezableItems.Count; i++)
                {
                    Log.Verbose(Constants.TAG, "Loop " + i);

                    dataItemList.Add(Android.Runtime.Extensions.JavaCast <IDataItem> ((IJavaObject)freezableItems [i]));
                }
                dataItems.Close();
                if (dataItemList.Count > 0)
                {
                    foreach (IDataItem dataItem in dataItemList)
                    {
                        Android.Net.Uri dataItemUri = dataItem.Uri;
                        // In a real calendar application, this might delete the corresponding calendar event from the calendar
                        // data provider. In this sample, we simply delete the
                        // DataItem, but leave the phone's calendar data intact
                        WearableClass.DataApi.DeleteDataItems(mGoogleApiClient, dataItemUri)
                        .SetResultCallback(new ResultCallback()
                        {
                            OnResultFunc = (Java.Lang.Object deleteResult) => {
                                if (Android.Runtime.Extensions.JavaCast <IDataApiDeleteDataItemsResult>(deleteResult).Status.IsSuccess)
                                {
                                    AppendLog("Successfully deleted data item: " + dataItemUri);
                                }
                                else
                                {
                                    AppendLog("Failed to delete data item: " + dataItemUri);
                                }
                            }
                        });
                    }
                }
                else
                {
                    AppendLog("There are no data items");
                }
            }
            else
            {
                Log.Error(Constants.TAG, "Failed to delete data items" + " - Client disconnected from Google Play Services");
            }
        }
 public void OnResult(DataItemBuffer result)
 {
     if (result.Status.IsSuccess)
     {
         var dataItemList = FreezableUtils.FreezeIterable(result);
         result.Close();
         act.ResetDataItems(dataItemList);
     }
     else
     {
         if (Log.IsLoggable(MainActivity.TAG, LogPriority.Debug))
         {
             Log.Debug(MainActivity.TAG, "Reset quiz: failed to get Data Items to reset");
         }
     }
     result.Close();
 }
Exemplo n.º 4
0
        async Task DeleteDataItems(DataItemBuffer dataItems)
        {
            if (mGoogleApiClient.IsConnected)
            {
                // Store the DataItem URIs in a List and close the bugger. Then we use these URIs to delete the DataItems.
                var dataItemList = new List <IDataItem> ();
                dataItemList.AddRange(dataItems);
                dataItems.Close();

                if (dataItemList.Count > 0)
                {
                    foreach (var dataItem in dataItemList)
                    {
                        Android.Net.Uri dataItemUri = dataItem.Uri;
                        // In a real calendar application, this might delete the corresponding calendar event from the calendar
                        // data provider. In this sample, we simply delete the
                        // DataItem, but leave the phone's calendar data intact

                        var deleteResult = await WearableClass.DataApi.DeleteDataItemsAsync(mGoogleApiClient, dataItemUri);

                        if (deleteResult.Status.IsSuccess)
                        {
                            AppendLog("Successfully deleted data item: " + dataItemUri);
                        }
                        else
                        {
                            AppendLog("Failed to delete data item: " + dataItemUri);
                        }
                    }
                }
                else
                {
                    AppendLog("There are no data items");
                }
            }
            else
            {
                Log.Error(Constants.TAG, "Failed to delete data items" + " - Client disconnected from Google Play Services");
            }
        }
 public void OnResult(DataItemBuffer result)
 {
     if (result.Status.IsSuccess)
     {
         List <Android.Net.Uri> dataItemUriList = new List <Android.Net.Uri> ();
         var iterator = result.Iterator();
         while (iterator.HasNext)
         {
             var dataItem = iterator.Next().JavaCast <IDataItem> ();
             dataItemUriList.Add(dataItem.Uri);
         }
         result.Close();
         act.DeleteDataItems(dataItemUriList);
     }
     else
     {
         if (Log.IsLoggable(MainActivity.TAG, LogPriority.Debug))
         {
             Log.Debug(MainActivity.TAG, "Clear quiz: failed to get Data Items for deletion");
         }
     }
     result.Close();
 }
Exemplo n.º 6
0
			public void OnResult (DataItemBuffer result)
			{
				if (result.Status.IsSuccess) {
					List<Android.Net.Uri> dataItemUriList = new List<Android.Net.Uri> ();
					var iterator = result.Iterator ();
					while (iterator.HasNext) {
						var dataItem = iterator.Next ().JavaCast<IDataItem> ();
						dataItemUriList.Add (dataItem.Uri);
					}
					result.Close ();
					act.DeleteDataItems (dataItemUriList);
				} else {
					if (Log.IsLoggable (MainActivity.TAG, LogPriority.Debug)) {
						Log.Debug (MainActivity.TAG, "Clear quiz: failed to get Data Items for deletion");
					}
				}
				result.Close ();
			}
Exemplo n.º 7
0
			public void OnResult (DataItemBuffer result)
			{
				if (result.Status.IsSuccess) {
					var dataItemList = FreezableUtils.FreezeIterable (result);
					result.Close ();
					act.ResetDataItems (dataItemList);
				} else {

					if (Log.IsLoggable (MainActivity.TAG, LogPriority.Debug))
						Log.Debug (MainActivity.TAG, "Reset quiz: failed to get Data Items to reset");
				}
				result.Close ();
			}
Exemplo n.º 8
0
		private void DeleteDataItems(DataItemBuffer dataItems)
		{
			if (mGoogleApiClient.IsConnected) {
				// Store the DataItem URIs in a List and close the bugger. Then we use these URIs to delete the DataItems.
				var freezableItems = FreezableUtils.FreezeIterable (dataItems);
				var dataItemList = new List<IDataItem> ();
				for (int i = 0; i < freezableItems.Count; i++) {
					Log.Verbose (Constants.TAG, "Loop " + i);

					dataItemList.Add (Android.Runtime.Extensions.JavaCast<IDataItem> ((IJavaObject)freezableItems [i]));
				}
				dataItems.Close ();
				if (dataItemList.Count > 0) {
					foreach (IDataItem dataItem in dataItemList) {
						Android.Net.Uri dataItemUri = dataItem.Uri;
						// In a real calendar application, this might delete the corresponding calendar event from the calendar
						// data provider. In this sample, we simply delete the
						// DataItem, but leave the phone's calendar data intact
						WearableClass.DataApi.DeleteDataItems (mGoogleApiClient, dataItemUri)
						.SetResultCallback (new ResultCallback () {
								OnResultFunc = (Java.Lang.Object deleteResult) => {
									if (Android.Runtime.Extensions.JavaCast<IDataApiDeleteDataItemsResult>(deleteResult).Status.IsSuccess) {
									AppendLog ("Successfully deleted data item: " + dataItemUri);
								} else {
									AppendLog ("Failed to delete data item: " + dataItemUri);
								}
							}
						});
					}
				} else {
					AppendLog ("There are no data items");
				}
			} else {
				Log.Error (Constants.TAG, "Failed to delete data items" + " - Client disconnected from Google Play Services");
			}
		}