Created
February 17, 2014 20:33
-
-
Save vackup/9058548 to your computer and use it in GitHub Desktop.
This file contains 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 Android.App; | |
using Android.Content; | |
using Android.Runtime; | |
using Android.Views; | |
using Android.Widget; | |
using Android.OS; | |
namespace ODataMobile | |
{ | |
using System.Collections.Generic; | |
using System.Threading.Tasks; | |
using Simple.OData.Client; | |
[Activity(Label = "ODataMobile", MainLauncher = true, Icon = "@drawable/icon")] | |
public class MainActivity : ListActivity | |
{ | |
private readonly TaskScheduler uiScheduler = TaskScheduler.FromCurrentSynchronizationContext(); | |
private List<string> entities = new List<string>(); | |
private ODataClient client; | |
private void StartRestRequestAsync() | |
{ | |
Task<IEnumerable<IDictionary<string,object>>>.Factory.StartNew(() => | |
{ | |
var packages = client.FindEntries("Packages?$filter=Title eq 'Simple.OData.Client'"); | |
return packages; //IEnumerable<IDictionary<string, object>> | |
}).ContinueWith( | |
t => | |
{ | |
var packages = t.Result; | |
foreach (var package in packages) | |
{ | |
entities.Add(package["Description"].ToString() + " " + package["Version"].ToString()); | |
} | |
ListAdapter = new ArrayAdapter<string>( | |
this, Android.Resource.Layout.SimpleListItem1, entities); | |
}, | |
uiScheduler); | |
} | |
protected override void OnCreate(Bundle bundle) | |
{ | |
base.OnCreate(bundle); | |
client = new ODataClient("http://packages.nuget.org/v1/FeedService.svc/"); | |
StartRestRequestAsync(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment