public void OnLoadFinished (Loader loader, Java.Lang.Object data)
		{
			var cursor = data.JavaCast<ICursor> ();

			TextView tv = ((Activity) mContext).FindViewById <TextView> (Resource.Id.sample_output);

			// Reset text in case of a previous query
			tv.Text = mContext.GetText (Resource.String.intro_message) + "\n\n";

			if (cursor.Count == 0) {
				return;
			}

			// Pulling the relevant value from the cursor requires knowing the column index to pull
			// it from.

			int phoneColumnIndex =  cursor.GetColumnIndex (ContactsContract.CommonDataKinds.Phone.Number);
			int emailColumnIndex = cursor.GetColumnIndex (ContactsContract.CommonDataKinds.Email.Address);
			int nameColumnIndex = cursor.GetColumnIndex (ContactsContract.CommonDataKinds.Contactables.InterfaceConsts.DisplayName);
			int lookupColumnIndex = cursor.GetColumnIndex (ContactsContract.CommonDataKinds.Contactables.InterfaceConsts.LookupKey);
			int typeColumnIndex = cursor.GetColumnIndex (ContactsContract.CommonDataKinds.Contactables.InterfaceConsts.Mimetype);


			cursor.MoveToFirst ();
			// Lookup key is the easiest way to verify a row of data is for the same
			// contact as the previous row.
			String lookupKey = "";
			do {

				String currentLookupKey = cursor.GetString (lookupColumnIndex);
				if (!lookupKey.Equals (currentLookupKey)) {
					String displayName = cursor.GetString (nameColumnIndex);
					tv.Append (displayName + "\n");
					lookupKey = currentLookupKey;
				}


				// The data type can be determined using the mime type column.
				String mimeType = cursor.GetString (typeColumnIndex);
				if (mimeType.Equals (ContactsContract.CommonDataKinds.Phone.ContentItemType)) {
					tv.Append ("\tPhone Number: " + cursor.GetString (phoneColumnIndex) + "\n");
				} else if (mimeType.Equals (ContactsContract.CommonDataKinds.Email.ContentItemType)) {
					tv.Append ("\tEmail Address: " + cursor.GetString (emailColumnIndex) + "\n");
				}


				// Look at DDMS to see all the columns returned by a query to Contactables.
				// Behold, the firehose!
				foreach (String column in cursor.GetColumnNames ()) {
					  Log.Debug (TAG, column + column + ": " +
					      cursor.GetString (cursor.GetColumnIndex (column)) + "\n");
				}
			} while (cursor.MoveToNext ());
		}
        public override void OnNestedScroll(CoordinatorLayout coordinatorLayout, Java.Lang.Object child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed)
        {
            base.OnNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);

            var floatingActionButtonChild = child.JavaCast<FloatingActionButton>();

            if (dyConsumed > 0 && floatingActionButtonChild.Visibility == ViewStates.Visible)
                floatingActionButtonChild.Hide();
            else if (dyConsumed < 0 && floatingActionButtonChild.Visibility != ViewStates.Visible)
                floatingActionButtonChild.Show();
        }
		public void OnResult (Java.Lang.Object result)
		{
			googleApiClient.Disconnect ();
			IDataApiDeleteDataItemsResult deleteDataItemsResult;
			try 
			{
				deleteDataItemsResult = result.JavaCast<IDataApiDeleteDataItemsResult>();
			}
			catch {
				return;
			}
			if (!deleteDataItemsResult.Status.IsSuccess)
				Log.Error (Tag, "DismissWearableNotification(): Failed to delete IDataItem");
		}
			public void Apply (Java.Lang.Object calendarCell)
			{
				if (calendarCell.Class.SimpleName == "CalendarMonthCell") {
					return;
				}

				CalendarDayCell dayCell = calendarCell.JavaCast<CalendarDayCell> ();
				if (dayCell.CellType != CalendarCellType.Date) {
					return;
				}

				this.calendar.TimeInMillis = dayCell.Date;
				
				if (calendar.Get (CalendarField.DayOfWeek) == Calendar.Saturday) {
					dayCell.Selectable = false;
				} else {
					dayCell.Selectable = true;
				}
			}
示例#5
0
        public void OnResult(Java.Lang.Object result)
        {
            if (state == 0) {
                state = 1;
                var apiResult = result.JavaCast<INodeApiGetConnectedNodesResult> ();
                var nodes = apiResult.Nodes;
                var phoneNode = nodes.FirstOrDefault ();
                if (phoneNode == null) {
                    DisplayError ();
                    return;
                }

                WearableClass.MessageApi.SendMessage (client, phoneNode.Id,
                                                      "/bikenow/SearchNearestStations/" + ActionStatus.ToString (),
                                                      new byte[0]).SetResultCallback (this);
            } else {
                state = 0;
                var apiResult = result.JavaCast<IMessageApiSendMessageResult> ();
                Android.Util.Log.Info ("SendMessage", apiResult.RequestId.ToString ());
            }
        }
示例#6
0
			public void OnResult (Java.Lang.Object result)
			{
				var ar = result.JavaCast<ILeaderboardsLoadScoresResult>();
				if (ar != null) {
					var id = ar.Leaderboard.LeaderboardId;
					if (!helper.scores.ContainsKey (id)) {
						helper.scores.Add (id, new List<ILeaderboardScore> ());
					}
					helper.scores [id].Clear ();
					var count = ar.Scores.Count;
					for (int i = 0; i < count; i++) {
						var score = ar.Scores.Get(i).JavaCast<ILeaderboardScore> ();
						helper.scores [id].Add (score);
					}
				}
			}
 public void OnResult(Java.Lang.Object result)
 {
     var dataItemResult = result.JavaCast<IDataApiDataItemResult> ();
     if (dataItemResult.Status.IsSuccess && dataItemResult.DataItem != null) {
         var configDataItem = dataItemResult.DataItem;
         var dataMapItem = DataMapItem.FromDataItem (configDataItem);
         SetupAllPickers (dataMapItem.DataMap);
     } else {
         SetupAllPickers (null);
     }
 }
		//Follow the same flow as the MainActivity for the Wearable (Wearable/MainActivity has more details).
		public void OnResult (Java.Lang.Object raw)
		{
			Exception nodeException, messageException;
			try {
				var nodeResult = raw.JavaCast<INodeApiGetConnectedNodesResult> ();
				foreach (var node in nodeResult.Nodes)
					WearableClass.MessageApi.SendMessage (mGoogleApiClient, node.Id, START_ACTIVITY_PATH, new byte[0])
							.SetResultCallback (this);
				return;
			} catch (Exception e) {
				nodeException = e;
			}
			try {
				var messageResult = raw.JavaCast<IMessageApiSendMessageResult> ();
				if (!messageResult.Status.IsSuccess)
					Log.Error (TAG, "Failed to connect to Google Api Client with status "
					+ messageResult.Status);
				return;
			} catch (Exception e) {
				messageException = e;
			}
			//We should never get to this point
			Log.Wtf (TAG, "Unexpected type for OnResult");
			Log.Error (TAG, "Node Exception", nodeException);
			Log.Error (TAG, "Message Exception", messageException);
		}
示例#9
0
 public override void OnSuccess(Java.Lang.Object jObject)
 {
     PurchaseResult purchaseResult = jObject.JavaCast<PurchaseResult>();
     if (null == purchaseResult) {
         m_debugText = string.Format ("PurchaseResult is null!");
     } else {
         m_debugText = string.Format ("Request Purchase: OnSuccess");
         Log.Info (TAG, "OnSuccess identiifer"+purchaseResult.ProductIdentifier);
     }
 }
 public void OnFinished(Kiip p0, Java.Lang.Object p1)
 {
     ME.Kiip.Api.Resource response = p1.JavaCast<ME.Kiip.Api.Resource>();
     example.toast(response.ToString());
 }
        /// <summary>
        /// On Geofence Request Result
        /// </summary>
        /// <param name="result"></param>
        public void OnResult(Java.Lang.Object result)
        {
            var res = result.JavaCast<IResult>();
          
            int statusCode = res.Status.StatusCode;
            string message = string.Empty;

            switch (res.Status.StatusCode)
            {
                case Android.Gms.Location.GeofenceStatusCodes.SuccessCache:
                case Android.Gms.Location.GeofenceStatusCodes.Success:
                    if (CurrentRequestType == RequestType.Add)
                    {
                        message = string.Format("{0} - {1}", CrossGeofence.Id, "Successfully added Geofence.");
                        
                        foreach (GeofenceCircularRegion region in Regions.Values)
                        {
                            CrossGeofence.GeofenceListener.OnMonitoringStarted(region.Id);
                        }
                    }
                    else
                    {
                        message = string.Format("{0} - {1}", CrossGeofence.Id, "Geofence Update Received");
                    }
                    
                    break;
                case Android.Gms.Location.GeofenceStatusCodes.Error:
                    message = string.Format("{0} - {1}", CrossGeofence.Id, "Error adding Geofence.");
                    break;
                case Android.Gms.Location.GeofenceStatusCodes.GeofenceTooManyGeofences:
                    message = string.Format("{0} - {1}", CrossGeofence.Id, "Too many geofences.");
                    break;
                case Android.Gms.Location.GeofenceStatusCodes.GeofenceTooManyPendingIntents:
                    message = string.Format("{0} - {1}", CrossGeofence.Id, "Too many pending intents.");
                    break;
                case Android.Gms.Location.GeofenceStatusCodes.GeofenceNotAvailable:
                    message = string.Format("{0} - {1}", CrossGeofence.Id, "Geofence not available.");
                    break;
            }

            System.Diagnostics.Debug.WriteLine(message);

            if (statusCode != Android.Gms.Location.GeofenceStatusCodes.Success && statusCode != Android.Gms.Location.GeofenceStatusCodes.SuccessCache && IsMonitoring)
            {
                // Rather than force killing all running geofences, delegate action on geofence failures to the application.
                // This lets the application decide to ignore the error, perform retry logic, stop monitoring as below, or any other behavior.
                // StopMonitoringAllRegions();
                ((GeofenceImplementation)CrossGeofence.Current).LocationHasError = true;

                if (!string.IsNullOrEmpty(message))
                    CrossGeofence.GeofenceListener.OnError(message);
            }
        }
示例#12
0
		public override bool OnDependentViewChanged (CoordinatorLayout parent, Java.Lang.Object child, View dependency)
		{
			// Move the fab vertically to place correctly wrt the info pane
			var fab = child.JavaCast<SwitchableFab> ();
			var currentInfoPaneY = ViewCompat.GetTranslationY (dependency);
			var newTransY = (int)Math.Max (0, dependency.Height - currentInfoPaneY - minMarginBottom - fab.Height / 2);
			ViewCompat.SetTranslationY (fab, -newTransY);

			// If alternating between open/closed state, change the FAB face
			if (wasOpened ^ ((InfoPane)dependency).Opened) {
				fab.Switch ();
				wasOpened = !wasOpened;
			}

			return true;
		}
示例#13
0
        public void OnResult(Java.Lang.Object result)
        {
            var apiResult = result.JavaCast<ICapabilityApiGetCapabilityResult> ();
            var nodes = apiResult.Capability.Nodes;
            phoneNode = nodes.FirstOrDefault ();
            if (phoneNode == null) {
                DisplayError ();
                return;
            }

            WearableClass.MessageApi.SendMessage (client, phoneNode.Id,
                                                  SearchStationPath + ActionStatus.ToString (),
                                                  new byte[0]);
        }
 public void OnResult(Java.Lang.Object statusRaw)
 {
     var status = statusRaw.JavaCast<Statuses>();
     if (status.IsSuccess) {
         var myHandler = new Handler ();
         myHandler.Post (() => {
             Android.Widget.Toast.MakeText (this, "Geofencing Started.", Android.Widget.ToastLength.Long).Show ();
         });
     } else {
         var myHandler = new Handler ();
         myHandler.Post (() => {
             Android.Widget.Toast.MakeText (this, "Error Starting Geofencing.", Android.Widget.ToastLength.Long).Show ();
         });
     }
 }
		//Since Java bytecode does not support generics, casting between types can be messy. Handle everything here.
		public void OnResult (Java.Lang.Object raw)
		{
			Exception nodeException, messageException;
			try {
				//send the message
				var nodeResult = raw.JavaCast<INodeApiGetConnectedNodesResult> ();
				foreach (var node in nodeResult.Nodes)
					WearableClass.MessageApi.SendMessage (mGoogleApiClient, node.Id, path, new byte[0]).SetResultCallback (this); //will go to second try/catch block
				return;
			} catch (Exception e) {
				nodeException = e;
			}
			try {
				//check that it worked correctly
				var messageResult = raw.JavaCast<IMessageApiSendMessageResult> ();
				if (!messageResult.Status.IsSuccess)
					Log.Error (TAG, "Failed to connect to Google Api Client with status "
					+ messageResult.Status);
				return;
			} catch (Exception e) {
				messageException = e;
			}
			//Will never get here
			Log.Warn (TAG, "Unexpected type for OnResult");
			Log.Error (TAG, "Node Exception", nodeException);
			Log.Error (TAG, "Message Exception", messageException);
		}
 public void OnFinished(Kiip p0, Java.Lang.Object p1)
 {
     ME.Kiip.Api.Resource response = p1.JavaCast<ME.Kiip.Api.Resource>();
     if (response != null)
     {
         if (mRewardActionToggle.Checked)
         {
             p0.ShowResource(response);
         }
         else
         {
             example.toast("Reward Queued");
             example.mResources.Add(response);
         }
     }
     else
     {
         example.toast("No Reward");
     }
 }
 public void OnResult(Java.Lang.Object result)
 {
     var dataItemResult = result.JavaCast<IDataApiDataItemResult> ();
     if (dataItemResult.Status.IsSuccess) {
         OnResultAction (dataItemResult);
     }
 }
