public async void DeleteJoke(JokeItem joke) { Scroll = ScrollEnum.NoScroll; JokeList.Remove(joke); UpdateBindedCollection(); if (Device.RuntimePlatform == Device.Android || Device.RuntimePlatform == Device.UWP) { await _databaseService.DeleteJoke(joke); } }
public async void AddJokeAsync() { try { if (!string.IsNullOrEmpty(url)) { Scroll = ScrollEnum.Scroll; var actualCategory = (Category == 0) ? (CategoryEnum)random.Next(1, 16) : Category; var joke = await _jokeService.GetJokeAsync(url, actualCategory.ToString().ToLower()); //if category is "All", select random one if (joke != null) { int id = 1; if (JokeList.Count > 0) { id = JokeList.Last().Id + 1; } var jokeItem = new JokeItem { Id = id, Icon = iconUrl, Joke = joke.value, Url = new Uri(joke.url), RestId = joke.icon_url, Category = actualCategory }; JokeList.Add(jokeItem); UpdateBindedCollection(); if (Device.RuntimePlatform == Device.Android || Device.RuntimePlatform == Device.UWP) { await _databaseService.AddJoke(jokeItem); } } else { _toastMessage.ShowToast(commonErrorMessage); } } else { _toastMessage.ShowToast(apiErrorMessage); } } catch { _toastMessage.ShowToast(commonErrorMessage); } }
public async void RequestQuote() { try { if (!string.IsNullOrEmpty(quoteUrl)) { Scroll = ScrollEnum.Scroll; var quotes = await _tronaldDumpService.GetQuoteAsync(quoteUrl); if (quotes != null) { var id = 1; if (Quotes.Count > 0) { id = Quotes.Last().Id + 1; } var quote = new QuoteItem { Id = id, Quote = quotes.value, Tags = quotes.tags, Icon = iconUrl }; Quotes.Add(quote); if (Device.RuntimePlatform == Device.Android || Device.RuntimePlatform == Device.UWP) { await _databaseService.AddQuote(new QuoteDbItem { Icon = quote.Icon, Id = quote.Id, Quote = quote.Quote, Tags = String.Join(";", quote.Tags.ToArray()) }); } } else { _toastMessage.ShowToast(commonErrorMessage); } } else { _toastMessage.ShowToast(apiErrorMessage); } } catch { _toastMessage.ShowToast(commonErrorMessage); } }
public void DoScroll(ScrollEnum instruction) { switch (instruction) { case ScrollEnum.Grow: this.Grow(); return; case ScrollEnum.Shrink: this.Shrink(); return; case ScrollEnum.Toggle: this.Toggle(); return; } }
private void Carousel_OnScrolled(object sender, ItemsViewScrolledEventArgs e) { if (_scrollStatus == ScrollEnum.EndScrolling) { _scrollStatus = ScrollEnum.StartScrolling; if (_scrollStatus == ScrollEnum.StartScrolling) { rates.FadeTo(1, 500, Easing.Linear); } } else { if (_scrollStatus == ScrollEnum.StartScrolling) { rates.FadeTo(0, 100, Easing.Linear); } _scrollStatus++; } }
public async void DeleteQuote(QuoteItem quote) { Scroll = ScrollEnum.NoScroll; if (quote != null) { Quotes.Remove(quote); } else { _toastMessage.ShowToast(selectErrorMessage); } if (Device.RuntimePlatform == Device.Android || Device.RuntimePlatform == Device.UWP) { await _databaseService.DeleteQuote(new QuoteDbItem { Icon = quote.Icon, Id = quote.Id, Quote = quote.Quote, Tags = String.Join(";", quote.Tags.ToArray()) }); } }
public void DoScroll(ScrollEnum instruction) { switch (instruction) { case ScrollEnum.Grow: this.Grow(); return; case ScrollEnum.Shrink: this.Shrink(); return; case ScrollEnum.Toggle: this.Toggle(); return; } }