public override UICollectionReusableView GetViewForSupplementaryElement(UICollectionView collectionView, NSString elementKind, NSIndexPath indexPath)
        {
            mvxLog.Trace("SupplementaryCollectionViewSource GetViewForSupplementaryElement started");

            if (elementKind == UICollectionElementKindSectionKey.Header && !HeaderReuseID.IsNullOrEmtpy())
            {
                mvxLog.Trace("SupplementaryCollectionViewSource GetViewForSupplementaryElement HEADER resolving started");

                if (_headerDataContext != null)
                {
                    var headerView = collectionView.DequeueReusableSupplementaryView(elementKind, HeaderReuseID, indexPath);
                    mvxLog.Trace("SupplementaryCollectionViewSource GetViewForSupplementaryElement HEADER in process");
                    SetupReusableView(headerView, elementKind, indexPath, _headerDataContext);
                    return(headerView);
                }

                mvxLog.Warn("SupplementaryCollectionViewSource GetViewForSupplementaryElement _headerDataContext is NULL");

                mvxLog.Trace("SupplementaryCollectionViewSource GetViewForSupplementaryElement HEADER resolving ended");
            }
            else
            {
                mvxLog.Warn("SupplementaryCollectionViewSource GetViewForSupplementaryElement HEADER ID NULL");
            }

            if (elementKind == UICollectionElementKindSectionKey.Footer && !FooterReuseID.IsNullOrEmtpy())
            {
                mvxLog.Trace("SupplementaryCollectionViewSource GetViewForSupplementaryElement FOOTER resolving started");

                if (_footerDataContext != null)
                {
                    var footerView = collectionView.DequeueReusableSupplementaryView(elementKind, FooterReuseID, indexPath);
                    mvxLog.Trace("SupplementaryCollectionViewSource GetViewForSupplementaryElement FOOTER in process");
                    SetupReusableView(footerView, elementKind, indexPath, _headerDataContext);
                    return(footerView);
                }

                mvxLog.Warn("SupplementaryCollectionViewSource GetViewForSupplementaryElement _footerDataContext is NULL");

                mvxLog.Trace("SupplementaryCollectionViewSource GetViewForSupplementaryElement FOOTER resolving ended");
            }
            else
            {
                mvxLog.Warn("SupplementaryCollectionViewSource GetViewForSupplementaryElement FOOTER ID NULL");
            }

            mvxLog.Trace("SupplementaryCollectionViewSource GetViewForSupplementaryElement ended");

            return(null);
        }
Exemplo n.º 2
0
        protected virtual void CollectionChangedOnCollectionChanged(
            object sender,
            NotifyCollectionChangedEventArgs args)
        {
            switch (args.Action)
            {
            case NotifyCollectionChangedAction.Add:
                foreach (var newItem in args.NewItems)
                {
                    this.AddTag(this.sourceItemToStringFunc.Invoke((TSourceItem)newItem), newItem);
                }
                break;

            case NotifyCollectionChangedAction.Remove:
                for (int i = 0; i < args.OldItems.Count; i++)
                {
                    this.RemoveTag((TSourceItem)args.OldItems[i]);
                }
                break;

            case NotifyCollectionChangedAction.Move:
                if (args.NewItems.Count != 1 && args.OldItems.Count != 1)
                {
                    _log.Warn("MvxTagListView: Move action called with more than one movement!");
                    break;
                }

                this.RemoveTag((TSourceItem)args.OldItems[0]);
                this.InsertTag(this.sourceItemToStringFunc.Invoke((TSourceItem)args.NewItems[0]), args.NewStartingIndex, (TSourceItem)args.NewItems[0]);
                break;

            case NotifyCollectionChangedAction.Replace:
                if (args.NewItems.Count != args.OldItems.Count)
                {
                    break;
                }

                for (int i = 0; i < args.OldItems.Count; i++)
                {
                    this.RemoveTag((TSourceItem)args.OldItems[i]);
                    this.InsertTag(this.sourceItemToStringFunc.Invoke((TSourceItem)args.NewItems[i]), args.NewStartingIndex, (TSourceItem)args.NewItems[i]);
                }
                break;

            case NotifyCollectionChangedAction.Reset:
                this.RearrangeViews();
                break;
            }
        }
Exemplo n.º 3
0
        /// <inheritdoc />
        public async Task <bool> Enable()
        {
            var currentStatus = GetStatus();

            if (currentStatus)
            {
                return(true);
            }

            var accessGranted = await _healthStore.RequestAuthorizationToShareAsync(_dataTypesToWrite, _dataTypesToRead);

            if (accessGranted.Item1)
            {
                var pList = NSUserDefaults.StandardUserDefaults;
                pList.SetBool(true, _userDefaultsKey);
                pList.Synchronize();
            }
            else
            {
                _log.Warn("Can't obtain authorization to health kit");
            }

            return(accessGranted.Item1);
        }