示例#18
0
 public override void OnSuccess(Java.Lang.Object jObject)
 {
     GamerInfo gamerInfo = jObject.JavaCast<GamerInfo>();
     if (null == gamerInfo) {
         m_debugText = string.Format ("GamerInfo is null!");
     } else {
         m_debugText = string.Format ("Request Gamer UUID={0} Username={1}", gamerInfo.Uuid, gamerInfo.Username);
         Log.Info (TAG, "OnSuccess uuid=" + gamerInfo.Uuid + " username=" + gamerInfo.Username);
     }
 }
 public void OnResult(Java.Lang.Object result)
 {
     var localNodeResult = result.JavaCast<INodeApiGetLocalNodeResult> ();
     OnResultAction (localNodeResult);
 }
示例#20
0
		/// <summary>
		/// Destroys the item.
		/// </summary>
		/// <param name="container">The container.</param>
		/// <param name="position">The position.</param>
		/// <param name="object">The object.</param>
		public override void DestroyItem(Android.Views.View container, int position, Java.Lang.Object @object)
		{
			//activePickerViews[position].OnDateSelected -= HandleOnDateSelected;
			//activePickerViews.Remove(position);
			var monthView = @object.JavaCast<MonthView>();
			(container.JavaCast<Android.Support.V4.View.ViewPager>()).RemoveView(monthView);
			_reusableMonthView = monthView;
			_activeMonthViews.Remove(position);
		}
		/**
     	* Dislays either the name of the first contact or a message.
     	*/
		public void OnLoadFinished (Loader loader, Java.Lang.Object data)
		{
			var cursor = data.JavaCast <ICursor> ();

			if (cursor != null) {
				int totalCount = cursor.Count;
				if (totalCount > 0) {
					cursor.MoveToFirst ();
					string name = cursor.GetString (cursor.GetColumnIndex (ContactsContract.Contacts.InterfaceConsts.DisplayName));
					messageText.Text = Resources.GetString (Resource.String.contacts_string, totalCount, name);
					CommonSampleLibrary.Log.Debug (TAG, "First contact loaded: " + name);
					CommonSampleLibrary.Log.Debug (TAG, "Total number of contacts: " + totalCount);
				} else {
					CommonSampleLibrary.Log.Debug (TAG, "List of contacts is empty.");
					messageText.Text = GetString (Resource.String.contacts_empty);
				}
			}
		}
			public void OnLoadFinished (Android.Support.V4.Content.Loader loader, Java.Lang.Object data)
			{
				// Swap the new cursor in.  (The framework will take care of closing the
	            // old cursor once we return.)
				_adapter.SwapCursor(data.JavaCast<ICursor>());
				
	            // The list should now be shown.
				if (IsResumed)
					SetListShown(true);
				else
					SetListShownNoAnimation(true);
			}
示例#23
0
 public override void OnSuccess(Java.Lang.Object jObject)
 {
     s_products.Clear ();
     JavaList<Product> products = jObject.JavaCast<JavaList<Product>> ();
     if (null == products) {
         m_debugText = string.Format ("Products are null!");
     } else {
         foreach (Product product in products) {
             s_products.Add (product);
         }
         m_debugText = string.Format ("Request Products: OnSuccess Count="+products.Count);
         Log.Info (TAG, "CustomRequestProductsListener: OnSuccess");
     }
 }
 public void OnSuccess(Java.Lang.Object result)
 {
     AuthenticationResult aresult = result.JavaCast<AuthenticationResult>();
     if (aresult != null)
     {
         App.ExchangeToken = aresult.AccessToken;
         SignInComplete(aresult, context);
     }
 }
