Last active
January 14, 2016 23:44
-
-
Save rmenezes/d1a98e18f19c6555c6c2 to your computer and use it in GitHub Desktop.
FacebookCallBack Sample for Xamarin.Android
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Xamarin.Facebook; | |
using CupcakeStore.Android.Activities; | |
using Xamarin.Facebook.Login; | |
using Android.Runtime; | |
namespace CupcakeStore.Android | |
{ | |
public class FacebookCallback<TResult> : Java.Lang.Object, IFacebookCallback | |
where TResult : Java.Lang.Object | |
{ | |
public Action HandleCancel { get; set; } | |
public Action<FacebookException> HandleError { get; set; } | |
public Action<TResult> HandleSuccess { get; set; } | |
public FacebookCallback () | |
{ | |
} | |
public void OnCancel () | |
{ | |
var handle = HandleCancel; | |
if (handle != null) | |
handle (); | |
} | |
public void OnError (FacebookException error) | |
{ | |
var handle = HandleError; | |
if (handle != null) | |
handle (error); | |
} | |
public void OnSuccess (Java.Lang.Object result) | |
{ | |
var handle = HandleSuccess; | |
if (handle != null) | |
handle (result.JavaCast<TResult> ()); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment