コード例 #1
0
        public override int GetHashCode()
        {
            int hashCode = -54185413;

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Title);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Description);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Payload);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(ProviderToken);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Currency);

            hashCode = hashCode * -1521134295 + EqualityComparer <IEnumerable <LabeledPrice> > .Default.GetHashCode(Prices);

            hashCode = hashCode * -1521134295 + MaxTipAmount.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <IEnumerable <uint> > .Default.GetHashCode(SuggestedTipAmounts);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(ProviderData);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(PhotoUrl);

            hashCode = hashCode * -1521134295 + PhotoSize.GetHashCode();
            hashCode = hashCode * -1521134295 + PhotoWidth.GetHashCode();
            hashCode = hashCode * -1521134295 + PhotoHeight.GetHashCode();
            hashCode = hashCode * -1521134295 + NeedName.GetHashCode();
            hashCode = hashCode * -1521134295 + NeedPhoneNumber.GetHashCode();
            hashCode = hashCode * -1521134295 + NeedEmail.GetHashCode();
            hashCode = hashCode * -1521134295 + NeedShippingAddress.GetHashCode();
            hashCode = hashCode * -1521134295 + SendPhoneNumberToProvider.GetHashCode();
            hashCode = hashCode * -1521134295 + SendEmailToProvider.GetHashCode();
            hashCode = hashCode * -1521134295 + IsFlexible.GetHashCode();
            return(hashCode);
        }
コード例 #2
0
        public override int GetHashCode()
        {
            int hashCode = 1395552640;

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Id);

            hashCode = hashCode * -1521134295 + EqualityComparer <InlineKeyboardMarkup> .Default.GetHashCode(ReplyMarkup);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(ParseMode);

            hashCode = hashCode * -1521134295 + EqualityComparer <IEnumerable <MessageEntity> > .Default.GetHashCode(CaptionEntities);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Type);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(PhotoUrl);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Title);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(ThumbUrl);

            hashCode = hashCode * -1521134295 + PhotoWidth.GetHashCode();
            hashCode = hashCode * -1521134295 + PhotoHeight.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Description);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Caption);

            hashCode = hashCode * -1521134295 + EqualityComparer <InputMessageContent> .Default.GetHashCode(InputMessageContent);

            return(hashCode);
        }
