public void AddFooterView(View v, Java.Lang.Object data, bool isSelectable)
        {
            IListAdapter adapter = (IListAdapter)Adapter;

            if (adapter != null && !(adapter is HeaderFooterViewGridAdapter))
            {
                throw new IllegalStateException("Cannot add footer view to grid -- setAdapter has already been called.");
            }

            FixedViewInfo info = new FixedViewInfo();
            FrameLayout fl = new FullWidthFixedViewLayout(this, Context);
            fl.AddView(v);
            info.view = v;
            info.viewContainer = fl;
            info.data = data;
            info.isSelectable = isSelectable;
            mFooterViewInfos.Add(info);

            // in the case of re-adding a header view, or adding one later on,
            // we need to notify the observer
            if (adapter != null)
            {
                ((HeaderFooterViewGridAdapter)adapter).notifyDataSetChanged();
            }
        }
Exemplo n.º 2
0
        public void setGridViewHeightBasedOnChildren(GridView gridView, int columns)
        {
            IListAdapter listAdapter = gridView.Adapter;

            if (listAdapter == null)
            {
                // pre-condition
                return;
            }

            int totalHeight = 0;
            int items       = listAdapter.Count;
            int rows        = 0;

            View listItem = listAdapter.GetView(0, null, gridView);

            listItem.Measure(0, 0);
            totalHeight = listItem.MeasuredHeight;

            float x = 1;

            if (items > columns)
            {
                x            = items / columns;
                rows         = (int)(x + 1);
                totalHeight *= rows;
            }

            ViewGroup.LayoutParams parameters = gridView.LayoutParameters;
            parameters.Height         = totalHeight;
            gridView.LayoutParameters = parameters;
        }
Exemplo n.º 3
0
 public DragListAdapter(Android.Widget.ListView listView, Xamarin.Forms.ListView element)
 {
     _listView = listView;
     // NOTE: careful, the listAdapter might not always be an IWrapperListAdapter
     _listAdapter = ((IWrapperListAdapter)_listView.Adapter).WrappedAdapter;
     _element     = element;
 }
        public override void SetAdapter(IListAdapter adapter)
        {
            // assert adapter in debug mode
//			if (BuildConfig.DEBUG && adapter != null) {
//				if (!(adapter.GetType() ==  (new PinnedSectionListAdapter()).GetType()))
//					throw IllegalArgumentException("Does your adapter implement PinnedSectionListAdapter?");
//				if (adapter.ViewTypeCount < 2)
//					throw new IllegalArgumentException("Does your adapter handle at least two types" +
//						" of views in getViewTypeCount() method: items and sections?");
//			}

            // unregister observer at old adapter and register on new one
            IListAdapter oldAdapter = Adapter;

            if (oldAdapter != null)
            {
                oldAdapter.UnregisterDataSetObserver(mDataSetObserver);
            }
            if (adapter != null)
            {
                adapter.RegisterDataSetObserver(mDataSetObserver);
            }

            // destroy pinned shadow, if new adapter is not same as old one
            if (oldAdapter != adapter)
            {
                destroyPinnedShadow();
            }

            base.SetAdapter(adapter);
        }
		public int GetRowHeight() {
			if (_rowHeight > 0) {
				return _rowHeight;
			}
			IListAdapter adapter = Adapter;
			int numColumns = GetNumColumnsCompatible();

			// adapter has not been set or has no views in it;
			if (adapter == null || adapter.Count <= numColumns * (_headerViewInfos.Count + _footerViewInfos.Count)) {
				return -1;
			}
			int mColumnWidth = GetColumnWidthCompatible();
			View view = Adapter.GetView(numColumns * _headerViewInfos.Count, _viewForMeasureRowHeight, this);
			AbsListView.LayoutParams p = (AbsListView.LayoutParams) view.LayoutParameters;
			if (p == null) {
				p = new AbsListView.LayoutParams(-1, -2, 0);
				view.LayoutParameters=p;
			}
			int childHeightSpec = GetChildMeasureSpec(
				MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified), 0, p.Height);
			int childWidthSpec = GetChildMeasureSpec(
				MeasureSpec.MakeMeasureSpec(mColumnWidth, MeasureSpecMode.Exactly), 0, p.Width);
			view.Measure(childWidthSpec, childHeightSpec);
			_viewForMeasureRowHeight = view;
			_rowHeight = view.MeasuredHeight;
			return _rowHeight;
		}
        int findCurrentSectionPosition(int fromPosition)
        {
            IListAdapter adapter = Adapter;

//			if (adapter.GetType() == ISectionIndexer) {
//				// try fast way by asking section indexer
//				SectionIndexerImpl indexer = (SectionIndexerImpl) adapter;
//				int sectionPosition = indexer.GetSectionForPosition(fromPosition);
//				int itemPosition = indexer.GetPositionForSection(sectionPosition);
//				int typeView = adapter.GetItemViewType(itemPosition);
//				if (isItemViewTypePinned(adapter, typeView)) {
//					return itemPosition;
//				} // else, no luck
//			}

            // try slow way by looking through to the next section item above
            for (int position = fromPosition; position >= 0; position--)
            {
                int viewType = adapter.GetItemViewType(position);

                if (isItemViewTypePinned(adapter, viewType))
                {
                    return(position);
                }
            }
            return(-1);            // no candidate found
        }
		public void AddFooterView(View v, Object data, bool isSelectable) {
			IListAdapter mAdapter = Adapter;
			if (mAdapter != null && !(mAdapter is HeaderViewGridAdapter)) {
				throw new Java.Lang.IllegalStateException(
					"Cannot add header view to grid -- setAdapter has already been called.");
			}

			ViewGroup.LayoutParams lyp = v.LayoutParameters;

			FixedViewInfo info = new FixedViewInfo();
			FrameLayout fl = new FullWidthFixedViewLayout(Context,this);

			if (lyp != null) {
				v.LayoutParameters=new FrameLayout.LayoutParams(lyp.Width, lyp.Height);
				fl.LayoutParameters=new AbsListView.LayoutParams(lyp.Width, lyp.Height);
			}
			fl.AddView(v);
			info.view = v;
			info.viewContainer = fl;
			info.data = data;
			info.isSelectable = isSelectable;
			_footerViewInfos.Add(info);

			if (mAdapter != null) {
				((HeaderViewGridAdapter) mAdapter).notifyDataSetChanged();
			}
		}
        int FindCurrentSectionPosition(int fromPosition)
        {
            IListAdapter adapter = Adapter;

            if (fromPosition >= adapter.Count)
            {
                return(-1);                               // dataset has changed, no candidate
            }
            if (adapter.GetType().IsAssignableFrom(typeof(ISectionIndexer)))
            {
                // try fast way by asking section indexer
                ISectionIndexer indexer         = (ISectionIndexer)adapter;
                int             sectionPosition = indexer.GetSectionForPosition(fromPosition);
                int             itemPosition    = indexer.GetPositionForSection(sectionPosition);
                int             typeView        = adapter.GetItemViewType(itemPosition);
                if (IsItemViewTypePinned(adapter, typeView))
                {
                    return(itemPosition);
                } // else, no luck
            }

            // try slow way by looking through to the next section item above
            for (int position = fromPosition; position >= 0; position--)
            {
                int viewType = adapter.GetItemViewType(position);
                if (IsItemViewTypePinned(adapter, viewType))
                {
                    return(position);
                }
            }
            return(-1); // no candidate found
        }
Exemplo n.º 9
0
 protected EndlessAdapterBase(Context context, IListAdapter wrapped, int pendingItemResourceId, bool keepOnAppending)
     : this(wrapped)
 {
     this._context = context;
     this._pendingItemResourceId = pendingItemResourceId;
     this.SetKeepOnAppending(keepOnAppending);
 }
        int FindFirstVisibleSectionPosition(int firstVisibleItem, int visibleItemCount)
        {
            IListAdapter adapter = Adapter;

            int adapterDataCount = adapter.Count;

            if (LastVisiblePosition >= adapterDataCount)
            {
                return(-1);                                         // dataset has changed, no candidate
            }
            if (firstVisibleItem + visibleItemCount >= adapterDataCount)
            {//added to prevent index Outofbound (in case)
                visibleItemCount = adapterDataCount - firstVisibleItem;
            }

            for (int childIndex = 0; childIndex < visibleItemCount; childIndex++)
            {
                int position = firstVisibleItem + childIndex;
                int viewType = adapter.GetItemViewType(position);
                if (IsItemViewTypePinned(adapter, viewType))
                {
                    return(position);
                }
            }
            return(-1);
        }