示例#25
0
 public override void OnSuccess(Java.Lang.Object jObject)
 {
     s_receipts.Clear ();
     JavaCollection<Receipt> receipts = jObject.JavaCast<JavaCollection<Receipt>> ();
     if (null == receipts) {
         m_debugText = string.Format ("Receipts are null!");
     } else {
         foreach (Receipt receipt in receipts) {
             s_receipts.Add (receipt);
         }
         m_debugText = string.Format ("Request Receipts: OnSuccess Count="+s_receipts.Count);
         Log.Info (TAG, "OnSuccess");
     }
 }
            public void OnSuccess(Java.Lang.Object result)
            {
                AuthenticationResult aresult = result.JavaCast<AuthenticationResult>();
                if (aresult != null)
                {
                    App.Token = aresult.AccessToken;

                    authContext.AcquireToken((Activity)context,
                        Constants.EXCHANGE_RESOURCE_ID,
                        Constants.AAD_CLIENT_ID,
                        Constants.AAD_REDIRECT_URL,
                        PromptBehavior.RefreshSession,
                        new ExchangeCallback((Activity)context));
                }
            }
        /// <summary>
        /// On Geofence Request Result
        /// </summary>
        /// <param name="result"></param>
        public void OnResult(Java.Lang.Object result)
        {
            var res = result.JavaCast<IResult>();
          
            int statusCode = res.Status.StatusCode;
            string message = string.Empty;

            switch (res.Status.StatusCode)
            {
                case Android.Gms.Location.GeofenceStatusCodes.SuccessCache:
                case Android.Gms.Location.GeofenceStatusCodes.Success:
                    if (CurrentRequestType == RequestType.Add)
                    {
                        message = string.Format("{0} - {1}", CrossGeofence.Id, "Successfully added Geofence.");
                        
                        foreach (GeofenceCircularRegion region in Regions.Values)
                        {
                            CrossGeofence.GeofenceListener.OnMonitoringStarted(region.Id);
                        }
                    }
                    else
                    {
                        message = string.Format("{0} - {1}", CrossGeofence.Id, "Geofence Update Received");
                    }
                    
                    break;
                case Android.Gms.Location.GeofenceStatusCodes.Error:
                    message = string.Format("{0} - {1}", CrossGeofence.Id, "Error adding Geofence.");
                    break;
                case Android.Gms.Location.GeofenceStatusCodes.GeofenceTooManyGeofences:
                    message = string.Format("{0} - {1}", CrossGeofence.Id, "Too many geofences.");
                    break;
                case Android.Gms.Location.GeofenceStatusCodes.GeofenceTooManyPendingIntents:
                    message = string.Format("{0} - {1}", CrossGeofence.Id, "Too many pending intents.");
                    break;
                case Android.Gms.Location.GeofenceStatusCodes.GeofenceNotAvailable:
                    message = string.Format("{0} - {1}", CrossGeofence.Id, "Geofence not available.");
                    break;
            }

            System.Diagnostics.Debug.WriteLine(message);

            if (statusCode != Android.Gms.Location.GeofenceStatusCodes.Success && statusCode != Android.Gms.Location.GeofenceStatusCodes.SuccessCache && IsMonitoring)
            {
                StopMonitoringAllRegions();


                if (!string.IsNullOrEmpty(message))
                    CrossGeofence.GeofenceListener.OnError(message);
            }
        }
示例#28
0
			public void OnResult (Java.Lang.Object result)
			{
				var ar = result.JavaCast<IAchievementsLoadAchievementsResult>();
				if (ar != null) {
					helper.achievments.Clear ();
					var count = ar.Achievements.Count;
					for (int i = 0; i < count; i++) {
						var item = ar.Achievements.Get (i);
						var a = item.JavaCast<IAchievement> ();
						helper.achievments.Add (a);
					}
				}
			}
示例#29
0
    public void OnResult(Java.Lang.Object result)
    {
      var apiResult = result.JavaCast<INodeApiGetConnectedNodesResult>();
      var nodes = apiResult.Nodes;
      phoneNode = nodes.FirstOrDefault();
      if (phoneNode == null)
      {
        DisplayError();
        return;
      }

      WearableClass.MessageApi.SendMessage(client, phoneNode.Id,
                                            TweetsPath,
                                            new byte[0]);
    }
示例#30
0
 public override void OnLoadFinished(Android.Support.V4.Content.Loader p0, Java.Lang.Object p1)
 {
     OnLoadFinished (p0, p1.JavaCast<Android.Support.V7.Util.SortedList> ());
 }