示例#1
0
        public override void Load(Action <bool> callback)
        {
            StoreService instance = StoreService.Instance;
            List <StoreProductFilter> productFilters = new List <StoreProductFilter>();

            productFilters.Add(StoreProductFilter.Purchased);
            Action <BackendResult <List <StockItem>, ResultCode> > callback1 = (Action <BackendResult <List <StockItem>, ResultCode> >)(result =>
            {
                bool flag = result.ResultCode == ResultCode.Succeeded;
                if (flag)
                {
                    Execute.ExecuteOnUIThread((Action)(() =>
                    {
                        List <StockItem> resultData = result.ResultData;
                        this.ClearItems();
                        foreach (StockItem stockItem in resultData.Where <StockItem>((Func <StockItem, bool>)(product => product != null)))
                        {
                            StockItemHeader stockItemHeader = new StockItemHeader(stockItem, false);
                            if (stockItemHeader.IsActive)
                            {
                                this.AddActiveStickers(stockItemHeader);
                            }
                            else
                            {
                                this.HiddenStickers.Add(stockItemHeader);
                            }
                        }
                        this.NotifyProperties();
                    }));
                }
                callback(flag);
            });

            instance.GetStockItems(productFilters, callback1);
        }
        private static List <IVirtualizable> CreateVirtualizableItems(IEnumerable <StockItemHeader> stickers)
        {
            List <IVirtualizable> virtualizableList = new List <IVirtualizable>();

            foreach (StockItemHeader sticker1 in stickers)
            {
                StockItemHeader sticker = sticker1;
                UCItem          ucItem  = new UCItem(480.0, new Thickness(), (Func <UserControlVirtualizable>)(() =>
                {
                    return((UserControlVirtualizable) new StickersPackListItemUC()
                    {
                        DataContext = (object)sticker
                    });
                }), (Func <double>)(() => 100.0), (Action <UserControlVirtualizable>)null, 0.0, false);
                virtualizableList.Add((IVirtualizable)ucItem);
            }
            return(virtualizableList);
        }
示例#3
0
 private void ActivateDeactivate(long productId, bool activate)
 {
     Execute.ExecuteOnUIThread((Action)(() =>
     {
         StockItemHeader stockItemHeader = activate ? this.HiddenStickers.FirstOrDefault <StockItemHeader>((Func <StockItemHeader, bool>)(item => (long)item.ProductId == productId)) : this.ActiveStickers.FirstOrDefault <StockItemHeader>((Func <StockItemHeader, bool>)(item => (long)item.ProductId == productId));
         if (stockItemHeader == null)
         {
             return;
         }
         if (activate)
         {
             this.HiddenStickers.Remove(stockItemHeader);
             this.AddActiveStickers(stockItemHeader);
         }
         else
         {
             this.ActiveStickers.Remove(stockItemHeader);
             this.HiddenStickers.Insert(0, stockItemHeader);
         }
         this.NotifyProperties();
     }));
 }
示例#4
0
 public void Deactivate(StockItemHeader stockItemHeader)
 {
     this.SetProgress(true);
     StorePurchaseManager.DeactivateStickersPack(stockItemHeader, (Action <bool>)(deactivated => this.SetProgress(false)));
 }
示例#5
0
 private void AddActiveStickers(StockItemHeader stockItemHeader)
 {
     this._updatingCollection = true;
     this.ActiveStickers.Add(stockItemHeader);
     this._updatingCollection = false;
 }
        public override void Load(Action <ResultCode> callback)
        {
            StoreService.Instance.GetStickersStoreCatalog(this._isChat ? 0L : this._userOrChatId, (Action <BackendResult <StoreCatalog, ResultCode> >)(result => Execute.ExecuteOnUIThread((Action)(() =>
            {
                StoreCatalog resultData = result.ResultData;
                if ((result.ResultCode != ResultCode.Succeeded ? false : (resultData != null ? true : false)) != false)
                {
                    List <StoreBanner> banners = resultData.banners;
                    if (banners != null)
                    {
                        this.Banners = banners.Select <StoreBanner, StoreBannerHeader>((Func <StoreBanner, StoreBannerHeader>)(banner => new StoreBannerHeader(banner))).ToList <StoreBannerHeader>();
                    }
                    this.NotifyPropertyChanged <List <StoreBannerHeader> >(() => this.Banners);
                    this.NotifyPropertyChanged <Visibility>(() => this.BannersVisibility);
                    this.NotifyPropertyChanged <bool>(() => this.IsSlideViewCycled);
                    this._stickersPacks.Clear();
                    List <StoreSection> sections = resultData.sections;
                    if (sections != null)
                    {
                        foreach (StoreSection storeSection in sections)
                        {/*
                          * List<StockItem> stockItemList1;
                          * if (storeSection == null)
                          * {
                          *     stockItemList1 = null;
                          * }
                          * else
                          * {
                          *     VKList<StockItem> stickers = storeSection.stickers;
                          *     stockItemList1 = stickers != null ? stickers.items : null;
                          * }*/
                         //List<StockItem> stockItemList2 = stockItemList1;//todo:bug?

                            //
                            //  if (stockItemList2 != null)
                            //  {

                            List <StockItemHeader> stockItemHeaderList = new List <StockItemHeader>();
                            List <StockItem> stockItems = storeSection.stickers.items;
                            //List<StockItem> source = stockItems != null ? stockItems.items : null;
                            if (stockItems != null)
                            {
                                foreach (StockItem stockItem1 in stockItems)
                                {
                                    StockItemHeader stockItemHeader = new StockItemHeader(stockItem1, false, this._userOrChatId, this._isChat);
                                    stockItemHeaderList.Add(stockItemHeader);
                                    StoreProduct product = stockItemHeader.StockItem.product;
                                    //
                                    if (((IAccountStickersData)resultData).Products == null)
                                    {
                                        ((IAccountStickersData)resultData).Products = new VKList <StoreProduct>();
                                    }
                                    if (((IAccountStickersData)resultData).StockItems == null)
                                    {
                                        ((IAccountStickersData)resultData).StockItems = new VKList <StockItem>();
                                    }
                                    ((IAccountStickersData)resultData).Products.items.Add(product);
                                    ((IAccountStickersData)resultData).StockItems.items.Add(stockItem1);
                                    //
                                    if (product != null)
                                    {
                                        StockItem stockItem2 = stockItems.FirstOrDefault <StockItem>((Func <StockItem, bool>)(item =>
                                        {
                                            int?nullable = item.product != null ? new int?(item.product.id) : new int?();
                                            if (nullable.GetValueOrDefault() != product.id)
                                            {
                                                return(false);
                                            }
                                            return(nullable.HasValue);
                                        }));
                                        if (stockItem2 != null)
                                        {
                                            stockItemHeader.StockItem.CanPurchaseFor = stockItem2.CanPurchaseFor;
                                        }
                                    }
                                }
                            }
                            this._stickersPacks.Add(stockItemHeaderList);
                            //  }
                            //

                            /*
                             * if (stockItemList2 != null)
                             * {
                             *
                             *  List<StockItemHeader> stockItemHeaderList = new List<StockItemHeader>();
                             *  VKList<StockItem> stockItems = resultData.StockItems;
                             *  List<StockItem> source = stockItems != null ? stockItems.items : null;
                             *  if (source != null)
                             *  {
                             *      foreach (StockItem stockItem1 in stockItemList2)
                             *      {
                             *          StockItemHeader stockItemHeader = new StockItemHeader(stockItem1, false, this._userOrChatId, this._isChat);
                             *          stockItemHeaderList.Add(stockItemHeader);
                             *          StoreProduct product = stockItemHeader.StockItem.product;
                             *          if (product != null)
                             *          {
                             *              StockItem stockItem2 = source.FirstOrDefault<StockItem>((Func<StockItem, bool>)(item =>
                             *              {
                             *                  int? nullable = item.product != null ? new int?(item.product.id) : new int?();
                             *                  if (nullable.GetValueOrDefault() != product.id)
                             *                      return false;
                             *                  return nullable.HasValue;
                             *              }));
                             *              if (stockItem2 != null)
                             *                  stockItemHeader.StockItem.CanPurchaseFor = stockItem2.CanPurchaseFor;
                             *          }
                             *      }
                             *  }
                             *  this._stickersPacks.Add(stockItemHeaderList);
                             * }*/
                        }
                    }
                    this.ReloadItems();
                    StickersSettings.Instance.UpdateStickersDataAndAutoSuggest((IAccountStickersData)resultData);
                    AppGlobalStateManager.Current.GlobalState.NewStoreItemsCount = 0;
                    EventAggregator.Current.Publish(new NewStoreItemsCountChangedEvent());
                }
                callback(result.ResultCode);
            }))));
        }
 public override void Load(Action <ResultCode> callback)
 {
     StoreService.Instance.GetStickersStoreCatalog(this._isChat ? 0L : this._userOrChatId, (Action <BackendResult <StoreCatalog, ResultCode> >)(result => Execute.ExecuteOnUIThread((Action)(() =>
     {
         ResultCode resultCode = result.ResultCode;
         StoreCatalog resultData = result.ResultData;
         if ((resultCode != ResultCode.Succeeded ? 0 : (resultData != null ? 1 : 0)) != 0)
         {
             List <StoreBanner> banners = resultData.banners;
             if (banners != null)
             {
                 this.Banners = banners.Select <StoreBanner, StoreBannerHeader>((Func <StoreBanner, StoreBannerHeader>)(banner => new StoreBannerHeader(banner))).ToList <StoreBannerHeader>();
             }
             this.NotifyPropertyChanged <List <StoreBannerHeader> >(() => this.Banners);
             this.NotifyPropertyChanged <Visibility>(() => this.BannersVisibility);
             this.NotifyPropertyChanged <bool>(() => this.IsSlideViewCycled);
             this._stickersPacks.Clear();
             List <StoreSection> sections = resultData.sections;
             if (sections != null)
             {
                 foreach (StoreSection storeSection in sections)
                 {
                     List <StockItem> stockItemList1;
                     if (storeSection == null)
                     {
                         stockItemList1 = (List <StockItem>)null;
                     }
                     else
                     {
                         VKList <StockItem> stickers = storeSection.stickers;
                         stockItemList1 = stickers != null ? stickers.items : (List <StockItem>)null;
                     }
                     List <StockItem> stockItemList2 = stockItemList1;
                     if (stockItemList2 != null)
                     {
                         List <StockItemHeader> stockItemHeaderList = new List <StockItemHeader>();
                         VKList <StockItem> stockItems = resultData.StockItems;
                         List <StockItem> source = stockItems != null ? stockItems.items : (List <StockItem>)null;
                         if (source != null)
                         {
                             foreach (StockItem stockItem1 in stockItemList2)
                             {
                                 int num1 = 0;
                                 long userOrChatId = this._userOrChatId;
                                 int num2 = this._isChat ? 1 : 0;
                                 StockItemHeader stockItemHeader = new StockItemHeader(stockItem1, num1 != 0, userOrChatId, num2 != 0);
                                 stockItemHeaderList.Add(stockItemHeader);
                                 StoreProduct product = stockItemHeader.StockItem.product;
                                 if (product != null)
                                 {
                                     StockItem stockItem2 = source.FirstOrDefault <StockItem>((Func <StockItem, bool>)(item =>
                                     {
                                         StoreProduct product2 = item.product;
                                         int?nullable = product2 != null ? new int?(product2.id) : new int?();
                                         int id = product.id;
                                         if (nullable.GetValueOrDefault() != id)
                                         {
                                             return(false);
                                         }
                                         return(nullable.HasValue);
                                     }));
                                     if (stockItem2 != null)
                                     {
                                         stockItemHeader.StockItem.CanPurchaseFor = stockItem2.CanPurchaseFor;
                                     }
                                 }
                             }
                         }
                         this._stickersPacks.Add(stockItemHeaderList);
                     }
                 }
             }
             this.ReloadItems();
             StickersSettings.Instance.UpdateStickersDataAndAutoSuggest((IAccountStickersData)resultData);
             AppGlobalStateManager.Current.GlobalState.NewStoreItemsCount = 0;
             EventAggregator.Current.Publish((object)new NewStoreItemsCountChangedEvent());
         }
         callback(resultCode);
     }))));
 }