Skip to content

Instantly share code, notes, and snippets.

@icebeam7
Created April 12, 2018 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icebeam7/823545849ae5c9871f9ccfd43775c1cc to your computer and use it in GitHub Desktop.
Save icebeam7/823545849ae5c9871f9ccfd43775c1cc to your computer and use it in GitHub Desktop.
Sentimental Tweets: PaginaTweets.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using SentimentalTweets.Servicios;
using SentimentalTweets.Modelos;
namespace SentimentalTweets.Paginas
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class PaginaTweets : ContentPage
{
public PaginaTweets()
{
InitializeComponent();
}
void Loading(bool mostrar)
{
indicator.IsEnabled = mostrar;
indicator.IsRunning = mostrar;
}
public async void btnBuscar_Clicked(object sender, EventArgs e)
{
var busqueda = txtBusqueda.Text;
if (!string.IsNullOrWhiteSpace(busqueda))
{
Loading(true);
var tweets = await ServicioTwitter.ObtenerTweets(busqueda);
lsvTweets.ItemsSource = tweets;
Loading(false);
}
else
{
await DisplayAlert("Advertencia", "Debes introducir un término de búsqueda", "OK");
}
}
private async void lsvTweets_ItemSelected(object sender, SelectedItemChangedEventArgs e)
{
try
{
var tweet = (Tweet)e.SelectedItem;
await Navigation.PushAsync(new PaginaAnalisisTweet(tweet));
}
catch (Exception ex)
{
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment