예제 #1
0
        public override UICollectionViewCell GetCell(UICollectionView collectionView, NSIndexPath indexPath)
        {
            if (_presenter.Count == (_flowDelegate.IsProfile ? (int)indexPath.Item - 1 : (int)indexPath.Item) && !_presenter.IsLastReaded)
            {
                var loader = (LoaderCollectionCell)collectionView.DequeueReusableCell(nameof(LoaderCollectionCell), indexPath);
                loader.SetLoader();
                return(loader);
            }
            else
            {
                if (indexPath.Row == 0 && _flowDelegate.IsProfile)
                {
                    var profile = (ProfileHeaderViewCell)collectionView.DequeueReusableCell(nameof(ProfileHeaderViewCell), indexPath);

                    if (profile.ContentView.Subviews.Length == 0)
                    {
                        profile.ContentView.AddSubview(_flowDelegate.profileCell);
                    }

                    if (!_flowDelegate.profileCell.IsProfileActionSet)
                    {
                        _flowDelegate.profileCell.ProfileAction += ProfileAction;
                    }

                    _flowDelegate.UpdateProfile(null);

                    return(profile);
                }
                else
                {
                    UICollectionViewCell cell;
                    var post = _presenter[_flowDelegate.IsProfile ? (int)indexPath.Item - 1 : (int)indexPath.Item];

                    if (IsGrid)
                    {
                        cell = (PhotoCollectionViewCell)collectionView.DequeueReusableCell(nameof(PhotoCollectionViewCell), indexPath);
                        if (post != null)
                        {
                            ((PhotoCollectionViewCell)cell).UpdateCell(post);
                        }
                    }
                    else
                    {
                        cell = (NewFeedCollectionViewCell)collectionView.DequeueReusableCell(nameof(NewFeedCollectionViewCell), indexPath);

                        if (post != null)
                        {
                            ((NewFeedCollectionViewCell)cell).Cell.UpdateCell(post, _flowDelegate.Variables[_flowDelegate.IsProfile ? (int)indexPath.Item - 1 : (int)indexPath.Item]);
                        }

                        if (!((NewFeedCollectionViewCell)cell).Cell.IsCellActionSet)
                        {
                            ((NewFeedCollectionViewCell)cell).Cell.CellAction += CellAction;
                            ((NewFeedCollectionViewCell)cell).Cell.TagAction  += TagAction;
                        }
                    }

                    return(cell);
                }
            }
        }
예제 #2
0
        public async Task <UserProfileResponse> GetUserInfo()
        {
            if (errorMessage == null)
            {
                return(_userData);
            }
            _userDataLoaded     = false;
            errorMessage.Hidden = true;
            try
            {
                var exception = await _presenter.TryGetUserInfo(Username);

                _refreshControl.EndRefreshing();

                if (exception == null)
                {
                    _userData = _presenter.UserProfileResponse;
                    if (_userData.IsSubscribed)
                    {
                        if (!AppSettings.User.WatchedUsers.Contains(_userData.Username))
                        {
                            AppSettings.User.WatchedUsers.Add(_userData.Username);
                        }
                    }
                    else
                    {
                        AppSettings.User.WatchedUsers.Remove(_userData.Username);
                    }

                    _collectionViewSource.user = _userData;
                    _gridDelegate.UpdateProfile(_userData);

                    if (powerText != null)
                    {
                        powerText.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.PowerOfLike, _userData.VotingPower);
                    }

                    if (!_refreshControl.Refreshing)
                    {
                        collectionView.ContentInset = new UIEdgeInsets(0, 0, 0, 0);

                        if (collectionView.Hidden)
                        {
                            collectionView.ContentOffset = new CGPoint(0, 0);
                        }
                        collectionView.Hidden = false;
                    }
                }
                return(_userData);
            }
            catch (Exception ex)
            {
                errorMessage.Hidden = false;
                AppSettings.Logger.Error(ex);
            }
            finally
            {
                _userDataLoaded = true;
                loading.StopAnimating();
            }
            return(_userData);
        }