private void RenrenCommentGetCallback(object sender, APIRequestCompletedEventArgs e)
{
// Success
if (e.Error == null)
{
DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(List<RenrenNews.Comments.Comment>));
List<RenrenNews.Comments.Comment> commentsResult = serializer.ReadObject(new MemoryStream(Encoding.UTF8.GetBytes(e.ResultJsonString))) as List<RenrenNews.Comments.Comment>;
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
Comments.Clear();
commentsResult.ForEach(p =>
{
CommentViewModel model = RenrenModelConverter.ConvertCommentToCommon(p);
if (model != null)
{
Comments.Add(model);
}
});
UpdateCommentCount(Comments.Count);
AddEmptyTipCommentCleverly();
});
}
// Fail
else
{
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
if (!String.IsNullOrEmpty(PreferenceHelper.GetPreference("Renren_ID")))
{
MessageBox.Show("人人评论获取失败,可能是网络问题,也可能是帐号过期", "失败", MessageBoxButton.OK);
}
});
}
}