Exemplo n.º 11
0
        public AdapterWrapper(IListAdapter wrapped)
        {
            this._wrappedAdapter = wrapped;

            NotificatingDataSetObserver dataSetObserver = new NotificatingDataSetObserver(NotifyDataSetChanged, NotifyDataSetInvalidated);
            wrapped.RegisterDataSetObserver(dataSetObserver);
        }
Exemplo n.º 12
0
 protected EndlessAdapterBase(Context context, IListAdapter wrapped, int pendingItemResourceId, bool keepOnAppending)
     : this(wrapped)
 {
     this._context = context;
     this._pendingItemResourceId = pendingItemResourceId;
     this.SetKeepOnAppending(keepOnAppending);
 }
Exemplo n.º 13
0
        /// <summary>
        /// Helper method for explicitly making a list view height be based on the height of it's children
        /// This is required when a list view is contained within a scroll view and would other wise only show a single item
        /// </summary>
        /// <param name="listView"></param>
        public static void SetListViewHeightBasedOnChildren(ListView listView)
        {
            IListAdapter listAdapter = listView.Adapter;

            if (listAdapter == null)
            {
                return;
            }

            int  desiredWidth = View.MeasureSpec.MakeMeasureSpec(listView.Width, MeasureSpecMode.Unspecified);
            int  totalHeight  = 0;
            View view         = null;

            for (int i = 0; i < listAdapter.Count; i++)
            {
                view = listAdapter.GetView(i, view, listView);
                if (i == 0)
                {
                    view.LayoutParameters = new ViewGroup.LayoutParams(desiredWidth, 0);
                }

                view.Measure(desiredWidth, 0);
                totalHeight += view.MeasuredHeight;
            }
            ViewGroup.LayoutParams layoutParams = listView.LayoutParameters;
            layoutParams.Height       = totalHeight + (listView.DividerHeight * (listAdapter.Count - 1));
            listView.LayoutParameters = layoutParams;
            listView.RequestLayout();
        }
Exemplo n.º 14
0
        /**
         * Sets the {@link ListAdapter} for this {@code DynamicListView}.
         * If the drag and drop functionality is or will be enabled, the adapter should have stable ids,
         * and should implement {@link com.nhaarman.listviewanimations.util.Swappable}.
         *
         * @param adapter the adapter.
         *
         * @throws java.lang.IllegalStateException    if the drag and drop functionality is enabled
         *                                            and the adapter does not have stable ids.
         * @throws java.lang.IllegalArgumentException if the drag and drop functionality is enabled
         *                                            and the adapter does not implement {@link com.nhaarman.listviewanimations.util.Swappable}.
         */
        //@Override

        public override void SetAdapter(IListAdapter adapter)
        {
            IListAdapter wrappedAdapter = adapter;

            mSwipeUndoAdapter = null;

            if (adapter is BaseAdapter)
            {
                BaseAdapter rootAdapter = (BaseAdapter)wrappedAdapter;
                while (rootAdapter is BaseAdapterDecorator)
                {
                    if (rootAdapter is SwipeUndoAdapter)
                    {
                        mSwipeUndoAdapter = (SwipeUndoAdapter)rootAdapter;
                    }
                    rootAdapter = ((BaseAdapterDecorator)rootAdapter).getDecoratedBaseAdapter();
                }

                if (rootAdapter is IInsertable)
                {
                    mAnimateAdditionAdapter = new AnimateAdditionAdapter <object>((BaseAdapter)wrappedAdapter);
                    mAnimateAdditionAdapter.setListView(this);
                    wrappedAdapter = mAnimateAdditionAdapter;
                }
            }

            base.Adapter = wrappedAdapter;

            if (mDragAndDropHandler != null)
            {
                mDragAndDropHandler.setAdapter(adapter);
            }
        }
        public HeaderViewListAdapter(List <StaggeredGridView.FixedViewInfo> headerViewInfos, List <StaggeredGridView.FixedViewInfo> footerViewInfos, IListAdapter adapter)
        {
            mAdapter      = adapter;
            mIsFilterable = adapter is IFilterable;

            if (headerViewInfos == null)
            {
                mHeaderViewInfos = EMPTY_INFO_LIST;
            }
            else
            {
                mHeaderViewInfos = headerViewInfos;
            }

            if (footerViewInfos == null)
            {
                mFooterViewInfos = EMPTY_INFO_LIST;
            }
            else
            {
                mFooterViewInfos = footerViewInfos;
            }

            mAreAllFixedViewsSelectable = AreAllListInfosSelectable(mHeaderViewInfos) && AreAllListInfosSelectable(mFooterViewInfos);
        }
Exemplo n.º 16
0
        public static void setListViewHeightBasedOnChildren(ListView listView)
        {
            IListAdapter listAdapter = listView.Adapter;

            if (listAdapter == null)
            {
                // pre-condition
                return;
            }

            int totalHeight  = 0;
            int desiredWidth = View.MeasureSpec.MakeMeasureSpec(listView.Width, View.MeasureSpec.AT_MOST);

            for (int i = 0; i < listAdapter.GetCount(); i++)
            {
                View listItem = listAdapter.GetView(i, null, listView);
                listItem.Measure(1000, 0);
                totalHeight += listItem.MeasuredHeight;
            }

            ViewGroup.LayoutParams parameters = listView.GetLayoutParams();
            parameters.Height = totalHeight + (listView.DividerHeight * (listAdapter.GetCount() - 1)) + 10;
            listView.SetLayoutParams(parameters);
            listView.RequestLayout();
        }
Exemplo n.º 17
0
 public DragListAdapter(AWidget.ListView listView, XListView element)
 {
     this.listView = listView;
     // NOTE: careful, the listAdapter might not always be an IWrapperListAdapter
     this.listAdapter = (listView.Adapter as IWrapperListAdapter)?.WrappedAdapter;
     this.element     = element;
 }
		/**
     * Add a fixed view to appear at the top of the grid. If addHeaderView is
     * called more than once, the views will appear in the order they were
     * added. Views added using this call can take focus if they want.
     * <p/>
     * NOTE: Call this before calling setAdapter. This is so HeaderGridView can wrap
     * the supplied cursor with one that will also account for header views.
     *
     * @param v            The view to add.
     * @param data         Data to associate with this view
     * @param isSelectable whether the item is selectable
     */
		public void AddHeaderView(View v, Object data, bool isSelectable) {
			IListAdapter adapter = Adapter;
			if (adapter != null && !(adapter is HeaderViewGridAdapter)) {
				throw new Java.Lang.IllegalStateException(
					"Cannot add header view to grid -- setAdapter has already been called.");
			}
			ViewGroup.LayoutParams lyp = v.LayoutParameters;

			FixedViewInfo info = new FixedViewInfo();
			FrameLayout fl = new FullWidthFixedViewLayout(Context,this);
			if (lyp == null) {
				lyp = new ViewGroup.LayoutParams (WindowManagerLayoutParams.MatchParent,WindowManagerLayoutParams.MatchParent);
			}

			if (lyp != null) {
				v.LayoutParameters=new FrameLayout.LayoutParams(lyp.Width, lyp.Height);
				fl.LayoutParameters=new AbsListView.LayoutParams(lyp.Width, lyp.Height);
			}
			fl.AddView(v);
			info.view = v;
			info.viewContainer = fl;
			info.data = data;
			info.isSelectable = isSelectable;
			_headerViewInfos.Add(info);
			// in the case of re-adding a header view, or adding one later on,
			// we need to notify the observer
			if (adapter != null) {
				((HeaderViewGridAdapter) adapter).notifyDataSetChanged();
			}
		}
        /**
         * Retrieves the {@code View} in the list corresponding to itemId.
         *
         * @return the {@code View}, or {@code null} if not found.
         */
        //@Nullable
        private View getViewForId(long itemId)
        {
            IListAdapter adapter = mAdapter;

            if (itemId == INVALID_ID || adapter == null)
            {
                return(null);
            }

            int firstVisiblePosition = mWrapper.getFirstVisiblePosition();

            View result = null;

            for (int i = 0; i < mWrapper.getChildCount() && result == null; i++)
            {
                int position = firstVisiblePosition + i;
                if (position - mWrapper.getHeaderViewsCount() >= 0)
                {
                    long id = adapter.GetItemId(position - mWrapper.getHeaderViewsCount());
                    if (id == itemId)
                    {
                        result = mWrapper.getChildAt(i);
                    }
                }
            }
            return(result);
        }
Exemplo n.º 20
0
        public AdapterWrapper(IListAdapter wrapped)
        {
            this._wrappedAdapter = wrapped;

            NotificatingDataSetObserver dataSetObserver = new NotificatingDataSetObserver(NotifyDataSetChanged, NotifyDataSetInvalidated);

            wrapped.RegisterDataSetObserver(dataSetObserver);
        }
Exemplo n.º 21
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="ObservableListBase{T}" /> class.
 /// </summary>
 /// <param name="internalContainer">The internal container.</param>
 /// <param name="suppressUndoable">If set to <see langword="true" />, suppresses undoable capabilities of this collection.</param>
 protected ObservableListBase(
     IListAdapter <T> internalContainer,
     bool suppressUndoable)
     : base(
         internalContainer,
         suppressUndoable)
 {
 }
Exemplo n.º 22
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="ObservableListBase{T}" /> class.
 /// </summary>
 /// <param name="internalContainer">The internal container.</param>
 /// <param name="context">The context.</param>
 protected ObservableListBase(
     IListAdapter <T> internalContainer,
     SynchronizationContext context)
     : base(
         internalContainer,
         context)
 {
 }
Exemplo n.º 23
0
 public virtual Builder SetItems(IListAdapter listAdapter, int checkedItemIdx, EventHandler <AdapterView.ItemClickEventArgs> handler)
 {
     mListAdapter        = listAdapter;
     mOnItemClickHandler = handler;
     mListCheckedItemIdx = checkedItemIdx;
     mChoiceMode         = ChoiceMode.None;
     return(this);
 }
Exemplo n.º 24
0
 /// <summary>
 /// Set list
 /// </summary>
 /// <param name="checkedItemIdx"> Item check by default, -1 if no item should be checked </param>
 public virtual Builder SetItems(IListAdapter listAdapter, int checkedItemIdx, AdapterView.IOnItemClickListener listener)
 {
     mListAdapter         = listAdapter;
     mOnItemClickListener = listener;
     mListCheckedItemIdx  = checkedItemIdx;
     mChoiceMode          = ChoiceMode.None;
     return(this);
 }
 public bool IsItemViewTypePinned(IListAdapter adapter, int viewType)
 {
     if (adapter.GetType().IsAssignableFrom(typeof(HeaderViewListAdapter)))
     {
         adapter = ((HeaderViewListAdapter)adapter).WrappedAdapter;
     }
     return(((IPinnedSectionListAdapter)adapter).IsItemViewTypePinned(viewType));
 }
Exemplo n.º 26
0
        void SetupTab(string title, IListAdapter adapter, GameListFragment fragment)
        {
            var tab = this.ActionBar.NewTab();

            tab.SetTabListener(this);
            tab.SetText(title);
            this.ActionBar.AddTab(tab);
        }
 public static Boolean isItemViewTypePinned(IListAdapter adapter, int viewType)
 {
     if (adapter.GetType() == (new HeaderViewListAdapter(null, null, null)).GetType())
     {
         adapter = ((HeaderViewListAdapter)adapter).WrappedAdapter;
     }
     return(((PinnedSectionListAdapter)adapter).isItemViewTypePinned(viewType));
 }
Exemplo n.º 28
0
        public static void SimpleInvalidate(this IListAdapter adapter)
        {
            var adp = (adapter as BaseAdapter);

            if (adp != null)
            {
                adp.NotifyDataSetChanged();
            }
        }
Exemplo n.º 29
0
 public virtual Builder SetItems(IListAdapter listAdapter, int[] checkedItemIds, ChoiceMode choiceMode, EventHandler <AdapterView.ItemClickEventArgs> handler)
 {
     mListAdapter = listAdapter;
     mListCheckedItemMultipleIds = checkedItemIds;
     mOnItemClickHandler         = handler;
     mChoiceMode         = choiceMode;
     mListCheckedItemIdx = -1;
     return(this);
 }
