summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2012-03-10 20:59:39 +0400
committerGravatar Vitaly Takmazov2012-03-10 20:59:39 +0400
commit4a664984f58b00493a61cb19fafc0ca01d35b930 (patch)
tree5af7c0ba8165c8bfd63683a6e40702449f5eded6
parent1daf00012658f8cf770eac1ad35bcb23159f29e8 (diff)
remove AvatarClient
-rw-r--r--Juick/App.xaml.cs8
-rw-r--r--Juick/ViewModels/MainViewModel.cs37
-rw-r--r--Juick/ViewModels/ThreadViewModel.cs20
3 files changed, 17 insertions, 48 deletions
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 }); }
- }
-
+
/// <summary>
/// Provides easy access to the root frame of the Phone Application.
/// </summary>
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");