예제 #1
0
        protected override View GetViewFor(int section, int index)
        {
            var item = (T)GetItemAt(section, index);

            if (item == null)
            {
                return(null);
            }
            if (!CurrentViews.TryGetValue(item, out var view) || (view?.IsDisposed ?? true))
            {
                using (new StateBuilder(State))
                {
                    if (item is INotifyPropertyRead read)
                    {
                        State.StartMonitoring(read);
                    }
                    view = ViewFor?.Invoke(item);
                }
                if (view == null)
                {
                    return(null);
                }
                CurrentViews[item] = view;
                view.Parent        = this;
            }
            return(view);
        }
예제 #2
0
        protected override View ViewFor(int index)
        {
            var item = List[index];

            if (!CurrentViews.TryGetValue(item, out var view) || (view?.IsDisposed ?? true))
            {
                CurrentViews[item] = view = Cell(item);
                view.Parent        = this;
            }
            return(view);
        }
예제 #3
0
        protected override void Dispose(bool disposing)
        {
            if (!disposing)
            {
                return;
            }

            DisposeObservable();

            var currentViews = CurrentViews.ToList();

            CurrentViews.Clear();
            currentViews.ForEach(x => x.Value?.Dispose());
            base.Dispose(disposing);
        }
예제 #4
0
        protected override View GetViewFor(int section, int index)
        {
            var item = (T)GetItemAt(section, index);

            if (item == null)
            {
                return(null);
            }
            var key = (section, item);

            if (!CurrentViews.TryGetValue(key, out var view) || (view?.IsDisposed ?? true))
            {
                view = sections.SafeGetAtIndex(section, GetCachedSection)?.GetViewFor(index)?.SetParent(this);
                if (view == null)
                {
                    return(null);
                }
                CurrentViews[key] = view;
            }
            return(view);
        }