Ejemplo n.º 1
0
        private void Send()
        {
            var newTweet = new Tweet {
                Text = this.Text, CreatedAt = DateTime.Now, UserName = "******"
            };

            TweetList.Insert(0, newTweet);
            Tweet = newTweet;
            Text  = "";
        }
Ejemplo n.º 2
0
        private async void FetchHomeTimeline(object obj)
        {
            if (HomeTimelineCommand.CanExecute(obj) == false)
            {
                return;
            }

            try
            {
                IsGettingTimeline = true;

                await PopupService.Flash(Application.Current.MainWindow, "タイムライン取得中");

                var tweets = (await Client.FetchHomeTimeline()).Select(tweet => new TweetControlViewModel(tweet));

                if (tweets.Max(t => t?.Id) == TweetList.Max(t => t?.Id))
                {
                    return;
                }

                var excepts        = Enumerable.Except(tweets.Select(t => t.Id), TweetList.Select(t => t.Id));
                var orderedExcepts = tweets.Where(t => excepts.Contains(t.Id)).OrderBy(t => t.Id);

                foreach (var content in orderedExcepts)
                {
                    content.SetProfileAndMediaSource();
                    Dispatcher.Invoke(() => TweetList.Insert(0, content));
                }
            }
            catch (AggregateException err)
            {
                foreach (var ie in err.InnerExceptions)
                {
                    throw ie;
                }
            }
            catch (CoreTweet.TwitterException err)
            {
                Debug.WriteLine(err);
                MessageBox.Show("Twitter API 取得制限に達しました。\r\n15分間の利用が制限されています。");
            }
            finally
            {
                IsGettingTimeline = false;
                await PopupService.Flash(Application.Current.MainWindow, "タイムライン取得完了");
            }
        }
Ejemplo n.º 3
0
        public MainViewModelDesign()
        {
            Text = "Text for a new tweet";
            var now = DateTime.Now;

            TweetList.Insert(0, new Tweet {
                Text = "Creating a simple Twitter app for Android with MvvmQuickCross", UserName = "******", CreatedAt = now.AddSeconds(-115)
            });
            TweetList.Insert(0, new Tweet {
                Text = "Created an Android solution with an application and a library project", UserName = "******", CreatedAt = now.AddSeconds(-63)
            });
            TweetList.Insert(0, new Tweet {
                Text = "Added Tweet model class", UserName = "******", CreatedAt = now.AddSeconds(-45)
            });
            TweetList.Insert(0, new Tweet {
                Text = "Added viewmodel properties and commands with code snippets", UserName = "******", CreatedAt = now.AddSeconds(-25)
            });
            TweetList.Insert(0, new Tweet {
                Text = "Added some hardcoded design data fot the viewmodel", UserName = "******", CreatedAt = now.AddSeconds(-1)
            });
        }