private void UpdateStickersAsync(TLFeaturedStickers cachedStickers) { var hash = cachedStickers != null ? cachedStickers.HashValue : new TLInt(0); IsWorking = true; MTProtoService.GetFeaturedStickersAsync(true, hash, result => BeginOnUIThread(() => { Status = string.Empty; IsWorking = false; var featuredStickers = result as TLFeaturedStickers; if (featuredStickers != null) { Status = featuredStickers.Sets.Count > 0 ? string.Empty : AppResources.NoSetsHere; Items.Clear(); cachedStickers = featuredStickers; StateService.SaveFeaturedStickersAsync(cachedStickers); UpdateSets(featuredStickers, featuredStickers.Unread); } ReadFeaturedStickersAsync(featuredStickers ?? cachedStickers); }), error => BeginOnUIThread(() => { Status = string.Empty; IsWorking = false; Execute.ShowDebugMessage("messages.getFeaturedStickers error " + error); })); }
private void UpdateStickersAsync(TLFeaturedStickers cachedStickers) { var hash = cachedStickers != null ? cachedStickers.HashValue : new TLInt(0); IsWorking = true; MTProtoService.GetFeaturedStickersAsync(true, hash, result => BeginOnUIThread(() => { IsWorking = false; var featuredStickers = result as TLFeaturedStickers; if (featuredStickers != null) { UpdateSets(featuredStickers, featuredStickers.Unread); UpdateStickersSubtitle(featuredStickers, _allStickers, _masks); StateService.SaveFeaturedStickersAsync(featuredStickers); } }), error => BeginOnUIThread(() => { IsWorking = false; Execute.ShowDebugMessage("messages.getFeaturedStickers error " + error); })); }
public void GetAllStickersAsync() { StateService.GetAllStickersAsync(cachedStickers => { Stickers = cachedStickers; var cachedStickers43 = cachedStickers as TLAllStickers43; if (cachedStickers43 != null && cachedStickers43.FavedStickers == null) { MTProtoService.GetFavedStickersAsync(new TLInt(0), result => { var favedStickers = result as TLFavedStickers; if (favedStickers != null) { cachedStickers43.FavedStickers = favedStickers; StateService.SaveAllStickersAsync(cachedStickers43); } }, error => { }); } var featuredStickers = StateService.GetFeaturedStickers(); if (featuredStickers == null) { MTProtoService.GetFeaturedStickersAsync(true, new TLInt(0), result => { featuredStickers = result as TLFeaturedStickers; if (featuredStickers != null) { StateService.SaveFeaturedStickersAsync(featuredStickers); } }, error => { }); } var cachedStickers29 = cachedStickers as TLAllStickers29; if (cachedStickers29 != null && cachedStickers29.Date != null && cachedStickers29.Date.Value != 0) { var date = TLUtils.ToDateTime(cachedStickers29.Date); if ( date < DateTime.Now.AddSeconds(Constants.GetAllStickersInterval)) { return; } } var hash = cachedStickers != null ? cachedStickers.Hash ?? TLString.Empty : TLString.Empty; MTProtoService.GetAllStickersAsync(hash, result => { var allStickers = result as TLAllStickers43; if (allStickers != null) { if (cachedStickers29 != null) { allStickers.ShowStickersTab = cachedStickers29.ShowStickersTab; allStickers.RecentlyUsed = cachedStickers29.RecentlyUsed; allStickers.Date = TLUtils.DateToUniversalTimeTLInt(0, DateTime.Now); } if (cachedStickers43 != null) { allStickers.RecentStickers = cachedStickers43.RecentStickers; allStickers.FavedStickers = cachedStickers43.FavedStickers; } Stickers = allStickers; cachedStickers = allStickers; StateService.SaveAllStickersAsync(cachedStickers); } }, error => { Execute.ShowDebugMessage("messages.getAllStickers error " + error); }); }); }
public void ForwardInAnimationComplete() { StateService.GetAllStickersAsync(cachedAllStickers => BeginOnUIThread(() => { _allStickers = cachedAllStickers; var allStickers = _allStickers as TLAllStickers43; if (allStickers != null) { UpdateShowStickersByEmojiSubtitle(allStickers.ShowStickersByEmoji); UpdateSets(allStickers, () => UpdateAllStickersAsync(allStickers)); Status = string.Empty; } else { UpdateAllStickersAsync(null); } })); StateService.GetFeaturedStickersAsync(cachedFeaturedStickers => BeginOnUIThread(() => { if (cachedFeaturedStickers != null) { UpdateFeaturedSetsString(cachedFeaturedStickers.Unread.Count); } _featuredStickers = cachedFeaturedStickers; var featuredStickersHash = _featuredStickers != null ? _featuredStickers.HashValue : new TLInt(0); MTProtoService.GetFeaturedStickersAsync(false, featuredStickersHash, result => BeginOnUIThread(() => { var featuredStickers = result as TLFeaturedStickers; if (featuredStickers != null) { if (_featuredStickers != null) { _featuredStickers.Unread = featuredStickers.Unread; } UpdateFeaturedSetsString(featuredStickers.Unread.Count); } }), error => { Execute.ShowDebugMessage("messages.getFeaturedStickers error " + error); }); })); StateService.GetArchivedStickersAsync(cachedArchivedStickers => BeginOnUIThread(() => { if (cachedArchivedStickers != null) { UpdateArchivedSetsString(cachedArchivedStickers.Count.Value); } _archivedStickers = cachedArchivedStickers; MTProtoService.GetArchivedStickersAsync(false, new TLLong(0), new TLInt(0), result => BeginOnUIThread(() => { UpdateArchivedSetsString(result.Count.Value); }), error => { Execute.ShowDebugMessage("messages.getArchivedStickers error " + error); }); })); }