コード例 #1
0
        private void FitSize2(int position, bool scrollingLeft, int columnHeaderScrollPosition, int columnHeaderOffset,
                              int columnHeaderFirstItem)
        {
            int columnCacheWidth = mColumnHeaderLayoutManager.GetCacheWidth(position);

            Android.Views.View column = mColumnHeaderLayoutManager.FindViewByPosition(position);
            if (column != null)
            {
                // Loop for all rows which are visible.
                for (int j = FindFirstVisibleItemPosition(); j < FindLastVisibleItemPosition() + 1; j++)
                {
                    // Get CellRowRecyclerView
                    CellRecyclerView child = (CellRecyclerView)FindViewByPosition(j);
                    if (child != null)
                    {
                        ColumnLayoutManager childLayoutManager = (ColumnLayoutManager)child.GetLayoutManager();
                        // Checking Scroll position is necessary. Because, even if they have same width
                        // values, their scroll positions can be different.
                        if (!scrollingLeft && columnHeaderScrollPosition != child.GetScrolledX())
                        {
                            // Column Header RecyclerView has the right scroll position. So,
                            // considering it
                            childLayoutManager.ScrollToPositionWithOffset(columnHeaderFirstItem, columnHeaderOffset);
                        }

                        Fit2(position, j, columnCacheWidth, column, childLayoutManager);
                    }
                }
            }
        }
コード例 #2
0
 public SelectionHandler(ITableView tableView)
 {
     this.mTableView = tableView;
     this.mColumnHeaderRecyclerView = mTableView.GetColumnHeaderRecyclerView();
     this.mRowHeaderRecyclerView    = mTableView.GetRowHeaderRecyclerView();
     this.mCellLayoutManager        = mTableView.GetCellLayoutManager();
 }
コード例 #3
0
 public AbstractItemClickListener(CellRecyclerView recyclerView, ITableView tableView)
 {
     this.mRecyclerView     = recyclerView;
     this.mTableView        = tableView;
     this.mSelectionHandler = tableView.GetSelectionHandler();
     mGestureDetector       = new GestureDetector(mRecyclerView.Context, new _SimpleOnGestureListener_46(this));
 }
コード例 #4
0
 public HorizontalRecyclerViewListener(ITableView tableView)
 {
     // X position means column position
     this.mColumnHeaderRecyclerView     = tableView.GetColumnHeaderRecyclerView();
     this.mCellLayoutManager            = tableView.GetCellRecyclerView().GetLayoutManager();
     this.mVerticalRecyclerViewListener = tableView.GetVerticalRecyclerViewListener();
 }
コード例 #5
0
 public override void OnScrolled(RecyclerView recyclerView, int dx, int dy)
 {
     // Column Header should be scrolled firstly. Because it is the compared recyclerView to
     // make column width fit.
     if (recyclerView == mColumnHeaderRecyclerView)
     {
         base.OnScrolled(recyclerView, dx, dy);
         // Scroll each cell recyclerViews
         for (int i = 0; i < mCellLayoutManager.ChildCount; i++)
         {
             CellRecyclerView child = (CellRecyclerView)mCellLayoutManager.GetChildAt(i);
             // Scroll horizontally
             child.ScrollBy(dx, 0);
         }
     }
     else
     {
         // Scroll column header recycler view as well
         //mColumnHeaderRecyclerView.scrollBy(dx, 0);
         base.OnScrolled(recyclerView, dx, dy);
         // Scroll each cell recyclerViews except the current touched one
         for (int i = 0; i < mCellLayoutManager.ChildCount; i++)
         {
             CellRecyclerView child = (CellRecyclerView)mCellLayoutManager.GetChildAt(i);
             if (child != recyclerView)
             {
                 // Scroll horizontally
                 child.ScrollBy(dx, 0);
             }
         }
     }
 }
コード例 #6
0
        public virtual bool ShouldFitColumns(int yPosition)
        {
            // Scrolling horizontally
            if (mCellRecyclerView.ScrollState == RecyclerView.ScrollStateIdle)
            {
                int lastVisiblePosition = FindLastVisibleItemPosition();
                CellRecyclerView lastCellRecyclerView = (CellRecyclerView)FindViewByPosition(lastVisiblePosition);
                if (lastCellRecyclerView != null)
                {
                    if (yPosition == lastVisiblePosition)
                    {
                        return(true);
                    }
                    else
                    {
                        if (lastCellRecyclerView.IsScrollOthers() && yPosition == lastVisiblePosition - 1)
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
コード例 #7
0
 public CellLayoutManager(Context context, ITableView tableView) : base(context)
 {
     //TODO: Store a single instance for both cell and column cache width values.
     this.mTableView                 = tableView;
     this.mCellRecyclerView          = tableView.GetCellRecyclerView();
     this.mColumnHeaderLayoutManager = tableView.GetColumnHeaderLayoutManager();
     this.mRowHeaderLayoutManager    = tableView.GetRowHeaderLayoutManager();
     this.mRowHeaderRecyclerView     = tableView.GetRowHeaderRecyclerView();
     Initialize();
 }
コード例 #8
0
 public virtual void RemeasureAllChild()
 {
     // TODO: the below code causes requestLayout() improperly called by com.evrencoskun
     // TODO: .tableview.adapter
     for (int j = 0; j < ChildCount; j++)
     {
         CellRecyclerView recyclerView = (CellRecyclerView)GetChildAt(j);
         recyclerView.LayoutParameters.Width = ViewGroup.LayoutParams.WrapContent;
         recyclerView.RequestLayout();
     }
 }
コード例 #9
0
        public virtual AbstractViewHolder GetCellViewHolder(int xPosition, int yPosition)
        {
            CellRecyclerView cellRowRecyclerView = (CellRecyclerView)FindViewByPosition(yPosition);

            if (cellRowRecyclerView != null)
            {
                return((AbstractViewHolder)cellRowRecyclerView.FindViewHolderForAdapterPosition(xPosition));
            }

            return(null);
        }
コード例 #10
0
 public ColumnLayoutManager(Context context, ITableView tableView) : base(context)
 {
     this.mTableView = tableView;
     this.mColumnHeaderRecyclerView  = mTableView.GetColumnHeaderRecyclerView();
     this.mColumnHeaderLayoutManager = mTableView.GetColumnHeaderLayoutManager();
     this.mCellLayoutManager         = mTableView.GetCellLayoutManager();
     // Set default orientation
     this.Orientation = Horizontal;
     //If you are using a RecyclerView.RecycledViewPool, it might be a good idea to set this
     // flag to true so that views will be available to other RecyclerViews immediately.
     this.RecycleChildrenOnDetach = true;
 }
コード例 #11
0
        // Add new one
        public override void OnAttachedToWindow(RecyclerView view)
        {
            base.OnAttachedToWindow(view);
            // initialize the instances
            if (mCellRecyclerView == null)
            {
                mCellRecyclerView = mTableView.GetCellRecyclerView();
            }

            if (mHorizontalListener == null)
            {
                mHorizontalListener = mTableView.GetHorizontalRecyclerViewListener();
            }
        }
コード例 #12
0
        public virtual CellRecyclerView[] GetVisibleCellRowRecyclerViews()
        {
            int length = FindLastVisibleItemPosition() - FindFirstVisibleItemPosition() + 1;

            CellRecyclerView[] recyclerViews = new CellRecyclerView[length];
            int index = 0;

            for (int i = FindFirstVisibleItemPosition(); i < FindLastVisibleItemPosition() + 1; i++)
            {
                recyclerViews[index] = (CellRecyclerView)FindViewByPosition(i);
                index++;
            }

            return(recyclerViews);
        }
コード例 #13
0
        public virtual AbstractViewHolder[] GetVisibleCellViewsByColumnPosition(int xPosition)
        {
            int visibleChildCount = FindLastVisibleItemPosition() - FindFirstVisibleItemPosition() + 1;
            int index             = 0;

            AbstractViewHolder[] viewHolders = new AbstractViewHolder[visibleChildCount];
            for (int i = FindFirstVisibleItemPosition(); i < FindLastVisibleItemPosition() + 1; i++)
            {
                CellRecyclerView   cellRowRecyclerView = (CellRecyclerView)FindViewByPosition(i);
                AbstractViewHolder holder =
                    (AbstractViewHolder)cellRowRecyclerView.FindViewHolderForAdapterPosition(xPosition);
                viewHolders[index] = holder;
                index++;
            }

            return(viewHolders);
        }
コード例 #14
0
ファイル: TableView.cs プロジェクト: vkhaitan/TableViewSharp
 private void Initialize()
 {
     // Create Views
     mColumnHeaderRecyclerView = CreateColumnHeaderRecyclerView();
     mRowHeaderRecyclerView    = CreateRowHeaderRecyclerView();
     mCellRecyclerView         = CreateCellRecyclerView();
     // Add Views
     AddView(mColumnHeaderRecyclerView);
     AddView(mRowHeaderRecyclerView);
     AddView(mCellRecyclerView);
     // Create Handlers
     mSelectionHandler   = new SelectionHandler(this);
     mVisibilityHandler  = new VisibilityHandler(this);
     mScrollHandler      = new ScrollHandler(this);
     mPreferencesHandler = new PreferencesHandler(this);
     mColumnWidthHandler = new ColumnWidthHandler(this);
     InitializeListeners();
 }
コード例 #15
0
ファイル: TableView.cs プロジェクト: vkhaitan/TableViewSharp
        protected internal virtual CellRecyclerView CreateRowHeaderRecyclerView()
        {
            CellRecyclerView recyclerView = new CellRecyclerView(Context);

            // Set layout manager
            recyclerView.SetLayoutManager(GetRowHeaderLayoutManager());
            // Set layout params
            FrameLayout.LayoutParams layoutParams =
                new FrameLayout.LayoutParams(mRowHeaderWidth, FrameLayout.LayoutParams.WrapContent);
            layoutParams.TopMargin        = mColumnHeaderHeight;
            recyclerView.LayoutParameters = layoutParams;
            if (IsShowVerticalSeparators())
            {
                // Add vertical item decoration to display row line
                recyclerView.AddItemDecoration(GetVerticalItemDecoration());
            }

            return(recyclerView);
        }
コード例 #16
0
ファイル: TableView.cs プロジェクト: vkhaitan/TableViewSharp
        protected internal virtual CellRecyclerView CreateCellRecyclerView()
        {
            CellRecyclerView recyclerView = new CellRecyclerView(Context);

            // Disable multitouch
            recyclerView.MotionEventSplittingEnabled = false;
            // Set layout manager
            recyclerView.SetLayoutManager(GetCellLayoutManager());
            // Set layout params
            FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WrapContent,
                                                                                 FrameLayout.LayoutParams.WrapContent);
            layoutParams.LeftMargin       = mRowHeaderWidth;
            layoutParams.TopMargin        = mColumnHeaderHeight;
            recyclerView.LayoutParameters = layoutParams;
            if (IsShowVerticalSeparators())
            {
                // Add vertical item decoration to display row line on center recycler view
                recyclerView.AddItemDecoration(GetVerticalItemDecoration());
            }

            return(recyclerView);
        }
コード例 #17
0
 public CellRecyclerViewItemClickListener(CellRecyclerView recyclerView, ITableView tableView) : base(
         recyclerView, tableView)
 {
     this.mCellRecyclerView = tableView.GetCellRecyclerView();
 }
コード例 #18
0
 public override void OnAttachedToWindow(RecyclerView view)
 {
     base.OnAttachedToWindow(view);
     mCellRowRecyclerView = (CellRecyclerView)view;
     mYPosition           = GetRowPosition();
 }
コード例 #19
0
 public TableViewLayoutChangeListener(ITableView tableView)
 {
     this.mCellRecyclerView         = tableView.GetCellRecyclerView();
     this.mColumnHeaderRecyclerView = tableView.GetColumnHeaderRecyclerView();
     this.mCellLayoutManager        = tableView.GetCellLayoutManager();
 }
 public ColumnHeaderRecyclerViewItemClickListener(CellRecyclerView recyclerView, ITableView tableView) : base(
         recyclerView, tableView)
 {
 }
コード例 #21
0
 public VerticalRecyclerViewListener(ITableView tableView)
 {
     // Y Position means row position
     this.mRowHeaderRecyclerView = tableView.GetRowHeaderRecyclerView();
     this.mCellRecyclerView      = tableView.GetCellRecyclerView();
 }
コード例 #22
0
        private int Fit(int xPosition, int yPosition, int left, int right, int columnCachedWidth)
        {
            CellRecyclerView child = (CellRecyclerView)FindViewByPosition(yPosition);

            if (child != null)
            {
                ColumnLayoutManager childLayoutManager = (ColumnLayoutManager)child.GetLayoutManager();
                int cellCacheWidth      = GetCacheWidth(yPosition, xPosition);
                Android.Views.View cell = childLayoutManager.FindViewByPosition(xPosition);
                // Control whether the cell needs to be fitted by column header or not.
                if (cell != null)
                {
                    if (cellCacheWidth != columnCachedWidth || mNeedSetLeft)
                    {
                        // This is just for setting width value
                        if (cellCacheWidth != columnCachedWidth)
                        {
                            cellCacheWidth = columnCachedWidth;
                            TableViewUtils.SetWidth(cell, cellCacheWidth);
                            SetCacheWidth(yPosition, xPosition, cellCacheWidth);
                        }

                        // Even if the cached values are same, the left & right value wouldn't change.
                        // mNeedSetLeft & the below lines for it.
                        if (left != IgnoreLeft && cell.Left != left)
                        {
                            // Calculate scroll distance
                            int scrollX = Math.Max(cell.Left, left) - Math.Min(cell.Left, left);
                            // Update its left
                            cell.Left = left;
                            int offset = mHorizontalListener.GetScrollPositionOffset();
                            // It shouldn't be scroll horizontally and the problem is gotten just for
                            // first visible item.
                            if (offset > 0 && xPosition == childLayoutManager.FindFirstVisibleItemPosition() &&
                                mCellRecyclerView.ScrollState != RecyclerView.ScrollStateIdle)
                            {
                                int scrollPosition = mHorizontalListener.GetScrollPosition();
                                offset = mHorizontalListener.GetScrollPositionOffset() + scrollX;
                                // Update scroll position offset value
                                mHorizontalListener.SetScrollPositionOffset(offset);
                                // Scroll considering to the desired value.
                                childLayoutManager.ScrollToPositionWithOffset(scrollPosition, offset);
                            }
                        }

                        if (cell.Width != cellCacheWidth)
                        {
                            if (left != IgnoreLeft)
                            {
                                // TODO: + 1 is for decoration item. It should be gotten from a
                                // generic method  of layoutManager
                                // Set right
                                right      = cell.Left + cellCacheWidth + 1;
                                cell.Right = right;
                                childLayoutManager.LayoutDecoratedWithMargins(cell, cell.Left, cell.Top, cell.Right,
                                                                              cell.Bottom);
                            }

                            mNeedSetLeft = true;
                        }
                    }
                }
            }

            return(right);
        }