private BaseFetcher SelectDefaultFetcher()
 {
     BaseFetcher fetcher = null;
     if(!String.IsNullOrEmpty(PreferenceHelper.GetPreference("SinaWeibo_ID"))
         && !String.IsNullOrEmpty(PreferenceHelper.GetPreference("SinaWeibo_FollowerID"))
         && !String.IsNullOrEmpty(PreferenceHelper.GetPreference("SinaWeibo_Token")))
     {
         LogoSource = PreferenceHelper.GetPreference("SinaWeibo_FollowerAvatar2");
         Name = PreferenceHelper.GetPreference("SinaWeibo_FollowerNickName");
         HerID = PreferenceHelper.GetPreference("SinaWeibo_FollowerID");
         fetcher = new SinaWeiboFetcher();
         m_type = EntryType.SinaWeibo;
     }
     else if (!String.IsNullOrEmpty(PreferenceHelper.GetPreference("Renren_ID"))
         && !String.IsNullOrEmpty(PreferenceHelper.GetPreference("Renren_FollowerID")))
     {
         // 因为人人的avatar2 很可能是不规则的,所以这里用低清的
         LogoSource = PreferenceHelper.GetPreference("Renren_FollowerAvatar");
         Name = PreferenceHelper.GetPreference("Renren_FollowerNickName");
         HerID = PreferenceHelper.GetPreference("Renren_FollowerID");
         fetcher = new RenrenFetcher();
         m_type = EntryType.Renren;
     }
     else if (!String.IsNullOrEmpty(PreferenceHelper.GetPreference("Douban_ID"))
         && !String.IsNullOrEmpty(PreferenceHelper.GetPreference("Douban_FollowerID"))
         && !String.IsNullOrEmpty(PreferenceHelper.GetPreference("Douban_Token")))
     {
         LogoSource = PreferenceHelper.GetPreference("Douban_FollowerAvatar2");
         Name = PreferenceHelper.GetPreference("Douban_FollowerNickName");
         HerID = PreferenceHelper.GetPreference("Renren_FollowerID");
         fetcher = new DoubanFetcher();
         m_type = EntryType.Douban;
     }
     return fetcher;
 }
示例#2
0
 private void RefreshCommentsForSinaWeibo()
 {
     if (string.IsNullOrEmpty(m_itemViewModel.ID))
         return;
     SinaWeiboFetcher fetcher = new SinaWeiboFetcher();
     fetcher.LoadSinaWeiboCommentByStatusID(m_itemViewModel.ID, (comments) =>
     {
         if (comments == null)
         {
             return;
         }
         Deployment.Current.Dispatcher.BeginInvoke(() =>
         {
             Comments.Clear();
             foreach (Comment comment in comments.comments)
             {
                 CommentViewModel model = SinaWeiboModelConverter.ConvertCommentToCommon(comment);
                 if (model != null)
                 {
                     Comments.Add(model);
                 }
             }
             UpdateCommentCount(comments.comments.Length);
             AddEmptyTipCommentCleverly();
         });
     });
 }
        private void Refersh(EntryType type)
        {
            Name = MiscTool.GetHerName();
            LogoSource = MiscTool.GetHerIconUrl();
            m_progressIndicatorHelper.PushTask();
            BaseFetcher fetcher;

            switch (type)
            {
                case EntryType.SinaWeibo:
                    fetcher = new SinaWeiboFetcher();
                    LogoSource = PreferenceHelper.GetPreference("SinaWeibo_FollowerAvatar2");
                    Name = PreferenceHelper.GetPreference("SinaWeibo_FollowerNickName");
                    HerID = PreferenceHelper.GetPreference("SinaWeibo_FollowerID");
                    break;
                case EntryType.Renren:
                    fetcher = new RenrenFetcher();
                    LogoSource = PreferenceHelper.GetPreference("Renren_FollowerAvatar2");
                    Name = PreferenceHelper.GetPreference("Renren_FollowerNickName");
                    HerID = PreferenceHelper.GetPreference("Renren_FollowerID");
                    break;
                case EntryType.Douban:
                    fetcher = new DoubanFetcher();
                    LogoSource = PreferenceHelper.GetPreference("Douban_FollowerAvatar");
                    Name = PreferenceHelper.GetPreference("Douban_FollowerNickName");
                    HerID = PreferenceHelper.GetPreference("Douban_FollowerID");
                    break;
                default:
                    fetcher = SelectDefaultFetcher();
                    break;
            }
            if (fetcher == null)
            {
                m_progressIndicatorHelper.PopTask();
                return;
            }
            fetcher.FetchCommentManList((List<CommentMan> list) =>
            {
                m_listMan = list;
                if (list == null)
                {
                    m_progressIndicatorHelper.PopTask();
                    return;
                }
                GetData();
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    ContentPanel.Children.Clear();
                    ContentPanel.Children.Add(new PotentialEnemy(name1, value1, name2, value2, name3, value3));
                });
                m_progressIndicatorHelper.PopTask();
            });
        }