Exemple #1
0
        public override void Execute(object parameter)
        {
            Model.Topic topic = null;
            if (parameter is ItemClickEventArgs)
            {
                var itemClick = parameter as ItemClickEventArgs;
                topic = itemClick.ClickedItem as Model.Topic;
            }
            else if (parameter is Model.Topic)
            {
                topic = (Model.Topic)parameter;
            }
            else if (parameter is IDictionary)
            {
                var elements = (Dictionary <object, object>)parameter;
                topic = elements["topic"] as Model.Topic;
                var desiredPage      = elements["page"]?.ToString();
                var desiredPageValue = 0;
                if (!int.TryParse(desiredPage, out desiredPageValue))
                {
                    return;
                }
                topic.TopicCurrentPage = desiredPageValue;
            }

            if (topic == null)
            {
                return;
            }

            if (!Loc.Main.Topics.Any())
            {
                Loc.Main.Topics.Add(topic);
            }
            else
            {
                Loc.Main.Topics[0] = topic;
            }
            Loc.Topic.SelectedTopic = 0;

            Task.Run(async() => await TopicFetcher.GetPosts(Loc.Topic.CurrentTopic));

            if (Loc.NavigationService.CurrentView != View.Main)
            {
                Loc.NavigationService.Navigate(View.Main);
            }
        }
Exemple #2
0
        public async Task RefreshPage(EditorIntent editorIntent)
        {
            await ThreadUI.Invoke(() =>
            {
                switch (editorIntent)
                {
                case EditorIntent.New:
                case EditorIntent.Quote:
                case EditorIntent.MultiQuote:
                    CurrentTopic.TopicCurrentPage = CurrentTopic.TopicNbPage;
                    break;

                case EditorIntent.Edit:
                    break;

                default:
                    break;
                }
            });

            await Task.Run(async() => await TopicFetcher.GetPosts(CurrentTopic));
        }
 public override void Execute(object parameter)
 {
     // Don't forget Index starts at 1, not 0, here.
     if (parameter is string)
     {
         var action = (string)parameter;
         if (action == "+" && Loc.Topic.CurrentTopic.TopicCurrentPage < Loc.Topic.CurrentTopic.TopicNbPage)
         {
             Loc.Topic.CurrentTopic.TopicCurrentPage = Loc.Topic.CurrentTopic.TopicCurrentPage + 1;
         }
         else if (action == "-" && Loc.Topic.CurrentTopic.TopicCurrentPage > 1)
         {
             Loc.Topic.CurrentTopic.TopicCurrentPage = Loc.Topic.CurrentTopic.TopicCurrentPage - 1;
         }
         else if (action == Strings.Last)
         {
             Loc.Topic.CurrentTopic.TopicCurrentPage = Loc.Topic.CurrentTopic.TopicNbPage;
         }
         else if (action == Strings.First)
         {
             Loc.Topic.CurrentTopic.TopicCurrentPage = 1;
         }
         else if (!string.IsNullOrEmpty(action))
         {
             int index = -1;
             if (!int.TryParse(action, out index))
             {
                 return;
             }
             if (index == 0 || index > Loc.Topic.CurrentTopic.TopicNbPage)
             {
                 return;
             }
             Loc.Topic.CurrentTopic.TopicCurrentPage = index;
         }
         Task.Run(() => TopicFetcher.GetPosts(Loc.Topic.CurrentTopic));
     }
 }
Exemple #4
0
 public Task RefreshPage()
 {
     return(Task.Run(async() => await TopicFetcher.GetPosts(CurrentTopic)));
 }
Exemple #5
0
 public override void Execute(object parameter)
 {
     Task.Run(async() => await TopicFetcher.GetPosts(Loc.Topic.CurrentTopic));
 }