protected override void LoadData()
 {
     if (Items.Count == 0)
         return;
     string maxId = Items[Items.Count - 1].Id;
     var option = new Option();
     option.Add(Const.MAX_ID, maxId);
     tweetService.GetMentions(option,
         tweets =>
         {
             if (!tweets.HasError)
             {
                 #region no more tweets
                 if (tweets.Count == 0)
                 {
                     toastMessageService.HandleMessage(languageHelper.GetString("Toast_Msg_NoMoreMentions"));
                 }
                 #endregion
                 #region add
                 else
                 {
     #if !LOCAL
                     if (maxId == tweets[0].Id)
                         tweets.RemoveAt(0);
     #endif
                     foreach (var tweet in tweets)
                     {
                         Items.Add(tweet);
                     }
                 }
                 #endregion
             }
             base.LoadDataCompleted();
         });
 }
Example #2
0
        public Selector(string selectedValue, IList options)
        {
            foreach (var opt in options)
            {
                Option.Add(opt.ToString());
            }

            SelectedItem = selectedValue;

            Type = options[0]?.GetType();
        }
Example #3
0
        public async Task InitialPoll()
        {
            bool IsVoted  = false;
            var  TempPoll = await DependencyService.Get <IFirebaseDatabase>().GetLastestPoll(groupChatRoom.RoomID);

            _Poll = TempPoll;
            Debug.Write(TempPoll.Title);
            Debug.Write(_Poll.Title);

            foreach (string votedUser in _Poll.Result.Keys)
            {
                if (votedUser.Equals(UserSetting.UserEmail.Replace(".", ":")))
                {
                    IsVoted = true;
                }
            }

            foreach (string TempStr in _Poll._Option)
            {
                if (IsVoted && TempStr.Equals(_Poll.Result[UserSetting.UserEmail.Replace(".", ":")]))
                {
                    Option.Add(new SelectableData <string>(TempStr, true));
                }
                else
                {
                    Option.Add(new SelectableData <string>(TempStr, false));
                }
            }

            if (_Poll.IsClose)
            {
                await App.Current.MainPage.DisplayAlert("Closed", "This poll had been closed", "Ok");

                IsEnablePoll = false;
                IsClosed     = true;
                OnPropertyChanged("IsEnablePoll");
                OnPropertyChanged("IsClosed");
            }
            OnPropertyChanged("_Poll");
        }
Example #4
0
        /// <summary>
        /// 解析额外的参数(Option)
        /// </summary>
        private void ParseOption(Line line)
        {
            string[] strs = line.Content.Split(new string[] { " ", "=", "\"", ";" },
                                               StringSplitOptions.RemoveEmptyEntries);

            if (strs.Length > 2 && strs[0].Equals("option"))
            {
                foreach (KeyValuePair <string, string> keyValuePair in Option)
                {
                    if (keyValuePair.Key.Equals(strs[1]))
                    {
                        throw new ProtoBufferException(string.Format("不能重复添加额外参数:{0}", line));
                    }
                }

                Option.Add(new KeyValuePair <string, string>(strs[1].Trim(), strs[2].Trim()));
            }
            else
            {
                throw new ProtoBufferException(string.Format("不能解析额外条件:{0}", line.ToString()));
            }
        }
 protected override void RefreshData()
 {
     string sinceId = string.Empty;
     var option = new Option();
     if (Items.Count != 0)
     {
         sinceId = items[0].Id;
         option.Add(Const.SINCE_ID, sinceId);
     }
     tweetService.GetMentions(option,
         tweets =>
         {
             if (!tweets.HasError)
             {
                 #region no new tweets yet
                 if (tweets.Count == 0)
                 {
                     toastMessageService.HandleMessage(languageHelper.GetString("Toast_Msg_NoNewMentions"));
                 }
                 #endregion
                 #region add
                 else
                 {
     #if !LOCAL
                     if (sinceId == tweets[tweets.Count - 1].Id)
                         tweets.RemoveAt(tweets.Count - 1);
     #endif
                     for (int i = tweets.Count - 1; i >= 0; i--)
                     {
                         Items.Insert(0, tweets[i]);
                         if (Items.Count >= Const.MAX_COUNT)
                             Items.RemoveAt(Items.Count - 1);
                     }
                 }
             }
                 #endregion
             base.LoadDataCompleted();
         });
 }