Exemplo n.º 30
0
 public virtual Builder SetItems(IListAdapter listAdapter, int[] checkedItemIds, ChoiceMode choiceMode, AdapterView.IOnItemClickListener listener)
 {
     mListAdapter = listAdapter;
     mListCheckedItemMultipleIds = checkedItemIds;
     mOnItemClickListener        = listener;
     mChoiceMode         = choiceMode;
     mListCheckedItemIdx = -1;
     return(this);
 }
		public override void SetNumColumns (int numColumns)
		{
			base.SetNumColumns (numColumns);
			_numColumns = numColumns;
			IListAdapter adapter = Adapter;
			if (adapter != null && adapter is HeaderViewGridAdapter) {
				((HeaderViewGridAdapter) adapter).setNumColumns(numColumns);
			}
		}
		protected override void OnMeasure (int widthMeasureSpec, int heightMeasureSpec)
		{
			base.OnMeasure (widthMeasureSpec, heightMeasureSpec);
			IListAdapter adapter = Adapter;
			if (adapter != null && adapter is HeaderViewGridAdapter) {
				((HeaderViewGridAdapter) adapter).setNumColumns(GetNumColumnsCompatible());
				((HeaderViewGridAdapter) adapter).setRowHeight(GetRowHeight());
			}
		}
			public HeaderViewGridAdapter(List<FixedViewInfo> headerViewInfos, List<FixedViewInfo> footViewInfos, IListAdapter adapter)
			{
				_adapter = adapter;
				_isFilterable = adapter is IFilterable;
				
				_headerViewInfos = headerViewInfos ?? new List<FixedViewInfo>();
				_footerViewInfos = footViewInfos ?? new List<FixedViewInfo>();

				_areAllFixedViewsSelectable = AreAllListInfosSelectable(_headerViewInfos)
						&& AreAllListInfosSelectable(_footerViewInfos);
			}
Exemplo n.º 34
0
        public MultiItemRowListAdapter(Context context, IListAdapter adapter, int itemsPerRow, int cellSpacing, bool canClickAtRow = false)
        {
            if (itemsPerRow <= 0) {
                throw new IllegalArgumentException("Number of items per row must be positive");
                }
                _contextReference = new WeakReference<Context>(context);
                _adapter = adapter;
                _itemsPerRow = itemsPerRow;
                _cellSpacing = cellSpacing;
            _canClickAtRow = canClickAtRow;

            _itemLayoutParams = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MatchParent);
                _itemLayoutParams.SetMargins(cellSpacing, cellSpacing, 0, 0);
                _itemLayoutParams.Weight = 1;
                _rowLayoutParams = new AbsListView.LayoutParams(AbsListView.LayoutParams.MatchParent, AbsListView.LayoutParams.WrapContent);
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);
            SetContentView (Resource.Layout.Main);

            _instructorList = FindViewById<ListView> (Resource.Id.instructor_list);
            _instructorsAdapter = new InstructorAdapter (this, InstructorData.Instructors);
            _instructorList.Adapter = _instructorsAdapter;
            _instructorList.FastScrollEnabled = true;

            _instructorList.ItemClick += (sender, e) =>
            {
                var detailsIntent = new Intent(this, typeof(InstructorDetailsActivity));
                detailsIntent.PutExtra("position", e.Position);
                StartActivity(detailsIntent);
            };
        }
			public HeaderViewGridAdapter(List<FixedViewInfo> headerViewInfos, List<FixedViewInfo> footViewInfos, IListAdapter adapter,GridViewWithHeaderAndFooter obj) {
				mAdapter = adapter;
				isFilterable = adapter is IFilterable;
				this.obj=obj;
				if (headerViewInfos == null) {
					_headerViewInfos = emptyInfoList;
				} else {
					_headerViewInfos = headerViewInfos;
				}

				if (footViewInfos == null) {
					_footerViewInfos = emptyInfoList;
				} else {
					_footerViewInfos = footViewInfos;
				}
				areAllFixedViewsSelectable = areAllListInfosSelectable(_headerViewInfos)
					&& areAllListInfosSelectable(_footerViewInfos);
			}
        private AdapterWrapper WrapAdapter(IListAdapter adapter)
        {
            AdapterWrapper wrapper = null;
            var indexer = adapter as ISectionIndexer;
            wrapper = indexer != null ? new SectionIndexerAdapterWrapper(Context, indexer) : new AdapterWrapper(Context, adapter);

            wrapper.Divider = m_Divider;
            wrapper.DividerHeight = m_DividerHeight;
            wrapper.RegisterDataSetObserver(m_DataSetObserver);
            wrapper.OnHeaderAdapterClickListener = m_AdapterHeaderAdapterClickListener;
            return wrapper;
        }
		public static Boolean isItemViewTypePinned(IListAdapter adapter, int viewType) {
			if (adapter.GetType() ==  (new HeaderViewListAdapter(null,null, null)).GetType()) {
				adapter = ((HeaderViewListAdapter)adapter).WrappedAdapter;
			}
			return ((PinnedSectionListAdapter) adapter).isItemViewTypePinned(viewType);
		}
		public override void SetAdapter (IListAdapter adapter)
		{
			// assert adapter in debug mode
//			if (BuildConfig.DEBUG && adapter != null) {
//				if (!(adapter.GetType() ==  (new PinnedSectionListAdapter()).GetType()))
//					throw IllegalArgumentException("Does your adapter implement PinnedSectionListAdapter?");
//				if (adapter.ViewTypeCount < 2)
//					throw new IllegalArgumentException("Does your adapter handle at least two types" +
//						" of views in getViewTypeCount() method: items and sections?");
//			}

			// unregister observer at old adapter and register on new one
			IListAdapter oldAdapter = Adapter;
			if (oldAdapter != null) oldAdapter.UnregisterDataSetObserver(mDataSetObserver);
			if (adapter != null) adapter.RegisterDataSetObserver(mDataSetObserver);

			// destroy pinned shadow, if new adapter is not same as old one
			if (oldAdapter != adapter) destroyPinnedShadow();

			base.SetAdapter (adapter);

		}
 /**
  * @throws java.lang.IllegalStateException    if the adapter does not have stable ids.
  * @throws java.lang.IllegalArgumentException if the adapter does not implement {@link com.nhaarman.listviewanimations.util.Swappable}.
  */
 public void setAdapter(IListAdapter adapter)
 {
     setAdapterInternal(adapter);
 }
Exemplo n.º 41
0
 protected EndlessAdapterBase(IListAdapter wrapped)
     : base(wrapped)
 {
     _keepOnAppending = new AtomicBoolean(true);
     _pendingItemResourceId = -1;
 }
        /**
         * Sets the {@link ListAdapter} for this {@code DynamicListView}.
         * If the drag and drop functionality is or will be enabled, the adapter should have stable ids,
         * and should implement {@link com.nhaarman.listviewanimations.util.Swappable}.
         *
         * @param adapter the adapter.
         *
         * @throws java.lang.IllegalStateException    if the drag and drop functionality is enabled
         *                                            and the adapter does not have stable ids.
         * @throws java.lang.IllegalArgumentException if the drag and drop functionality is enabled
         *                                            and the adapter does not implement {@link com.nhaarman.listviewanimations.util.Swappable}.
         */
        //@Override

        public override void SetAdapter(IListAdapter adapter)
        {
            IListAdapter wrappedAdapter = adapter;
            mSwipeUndoAdapter = null;

            if (adapter is BaseAdapter)
            {
                BaseAdapter rootAdapter = (BaseAdapter)wrappedAdapter;
                while (rootAdapter is BaseAdapterDecorator)
                {
                    if (rootAdapter is SwipeUndoAdapter)
                    {
                        mSwipeUndoAdapter = (SwipeUndoAdapter)rootAdapter;
                    }
                    rootAdapter = ((BaseAdapterDecorator)rootAdapter).getDecoratedBaseAdapter();
                }

                if (rootAdapter is IInsertable)
                {
                    mAnimateAdditionAdapter = new AnimateAdditionAdapter<object>((BaseAdapter)wrappedAdapter);
                    mAnimateAdditionAdapter.setListView(this);
                    wrappedAdapter = mAnimateAdditionAdapter;
                }
            }

            base.Adapter = wrappedAdapter;

            if (mDragAndDropHandler != null)
            {
                mDragAndDropHandler.setAdapter(adapter);
            }
        }
Exemplo n.º 43
0
 protected EndlessAdapterBase(IListAdapter wrapped, bool keepOnAppending)
     : this(wrapped)
 {
     this.SetKeepOnAppending(keepOnAppending);
 }
Exemplo n.º 44
0
 protected EndlessAdapterBase(Context context, IListAdapter wrapped, int pendingItemResourceId)
     : this(wrapped)
 {
     this._context = context;
     this._pendingItemResourceId = pendingItemResourceId;
 }
        /**
         * @throws java.lang.IllegalStateException    if the adapter does not have stable ids.
         * @throws java.lang.IllegalArgumentException if the adapter does not implement {@link com.nhaarman.listviewanimations.util.Swappable}.
         */
        private void setAdapterInternal(IListAdapter adapter)
        {
            IListAdapter actualAdapter = adapter;
            if (actualAdapter is IWrapperListAdapter)
            {
                actualAdapter = ((IWrapperListAdapter)actualAdapter).WrappedAdapter;
            }

            if (!actualAdapter.HasStableIds)
            {
                throw new Java.Lang.IllegalStateException("Adapter doesn't have stable ids! Make sure your adapter has stable ids, and override hasStableIds() to return true.");
            }

            if (!(actualAdapter is ISwappable))
            {
                throw new Java.Lang.IllegalArgumentException("Adapter should implement Swappable!");
            }

            mAdapter = actualAdapter;
        }
Exemplo n.º 46
0
        private void CreateAdapter()
        {
            var cursor = (ICursor)_loader.LoadInBackground();

            _adapter = new CursorImageAdapter(_ctx, cursor);
        }
Exemplo n.º 47
0
 public Builder SetAdapter(IListAdapter adapter, IListCallback callback)
 {
     if (this.CustomView != null)
         throw new InvalidOperationException("You cannot set adapter() when you're using a custom view.");
     this.Adapter = adapter;
     this.ListCallbackCustom = callback;
     return this;
 }
        private void EnsureList()
        {
            if (m_GridView != null)
                return;

            var root = View;
            if(root == null)
                throw new IllegalStateException("Content view not yet created");

            m_GridView = root as GridView;
            if (m_GridView == null)
            {
                var emptyView = root.FindViewById(Android.Resource.Id.Empty);
                if (emptyView != null)
                {
                    var emptyTextView = emptyView as TextView;
                    if (emptyTextView != null)
                        m_StandardEmptyView = emptyTextView;
                    else
                        m_EmptyView = emptyView;
                }
                else
                {
                    m_StandardEmptyView.Visibility = ViewStates.Gone;
                }

                m_ProgressContainer = root.FindViewById(Resource.Id.progress_container);
                m_GridContainer = root.FindViewById(Resource.Id.grid_container);
                m_GridView = root.FindViewById(Resource.Id.grid) as GridView;
                if (m_GridView == null)
                    throw new RuntimeException("Content has a view with id attribute R.id.grid and is not a gridview class");

                if (m_EmptyView != null)
                {
                    m_GridView.EmptyView = m_EmptyView;
                }
                else if (m_EmptyText != null)
                {
                    m_StandardEmptyView.Text = m_EmptyText;
                    m_GridView.EmptyView = m_StandardEmptyView;
                }
            }


            m_GridShown = true;
            m_GridView.OnItemClickListener = this;
            if (m_GridAdapter != null)
            {
                var adapter = m_GridAdapter;
                m_GridAdapter = null;
                GridAdapter = adapter;
            }
            else if(m_ProgressContainer != null)
            {
                SetGridShown(false, false);
            }

            m_Handler.Post(RequestFocusRunnable);
        }
Exemplo n.º 49
0
 private void updateNotesList(string aquery, int aposition)
 {
     // adapter that binds the ListView UI to the notes in the note manager
     adapter = NoteManager.getListAdapter(this, aquery, rightPane != null ? aposition : -1);
     SetListAdapter(adapter);
 }
		public override void SetAdapter(IListAdapter adapter)
		{
			if (_mHeaderViewInfos.Any())
			{
				HeaderViewGridAdapter headerViewGridAdapter = new HeaderViewGridAdapter(_mHeaderViewInfos, _mFooterViewInfos, adapter);
				int numColumns = GetNumColumnsCompat();
				if (1 < numColumns)
				{
					headerViewGridAdapter.SetNumColumns(numColumns);
				}
				base.SetAdapter(headerViewGridAdapter);
			}
			else
			{
				base.SetAdapter(adapter);
			}
		}
Exemplo n.º 51
0
 /// <summary>
 /// Set a list of items, which are supplied by the given adapter, to be displayed in the dialog as the content, 
 /// you will be notified of the selected item via the supplied event handler.
 /// </summary>
 public Builder SetAdapter(IListAdapter adapter, EventHandler<DialogInterfaceClickEventArgs> handler)
 {
     return SetAdapter(adapter, new DialogOnClickListener(handler));
 }
		public override void SetAdapter (IListAdapter adapter)
		{
			base.SetAdapter (adapter);
			mAdapter = (IPinnedHeaderAdapter)adapter;
		}