using System; using System.Collections.Generic; using System.Device.Location; using System.Windows.Controls; using MahApps.FourSquare.Models; using MahTweets.Mobile.Core; using MahTweets.Mobile.Core.Interfaces; using MahTweets.Mobile.FourSquarePlugin.ViewModels; using MahTweets.Mobile.FourSquarePlugin.Views; namespace MahTweets.Mobile.FourSquarePlugin { public class FourSquare : IKnowWhereYouAre { private readonly MahApps.FourSquare.FourSquare _client = new MahApps.FourSquare.FourSquare("U3GXDF3BLYOQUKRI3MNOYZZVIE1W25OLO5OGANFY1A3IMSKO", "QLY0N1RR3PK2GVNXRXNPSFKRRZJBGDT3HRP2TW13AE211MKP"); private readonly Func _setupViewModelFactory; public Credential Credentials { get; set; } public FourSquare(Func setupViewModelFactory) { _setupViewModelFactory = setupViewModelFactory; } public string Name { get { return "FourSquare"; } } public string Protocol { get { return "foursquare"; } } public static Action OnSuccess { get; set; } public static Action OnFailure { get; set; } public Action ShowDialog { get; set; } public Uri DarkIcon { get { return new Uri("/MahTweets.Mobile.FourSquarePlugin;component/Resources/4sq.png", UriKind.RelativeOrAbsolute); } } public Uri LightIcon { get { return new Uri("/MahTweets.Mobile.FourSquarePlugin;component/Resources/4sq.png", UriKind.RelativeOrAbsolute); } } public void Setup(Action onSuccess, Action onError) { OnSuccess = onSuccess; OnFailure = onError; var setup = new FourSquareSetupView() { DataContext = _setupViewModelFactory() }; ShowDialog(setup); } public void Connect() { } public void Disconnect() { } public void NewLocationUpdate(string text, string id, GeoCoordinate location) { } public void BeginGetVenues(double phoneLatitude, double phoneLongitude, Action> action) { _client.Venue.BeginSearch(phoneLatitude, phoneLongitude, (res, req, obj) => { if (!(obj is Venues)) return; var results = new List(); var venues = (Venues) obj; foreach (var v in venues.Group) { v.Venue.ForEach(results.Add); } action(results); }); } } }