private List <int> SortBasedOnRecents(List <int> user_stickers)
        {
            List <int> intList1 = new List <int>();

            if (user_stickers == null)
            {
                return(intList1);
            }
            StickersSettings instance = StickersSettings.Instance;
            List <int>       intList2;

            if (instance == null)
            {
                intList2 = null;
            }
            else
            {
                StoreStickers recentStickers = instance.RecentStickers;
                intList2 = recentStickers != null ? recentStickers.sticker_ids : null;
            }
            List <int> intList3 = intList2;

            if (intList3 == null)
            {
                return(user_stickers);
            }
            List <int> .Enumerator enumerator1 = intList3.GetEnumerator();
            try
            {
                while (enumerator1.MoveNext())
                {
                    int current = enumerator1.Current;
                    if (user_stickers.Contains(current))
                    {
                        intList1.Add(current);
                    }
                }
            }
            finally
            {
                enumerator1.Dispose();
            }
            List <int> .Enumerator enumerator2 = user_stickers.GetEnumerator();
            try
            {
                while (enumerator2.MoveNext())
                {
                    int current = enumerator2.Current;
                    if (!intList1.Contains(current))
                    {
                        intList1.Add(current);
                    }
                }
            }
            finally
            {
                enumerator2.Dispose();
            }
            return(intList1);
        }
Пример #2
0
        private static void PreprocessStickersData(IAccountStickersData stickersData)
        {
            VKList <StoreProduct> vkList1  = new VKList <StoreProduct>();
            VKList <StockItem>    vkList2  = new VKList <StockItem>();
            VKList <StoreProduct> products = stickersData.Products;

            if ((products != null ? products.items :  null) != null)
            {
                VKList <StockItem> stockItems = stickersData.StockItems;
                if ((stockItems != null ? stockItems.items :  null) != null)
                {
                    List <StoreProduct> .Enumerator enumerator = stickersData.Products.items.GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            StoreProduct product   = enumerator.Current;
                            StockItem    stockItem = (StockItem)Enumerable.FirstOrDefault <StockItem>(stickersData.StockItems.items, (Func <StockItem, bool>)(i => i.product.id == product.id));
                            if (stockItem != null && product != null && (product.promoted != 1 || product.purchased != 1 || product.active != 0))
                            {
                                product.description = stockItem.description;
                                product.author      = stockItem.author;
                                product.photo_140   = stockItem.photo_140;
                                vkList1.items.Add(product);
                                vkList2.items.Add(stockItem);
                            }
                        }
                    }
                    finally
                    {
                        enumerator.Dispose();
                    }
                    vkList1.count           = vkList1.items.Count;
                    vkList2.count           = vkList2.items.Count;
                    stickersData.Products   = vkList1;
                    stickersData.StockItems = vkList2;
                }
            }
            StoreStickers recentStickers = stickersData.RecentStickers;

            if ((recentStickers != null ? recentStickers.sticker_ids :  null) == null)
            {
                return;
            }
            stickersData.RecentStickers.sticker_ids = (List <int>)Enumerable.ToList <int>(Enumerable.Take <int>(stickersData.RecentStickers.sticker_ids, 32));
        }
Пример #3
0
        private List <int> SortBasedOnRecents(List <int> user_stickers)
        {
            List <int> intList1 = new List <int>();

            if (user_stickers == null)
            {
                return(intList1);
            }
            StickersSettings instance = StickersSettings.Instance;
            List <int>       intList2;

            if (instance == null)
            {
                intList2 = (List <int>)null;
            }
            else
            {
                StoreStickers recentStickers = instance.RecentStickers;
                intList2 = recentStickers != null ? recentStickers.sticker_ids : (List <int>)null;
            }
            List <int> intList3 = intList2;

            if (intList3 == null)
            {
                return(user_stickers);
            }
            foreach (int num in intList3)
            {
                if (user_stickers.Contains(num))
                {
                    intList1.Add(num);
                }
            }
            foreach (int userSticker in user_stickers)
            {
                if (!intList1.Contains(userSticker))
                {
                    intList1.Add(userSticker);
                }
            }
            return(intList1);
        }
Пример #4
0
        private void InsertRecentSticker(int stickerId)
        {
            StoreStickers recentStickers = this.RecentStickers;
            List <int>    intList        = recentStickers != null ? recentStickers.sticker_ids :  null;

            if (intList == null)
            {
                return;
            }
            if (intList.Contains(stickerId))
            {
                intList.Remove(stickerId);
            }
            intList.Insert(0, stickerId);
            if (intList.Count > 32)
            {
                intList = (List <int>)Enumerable.ToList <int>(Enumerable.Take <int>(intList, 32));
            }
            this.RecentStickers.sticker_ids = intList;
            EventAggregator.Current.Publish(new StickersSettings.StickerRecentItemInsertedEvent());
        }
Пример #5
0
        private void InsertRecentSticker(int stickerId)
        {
            StoreStickers recentStickers = this.RecentStickers;
            List <int>    source         = recentStickers != null ? recentStickers.sticker_ids : (List <int>)null;

            if (source == null)
            {
                return;
            }
            if (source.Contains(stickerId))
            {
                source.Remove(stickerId);
            }
            source.Insert(0, stickerId);
            if (source.Count > 32)
            {
                source = source.Take <int>(32).ToList <int>();
            }
            this.RecentStickers.sticker_ids = source;
            EventAggregator.Current.Publish((object)new StickersSettings.StickerRecentItemInsertedEvent());
        }
Пример #6
0
        private static void PreprocessStickersData(IAccountStickersData stickersData)
        {
            VKList <StoreProduct> vkList1  = new VKList <StoreProduct>();
            VKList <StockItem>    vkList2  = new VKList <StockItem>();
            VKList <StoreProduct> products = stickersData.Products;

            if ((products != null ? products.items : (List <StoreProduct>)null) != null)
            {
                VKList <StockItem> stockItems = stickersData.StockItems;
                if ((stockItems != null ? stockItems.items : (List <StockItem>)null) != null)
                {
                    foreach (StoreProduct storeProduct in stickersData.Products.items)
                    {
                        StoreProduct product   = storeProduct;
                        StockItem    stockItem = stickersData.StockItems.items.FirstOrDefault <StockItem>((Func <StockItem, bool>)(i => i.product.id == product.id));
                        if (stockItem != null && product != null && (product.promoted != 1 || product.purchased != 1 || product.active != 0))
                        {
                            product.description = stockItem.description;
                            product.author      = stockItem.author;
                            product.photo_140   = stockItem.photo_140;
                            vkList1.items.Add(product);
                            vkList2.items.Add(stockItem);
                        }
                    }
                    vkList1.count           = vkList1.items.Count;
                    vkList2.count           = vkList2.items.Count;
                    stickersData.Products   = vkList1;
                    stickersData.StockItems = vkList2;
                }
            }
            StoreStickers recentStickers = stickersData.RecentStickers;

            if ((recentStickers != null ? recentStickers.sticker_ids : (List <int>)null) == null)
            {
                return;
            }
            stickersData.RecentStickers.sticker_ids = stickersData.RecentStickers.sticker_ids.Take <int>(32).ToList <int>();
        }