コード例 #3
0
        public override void UpdateCell(Post post)
        {
            _currentPost      = post;
            avatarImage.Image = null;
            _scheduledWorkAvatar?.Cancel();

            bodyImage.Image = null;
            _scheduledWorkBody?.Cancel();

            var media = _currentPost.Media[0];

            _scheduledWorkBody = ImageService.Instance.LoadUrl(media.Url, Helpers.Constants.ImageCacheDuration)
                                 //.Retry(5)
                                 .FadeAnimation(false)
                                 .WithCache(FFImageLoading.Cache.CacheType.All)
                                 .DownSample((int)UIScreen.MainScreen.Bounds.Width)
                                 .WithPriority(LoadingPriority.Highest)
                                 .Into(bodyImage);

            if (!string.IsNullOrEmpty(_currentPost.Avatar))
            {
                _scheduledWorkAvatar = ImageService.Instance.LoadUrl(_currentPost.Avatar, TimeSpan.FromDays(30))
                                       .WithCache(FFImageLoading.Cache.CacheType.All)
                                       .FadeAnimation(false)
                                       .DownSample(200)
                                       .LoadingPlaceholder("ic_noavatar.png")
                                       .ErrorPlaceholder("ic_noavatar.png")
                                       .WithPriority(LoadingPriority.Normal)
                                       .Into(avatarImage);
            }
            else
            {
                avatarImage.Image = UIImage.FromBundle("ic_noavatar");
            }

            topLikers.Hidden = true;
            if (_currentPost.TopLikersAvatars.Count() >= 1 && !string.IsNullOrEmpty(_currentPost.TopLikersAvatars[0]))
            {
                _scheduledWorkfirst?.Cancel();
                firstLiker.Image    = null;
                topLikers.Hidden    = false;
                firstLiker.Hidden   = false;
                _scheduledWorkfirst = ImageService.Instance.LoadUrl(_currentPost.TopLikersAvatars[0], TimeSpan.FromDays(30))
                                      .WithCache(FFImageLoading.Cache.CacheType.All)
                                      .LoadingPlaceholder("ic_noavatar.png")
                                      .ErrorPlaceholder("ic_noavatar.png")
                                      .DownSample(width: 100)
                                      .WithPriority(LoadingPriority.Lowest)
                                      .Into(firstLiker);
            }
            else
            {
                firstLiker.Hidden = true;
            }

            if (_currentPost.TopLikersAvatars.Count() >= 2 && !string.IsNullOrEmpty(_currentPost.TopLikersAvatars[1]))
            {
                _scheduledWorksecond?.Cancel();
                secondLiker.Image    = null;
                secondLiker.Hidden   = false;
                _scheduledWorksecond = ImageService.Instance.LoadUrl(_currentPost.TopLikersAvatars[1], TimeSpan.FromDays(30))
                                       .WithCache(FFImageLoading.Cache.CacheType.All)
                                       .LoadingPlaceholder("ic_noavatar.png")
                                       .ErrorPlaceholder("ic_noavatar.png")
                                       .WithPriority(LoadingPriority.Lowest)
                                       .DownSample(width: 100)
                                       .Into(secondLiker);
            }
            else
            {
                secondLiker.Hidden = true;
            }

            if (_currentPost.TopLikersAvatars.Count() >= 3 && !string.IsNullOrEmpty(_currentPost.TopLikersAvatars[2]))
            {
                _scheduledWorkthird?.Cancel();
                thirdLiker.Image    = null;
                thirdLiker.Hidden   = false;
                _scheduledWorkthird = ImageService.Instance.LoadUrl(_currentPost.TopLikersAvatars[2], TimeSpan.FromDays(30))
                                      .WithCache(FFImageLoading.Cache.CacheType.All)
                                      .LoadingPlaceholder("ic_noavatar.png")
                                      .ErrorPlaceholder("ic_noavatar.png")
                                      .WithPriority(LoadingPriority.Lowest)
                                      .DownSample(width: 100)
                                      .Into(thirdLiker);
            }
            else
            {
                thirdLiker.Hidden = true;
            }

            cellText.Text  = _currentPost.Author;
            rewards.Hidden = !BasePresenter.User.IsNeedRewards;
            //rewards.Text = BaseViewController.ToFormatedCurrencyString(_currentPost.TotalPayoutReward);

            netVotes.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.Like, _currentPost.NetVotes);

            if (_currentPost.VoteChanging)
            {
                Animate();
            }
            else
            {
                likeButton.Transform = CGAffineTransform.MakeScale(1f, 1f);
                likeButton.Selected  = _currentPost.Vote;
            }

            flagButton.Selected  = _currentPost.Flag;
            viewCommentText.Text = _currentPost.Children == 0
                ? AppSettings.LocalizationManager.GetText(LocalizationKeys.PostFirstComment)
                : AppSettings.LocalizationManager.GetText(LocalizationKeys.ViewComments, _currentPost.Children);

            likeButton.Enabled = true;
            flagButton.Enabled = true;
            postTimeStamp.Text = _currentPost.Created.ToPostTime();

            imageHeight.Constant      = PhotoHeight.Get(media.Size);
            contentViewWidth.Constant = UIScreen.MainScreen.Bounds.Width;

            if (!_isButtonBinded)
            {
                cellText.Font        = Helpers.Constants.Semibold14;
                postTimeStamp.Font   = Helpers.Constants.Regular12;
                netVotes.Font        = Helpers.Constants.Semibold14;
                rewards.Font         = Helpers.Constants.Semibold14;
                viewCommentText.Font = Helpers.Constants.Regular14;

                avatarImage.Layer.CornerRadius = avatarImage.Frame.Size.Width / 2;
                firstLiker.Layer.CornerRadius  = firstLiker.Frame.Size.Width / 2;
                secondLiker.Layer.CornerRadius = secondLiker.Frame.Size.Width / 2;
                thirdLiker.Layer.CornerRadius  = thirdLiker.Frame.Size.Width / 2;

                attributedLabel = new TTTAttributedLabel();
                attributedLabel.EnabledTextCheckingTypes = NSTextCheckingType.Link;
                var prop = new NSDictionary();
                attributedLabel.LinkAttributes       = prop;
                attributedLabel.ActiveLinkAttributes = prop;

                commentView.AddSubview(attributedLabel);
                attributedLabel.Font  = Helpers.Constants.Regular14;
                attributedLabel.Lines = 0;
                attributedLabel.UserInteractionEnabled = true;
                attributedLabel.Enabled = true;
                attributedLabel.AutoPinEdgeToSuperviewEdge(ALEdge.Left, 15f);
                attributedLabel.AutoPinEdgeToSuperviewEdge(ALEdge.Right, 15f);
                attributedLabel.AutoPinEdgeToSuperviewEdge(ALEdge.Top, 15f);
                viewCommentText.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, attributedLabel, 5f);
                attributedLabel.Delegate = new TTTAttributedLabelFeedDelegate(TagAction);

                UITapGestureRecognizer tap = new UITapGestureRecognizer(() =>
                {
                    CellAction?.Invoke(ActionType.Preview, _currentPost);
                });
                bodyImage.AddGestureRecognizer(tap);

                UITapGestureRecognizer imageTap = new UITapGestureRecognizer(() =>
                {
                    CellAction?.Invoke(ActionType.Profile, _currentPost);
                });
                UITapGestureRecognizer textTap = new UITapGestureRecognizer(() =>
                {
                    CellAction?.Invoke(ActionType.Profile, _currentPost);
                });
                UITapGestureRecognizer moneyTap = new UITapGestureRecognizer(() =>
                {
                    CellAction?.Invoke(ActionType.Profile, _currentPost);
                });
                avatarImage.AddGestureRecognizer(imageTap);
                cellText.AddGestureRecognizer(textTap);
                rewards.AddGestureRecognizer(moneyTap);

                UITapGestureRecognizer commentTap = new UITapGestureRecognizer(() =>
                {
                    CellAction?.Invoke(ActionType.Comments, _currentPost);
                });
                viewCommentText.AddGestureRecognizer(commentTap);

                UITapGestureRecognizer netVotesTap = new UITapGestureRecognizer(() =>
                {
                    CellAction?.Invoke(ActionType.Voters, _currentPost);
                });
                netVotes.AddGestureRecognizer(netVotesTap);

                flagButton.TouchDown += FlagButton_TouchDown;
                likeButton.TouchDown += LikeTap;

                _isButtonBinded = true;

                Debug.WriteLine("Cell created");
            }

            var noLinkAttribute = new UIStringAttributes
            {
                Font            = Helpers.Constants.Regular14,
                ForegroundColor = Helpers.Constants.R15G24B30,
            };

            var at = new NSMutableAttributedString();

            at.Append(new NSAttributedString(_currentPost.Title, noLinkAttribute));
            if (!string.IsNullOrEmpty(_currentPost.Description))
            {
                at.Append(new NSAttributedString(Environment.NewLine));
                at.Append(new NSAttributedString(Environment.NewLine));
                at.Append(new NSAttributedString(_currentPost.Description, noLinkAttribute));
            }

            foreach (var tag in _currentPost.Tags)
            {
                if (tag == "steepshot")
                {
                    continue;
                }
                var linkAttribute = new UIStringAttributes
                {
                    Link            = new NSUrl(tag),
                    Font            = Helpers.Constants.Regular14,
                    ForegroundColor = Helpers.Constants.R231G72B0,
                };
                at.Append(new NSAttributedString($" #{tag}", linkAttribute));
            }
            attributedLabel.SetText(at);
        }