//region register scrollables

        /**
         * Register a RecyclerView to the current MaterialViewPagerAnimator
         * Listen to RecyclerView.OnScrollListener so give to $[onScrollListener] your RecyclerView.OnScrollListener if you already use one
         * For loadmore or anything else
         *
         * @param recyclerView     the scrollable
         * @param onScrollListener use it if you want to get a callback of the RecyclerView
         */
        public void RegisterRecyclerView(RecyclerView recyclerView, RecyclerView.OnScrollListener onScrollListener)
        {
            if (recyclerView != null)
            {
                ScrollViewList.Add(recyclerView);                         //add to the scrollable list
                YOffsets.AddOrUpdate(recyclerView, recyclerView.ScrollY); //save the initial recyclerview's yOffset (0) into hashmap
                //only necessary for recyclerview

                //listen to scroll
                recyclerView.AddOnScrollListener(new RecyclerViewScrollListener(this, onScrollListener));

                recyclerView.Post(() => SetScrollOffset(recyclerView, LastYOffset));
            }
        }
Пример #2
0
        /**
         * Implement this method to customize the AbsListView
         */
        protected void initRecyclerView(View view)
        {
            mRecycler = (RecyclerView)view.FindViewById(AndroidResource.Id.List);
            tipView   = (TextView)view.FindViewById(Resource.Id.tvTip);
            setItemAnimator(null);
            if (mRecycler != null)
            {
                mRecycler.HasFixedSize = true;
                mRecycler.SetClipToPadding(mClipToPadding);
                mInternalOnScrollListener = new CustomOnScrollListener(this);
                mRecycler.AddOnScrollListener(mInternalOnScrollListener);

                if (mPadding != -1.0f)
                {
                    mRecycler.SetPadding(mPadding, mPadding, mPadding, mPadding);
                }
                else
                {
                    mRecycler.SetPadding(mPaddingLeft, mPaddingTop, mPaddingRight, mPaddingBottom);
                }
                if (mScrollbarStyle != -1)
                {
                    mRecycler.ScrollBarStyle = (ScrollbarStyles)mScrollbarStyle;
                }
                switch (mScrollbar)
                {
                case 0:
                    VerticalScrollBarEnabled = false;
                    break;

                case 1:
                    HorizontalScrollBarEnabled = false;
                    break;

                case 2:
                    VerticalScrollBarEnabled   = false;
                    HorizontalScrollBarEnabled = false;
                    break;
                }
            }
        }
Пример #3
0
 public override void AddOnScrollListener(RecyclerView.OnScrollListener listener)
 {
     if (listener is HorizontalRecyclerViewListener)
     {
         if (mIsHorizontalScrollListenerRemoved)
         {
             mIsHorizontalScrollListenerRemoved = false;
             base.AddOnScrollListener(listener);
         }
         else
         {
             // Do not let add the listener
             Log.Warn(LogTag,
                      "mIsHorizontalScrollListenerRemoved has been tried to add itself " +
                      "before remove the old one");
         }
     }
     else
     {
         if (listener is VerticalRecyclerViewListener)
         {
             if (mIsVerticalScrollListenerRemoved)
             {
                 mIsVerticalScrollListenerRemoved = false;
                 base.AddOnScrollListener(listener);
             }
             else
             {
                 // Do not let add the listener
                 Log.Warn(LogTag,
                          "mIsVerticalScrollListenerRemoved has been tried to add itself " +
                          "before remove the old one");
             }
         }
         else
         {
             base.AddOnScrollListener(listener);
         }
     }
 }
Пример #4
0
 public override void RemoveOnScrollListener(RecyclerView.OnScrollListener listener)
 {
     if (listener is HorizontalRecyclerViewListener)
     {
         if (mIsHorizontalScrollListenerRemoved)
         {
             // Do not let remove the listener
             Log.Error(LogTag,
                       "HorizontalRecyclerViewListener has been tried to remove " + "itself before add new one");
         }
         else
         {
             mIsHorizontalScrollListenerRemoved = true;
             base.RemoveOnScrollListener(listener);
         }
     }
     else
     {
         if (listener is VerticalRecyclerViewListener)
         {
             if (mIsVerticalScrollListenerRemoved)
             {
                 // Do not let remove the listener
                 Log.Error(LogTag,
                           "mIsVerticalScrollListenerRemoved has been tried to remove " + "itself before add new one");
             }
             else
             {
                 mIsVerticalScrollListenerRemoved = true;
                 base.RemoveOnScrollListener(listener);
             }
         }
         else
         {
             base.RemoveOnScrollListener(listener);
         }
     }
 }
Пример #5
0
        public void AttachToRecyclerView(RecyclerView recyclerView, IScrollDirectorListener scrollDirectionListener = null, RecyclerView.OnScrollListener onScrollListener = null)
        {
            var scrollDetector = new RecyclerViewScrollDetectorImpl(this)
            {
                ScrollDirectionListener = scrollDirectionListener,
                OnScrollListener        = onScrollListener,
                ScrollThreshold         = scrollThreshold
            };

            recyclerView.AddOnScrollListener(scrollDetector);
        }
		public RecyclerViewScrollListener(MaterialViewPagerAnimator materialViewPagerAnimator, RecyclerView.OnScrollListener onScrollListener)
		{
			_animator = materialViewPagerAnimator;
			_onScrollListener = onScrollListener;
		}
Пример #7
0
 /**
  * Register a RecyclerView to the current MaterialViewPagerAnimator
  * Listen to RecyclerView.OnScrollListener so give to $[onScrollListener] your RecyclerView.OnScrollListener if you already use one
  * For loadmore or anything else
  *
  * @param activity         current context
  * @param recyclerView     the scrollable
  * @param onScrollListener use it if you want to get a callback of the RecyclerView
  */
 public static void RegisterRecyclerView(Activity activity, RecyclerView recyclerView, RecyclerView.OnScrollListener onScrollListener)
 {
     if (activity != null && _hashMap.ContainsKey(activity))
     {
         MaterialViewPagerAnimator animator;
         if (_hashMap.TryGetValue(activity, out animator) && animator != null)
         {
             animator.RegisterRecyclerView(recyclerView, onScrollListener);
         }
     }
 }
 public RecyclerViewScrollListener(MaterialViewPagerAnimator materialViewPagerAnimator, RecyclerView.OnScrollListener onScrollListener)
 {
     _animator         = materialViewPagerAnimator;
     _onScrollListener = onScrollListener;
 }
Пример #9
0
 public void AddOnScrollListener(RecyclerView.OnScrollListener listener)
 {
     mListeners.Add(listener);
 }