예제 #1
0
        public TweetsView(string ticker)
        {
            InitializeComponent();
            var viewModel = new TwitterViewModel(ticker);

            BindingContext = viewModel;
            viewModel.LoadTweetsCommand();

            TweetList.ItemSelected += (sender, args) =>
            {
                if (TweetList.SelectedItem == null)
                {
                    return;
                }

                Navigation.PushAsync(new ContentPage
                {
                    Content = new WebView
                    {
                        Source = new UrlWebViewSource
                        {
                            Url = ((Tweet)TweetList.SelectedItem).Url
                        }
                    }
                });

                TweetList.SelectedItem = null;
            };
        }
예제 #2
0
        // Moved the code here so we can await the async call

        private async Task InitializeAsync()
        {
            BindingContext = viewModel;

            await viewModel.LoadTweetsCommand();

            TweetList.ItemSelected += (sender, args) =>
            {
                if (TweetList.SelectedItem == null)
                {
                    return;
                }

                Navigation.PushAsync(new ContentPage
                {
                    Content = new WebView
                    {
                        Source = new UrlWebViewSource
                        {
                            Url = ((Tweet)TweetList.SelectedItem).Url
                        }
                    }
                });

                TweetList.SelectedItem = null;
            };
        }
예제 #3
0
        private async void ButtonSearch_Click(object sender, RoutedEventArgs e)
        {
            Progress.Visibility = System.Windows.Visibility.Visible;

            await viewModel.LoadTweetsCommand(TextBoxSearch.Text);

            Tweets.ItemsSource = viewModel.Tweets;

            Progress.Visibility = System.Windows.Visibility.Collapsed;
        }
예제 #4
0
        async partial void ButtonGetTweets_TouchUpInside(UIButton sender)
        {
            ButtonGetTweets.Enabled = false;
            activityIndicator.StartAnimating();
            TextFieldSearch.ResignFirstResponder();


            await viewModel.LoadTweetsCommand(TextFieldSearch.Text.Trim());

            TableViewTweets.ReloadData();

            activityIndicator.StopAnimating();
            ButtonGetTweets.Enabled = true;
        }
예제 #5
0
        async void OnLoadPressed(object o, EventArgs e)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy             = true;
            LoadTweets.Enabled = false;
            Search.ResignFirstResponder();
            await viewModel.LoadTweetsCommand(Search.StringValue.Trim());

            TweetTable.ReloadData();
            TweetTable.SizeToFit();
            LoadTweets.Enabled = true;
            IsBusy             = false;
        }
예제 #6
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            var search   = FindViewById <EditText>(Resource.Id.search_text);
            var button   = FindViewById <Button>(Resource.Id.get_tweets);
            var listView = FindViewById <ListView>(Resource.Id.listView);
            var progress = FindViewById <ProgressBar>(Resource.Id.progressBar);

            progress.Indeterminate = true;
            progress.Visibility    = ViewStates.Invisible;


            button.Click += async(sender, args) =>
            {
                button.Enabled = false;

                progress.Visibility = ViewStates.Visible;

                await viewModel.LoadTweetsCommand(search.Text.Trim());


                listView.Adapter = new TweetAdapter(this, viewModel);

                progress.Visibility = ViewStates.Invisible;
                button.Enabled      = true;
            };

            listView.ItemClick += (sender, args) =>
            {
                viewModel.Speak(args.Position);
            };
        }