Esempio n. 1
0
        public BookshelfDataSource(List <Book> bookList, bool updateMenu, BookshelfViewController parentVC)
        {
            this.updateMenu = updateMenu;
            this.parentVC   = parentVC;
            this.BookList   = bookList;

            if (BookList != null && BookList.Count > 0)
            {
                indexDictionary = new Dictionary <NSIndexPath, BookshelfBookView>();

                // Sort books based on current setting
                BookList = SortBooks(bookList);
            }
        }
Esempio n. 2
0
        public BookshelfBookView(Book book, bool updateMenu, BookshelfViewController parentVC) : base(new CGRect(0, 0, 280, 280))
        {
            this.BookshelfBook = book;
            this.updateMenu    = updateMenu;

            this.BackgroundColor     = UIColor.White;
            this.Layer.ShadowColor   = UIColor.Black.CGColor;
            this.Layer.ShadowOpacity = 0.3f;
            this.Layer.ShadowRadius  = 2f;
            this.Layer.ShadowOffset  = new CGSize(5f, 5f);

            // imageView
            imageView       = new UIImageView();
            imageView.Frame = new CGRect(0, 0, this.Frame.Width, 150);
            this.AddSubview(imageView);

            // recognizer
            this.AddGestureRecognizer(new UILongPressGestureRecognizer(this, new Selector("HandleLongPress:")));

            if (!String.IsNullOrEmpty(BookshelfBook.LargeImageURL))
            {
                // imageSpinner
                imageSpinner        = eBriefingAppearance.GenerateBounceSpinner();
                imageSpinner.Center = imageView.Center;
                this.AddSubview(imageSpinner);

                // Download image
                bool exist = FileDownloader.Download(BookshelfBook.LargeImageURL, parentVC);
                if (exist)
                {
                    bool outDated = false;
                    var  item     = BooksOnDeviceAccessor.GetBook(BookshelfBook.ID);
                    if (item != null)
                    {
                        if (item.ImageVersion < BookshelfBook.ImageVersion)
                        {
                            DownloadedFilesCache.RemoveFile(item.LargeImageURL);
                            DownloadedFilesCache.RemoveFile(item.SmallImageURL);

                            outDated = true;
                        }
                    }

                    if (outDated)
                    {
                        FileDownloader.Download(BookshelfBook.LargeImageURL, parentVC, true);
                    }
                    else
                    {
                        UpdateImage(BookshelfBook.LargeImageURL);
                    }
                }
            }

            // favoriteView
            if (BooksDataAccessor.IsFavorite(book.ID))
            {
                AddFavorite();
            }

            if (book.New)
            {
                AddRibbon();
            }

            // titleLabel
            titleLabel               = eBriefingAppearance.GenerateLabel(16);
            titleLabel.Frame         = new CGRect(10, imageView.Frame.Bottom + 8, 260, 21);
            titleLabel.Lines         = 2;
            titleLabel.LineBreakMode = UILineBreakMode.WordWrap;
            titleLabel.Text          = book.Title;
            titleLabel.SizeToFit();
            titleLabel.Frame = new CGRect(10, titleLabel.Frame.Y, 260, titleLabel.Frame.Height);
            this.AddSubview(titleLabel);

            UpdateUI();
        }