From 4a664984f58b00493a61cb19fafc0ca01d35b930 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sat, 10 Mar 2012 20:59:39 +0400 Subject: remove AvatarClient --- Juick/App.xaml.cs | 8 +------- Juick/ViewModels/MainViewModel.cs | 37 ++++++++++--------------------------- Juick/ViewModels/ThreadViewModel.cs | 20 ++++++-------------- 3 files changed, 17 insertions(+), 48 deletions(-) (limited to 'Juick') diff --git a/Juick/App.xaml.cs b/Juick/App.xaml.cs index b73398c..69dbe16 100644 --- a/Juick/App.xaml.cs +++ b/Juick/App.xaml.cs @@ -38,13 +38,7 @@ namespace Juick { get { return _cl ?? (_cl = new RestClient("http://api.juick.com") {UserAgent = "Juick 0.999/Windows Phone " + Environment.OSVersion.Version}); } } - - private static RestClient _acl; - public static RestClient AvatarClient - { - get { return _acl ?? (_acl = new RestClient("http://i.juick.com") { UserAgent = "Juick 0.999/Windows Phone " + Environment.OSVersion.Version }); } - } - + /// /// Provides easy access to the root frame of the Phone Application. /// diff --git a/Juick/ViewModels/MainViewModel.cs b/Juick/ViewModels/MainViewModel.cs index ed244d7..3ee4a16 100644 --- a/Juick/ViewModels/MainViewModel.cs +++ b/Juick/ViewModels/MainViewModel.cs @@ -66,20 +66,13 @@ namespace Juick.ViewModels post.Replies) }; MyFeed.Add(item); - var imageRequest = - new RestRequest( - string.Format("/as/{0}.png", - post.User.Uid)); - App.AvatarClient.ExecuteAsync( - imageRequest, restResponse => + var imageUri = new Uri(string.Format("http://i.juick.com/as/{0}.png", post.User.Uid), UriKind.Absolute); + item.UserAvatar = new BitmapImage { - item.UserAvatar = new BitmapImage - (); - item.UserAvatar.SetSource(new MemoryStream(restResponse.RawBytes)); - item. - NotifyPropertyChanged - ("UserAvatar"); - }); + UriSource = imageUri + }; + item.NotifyPropertyChanged("UserAvatar"); + }); NotifyPropertyChanged("MyFeed"); @@ -102,20 +95,10 @@ namespace Juick.ViewModels post.Replies) }; Last.Add(item); - var imageRequest = - new RestRequest( - string.Format("/as/{0}.png", - post.User.Uid)); - App.AvatarClient.ExecuteAsync( - imageRequest, restResponse => - { - item.UserAvatar = new BitmapImage - (); - item.UserAvatar.SetSource(new MemoryStream(restResponse.RawBytes)); - item. - NotifyPropertyChanged - ("UserAvatar"); - }); + var imageUri = new Uri(string.Format("http://i.juick.com/as/{0}.png", post.User.Uid), UriKind.Absolute); + item.UserAvatar = new BitmapImage {UriSource = imageUri}; + item.NotifyPropertyChanged("UserAvatar"); + if (post.Photo != null) { item.Attachment = new BitmapImage {UriSource = new Uri(post.Photo.Small, UriKind.Absolute)}; diff --git a/Juick/ViewModels/ThreadViewModel.cs b/Juick/ViewModels/ThreadViewModel.cs index 80d8b3e..a929700 100644 --- a/Juick/ViewModels/ThreadViewModel.cs +++ b/Juick/ViewModels/ThreadViewModel.cs @@ -48,20 +48,12 @@ namespace Juick.ViewModels { var item = new MessageViewModel(post); Items.Add(item); - var imageRequest = - new RestRequest( - string.Format("/as/{0}.png", - post.User.Uid)); - App.AvatarClient.ExecuteAsync( - imageRequest, restResponse => - { - item.UserAvatar = new BitmapImage - (); - item.UserAvatar.SetSource(new MemoryStream(restResponse.RawBytes)); - item. - NotifyPropertyChanged - ("UserAvatar"); - }); + var imageUri = new Uri(string.Format("http://i.juick.com/as/{0}.png", post.User.Uid), UriKind.Absolute); + item.UserAvatar = new BitmapImage + { + UriSource = imageUri + }; + item.NotifyPropertyChanged("UserAvatar"); }); IsDataLoaded = true; NotifyPropertyChanged("Items"); -- cgit v1.2.3