Beispiel #1
0
            public override void OnScrollStateChanged(RecyclerView recyclerView, int newState)
            {
                base.OnScrollStateChanged(recyclerView, newState);

                try
                {
                    if (newState == (int)Android.Widget.ScrollState.Idle)
                    {
                        //if (XRecyclerView.Thumbnail != null)
                        //    XRecyclerView.Thumbnail.Visibility = ViewStates.Visible;

                        //if (XRecyclerView.PlayControl != null)
                        //    XRecyclerView.PlayControl.Visibility = ViewStates.Visible;

                        XRecyclerView.PlayVideo(!recyclerView.CanScrollVertically(1));
                    }
                    else
                    {
                        var startPosition = LayoutManager.FindFirstVisibleItemPosition();
                        var endPosition   = LayoutManager.FindLastVisibleItemPosition();

                        var startPositionVideoHeight = XRecyclerView.GetVisibleVideoSurfaceHeight(startPosition);
                        var endPositionVideoHeight   = XRecyclerView.GetVisibleVideoSurfaceHeight(endPosition);
                        var targetPosition           = startPositionVideoHeight > endPositionVideoHeight;

                        if (endPositionVideoHeight - 230 > startPositionVideoHeight)
                        {
                            if (XRecyclerView.VideoPlayer.PlayWhenReady)
                            {
                                XRecyclerView.VideoPlayer.PlayWhenReady = false;
                            }
                        }
                        if (startPositionVideoHeight <= 60)
                        {
                            if (XRecyclerView.Thumbnail != null)
                            {
                                XRecyclerView.Thumbnail.Visibility = ViewStates.Visible;
                            }

                            if (XRecyclerView.PlayControl != null)
                            {
                                XRecyclerView.PlayControl.Visibility = ViewStates.Visible;
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
        /**
         * Returns true iff the {@link RecyclerView} is scrolled to the
         * top of its content (i.e. its first item is completely visible).
         */
        private static bool IsRvScrolledToTop(RecyclerView rv)
        {
            LinearLayoutManager lm = (LinearLayoutManager)rv.GetLayoutManager();

            return(lm.FindFirstVisibleItemPosition() == 0 &&
                   lm.FindViewByPosition(0).Top == 0);
        }
Beispiel #3
0
        public override void OnScrolled(RecyclerView recyclerView, int dx, int dy)
        {
            base.OnScrolled(recyclerView, dx, dy);



            var y         = dy;
            var yukseklik = ToolbarHaznesi.Bottom;

            //ToolbarHaznesi.TranslationY=dy;



            if (y >= yukseklik && ToolbarHaznesi.Visibility == ViewStates.Visible)
            {
                ToolbarHaznesi.Visibility = ViewStates.Gone;
            }
            else if (y >= 0 && y <= 10 && ToolbarHaznesi.Visibility == ViewStates.Gone)
            {
                ToolbarHaznesi.Visibility = ViewStates.Visible;
            }


            return;

            var visibleItemCount  = recyclerView.ChildCount;
            var totalItemCount    = recyclerView.GetAdapter().ItemCount;
            var pastVisiblesItems = LayoutManager.FindFirstVisibleItemPosition();

            if ((visibleItemCount + pastVisiblesItems) >= totalItemCount)
            {
                LoadMoreEvent(this, null);
            }
        }
        public override void OnScrolled(RecyclerView recyclerView, int dx, int dy)
        {
            base.OnScrolled(recyclerView, dx, dy);

            visibleItemCount = recyclerView.ChildCount;
            totalItemCount   = recyclerView.GetAdapter().ItemCount;
            firstVisibleItem = LayoutManager.FindFirstVisibleItemPosition();

            if (loading)
            {
                if (totalItemCount > previousTotal)
                {
                    loading = false;

                    previousTotal = totalItemCount;
                }
            }

            if (!loading && (totalItemCount - visibleItemCount) <= (firstVisibleItem + visibleThreshold))
            {
                LoadMoreEvent(this, null);

                loading = true;
            }
        }
Beispiel #5
0
 public override void OnScrolled(RecyclerView recyclerView, int dx, int dy)
 {
     base.OnScrolled(recyclerView, dx, dy);
     if (!IsLoading)
     {
         IsLoading = true;
         var visibleItemCount  = recyclerView.ChildCount;
         var totalItemCount    = recyclerView.GetAdapter().ItemCount;
         var pastVisiblesItems = LayoutManager.FindFirstVisibleItemPosition();
         if (dy > 0 && Direction == ScrollDirection.DOWN) //check for scroll down
         {
             if (totalItemCount != 0
                 //&& pastVisiblesItems > 0
                 &&
                 (
                     RemainingItemsToTriggerFetch >= totalItemCount ||
                     (visibleItemCount + pastVisiblesItems + RemainingItemsToTriggerFetch) >= totalItemCount
                 ))
             {
                 LoadMoreEvent?.Invoke(this, null);
             }
         }
         else if (dy < 0 && Direction == ScrollDirection.UP)
         {
             if (pastVisiblesItems < RemainingItemsToTriggerFetch)
             {
                 LoadMoreEvent?.Invoke(this, null);
             }
         }
         IsLoading = false;
     }
 }
            public override void OnScrollStateChanged(RecyclerView recyclerView, int newState)
            {
                base.OnScrollStateChanged(recyclerView, newState);
                switch (newState)
                {
                case RecyclerView.ScrollStateIdle:
                    try
                    {
                        var positionn = mLinearLayoutManager.FindFirstVisibleItemPosition();
                        //if (positionn != 0)
                        //{
                        //    positionn += 1;
                        //}
                        GelenBase.ScrollZoomMarker(positionn);
                        Console.WriteLine(positionn);
                    }
                    catch
                    {
                    }
                    sonDurum = RecyclerView.ScrollStateIdle;
                    break;

                case RecyclerView.ScrollStateDragging:
                    sonDurum = RecyclerView.ScrollStateDragging;
                    break;

                case RecyclerView.ScrollStateSettling:
                    sonDurum = RecyclerView.ScrollStateSettling;
                    break;
                }
            }
            public override void OnScrolled(RecyclerView recyclerView, int dx, int dy)
            {
                base.OnScrolled(recyclerView, dx, dy);


                if (LayoutManager == null)
                {
                    LayoutManager = (LinearLayoutManager)recyclerView.GetLayoutManager();
                }

                var visibleItemCount = recyclerView.ChildCount;
                var totalItemCount   = recyclerView.GetAdapter().ItemCount;

                var pastItems = LayoutManager.FindFirstVisibleItemPosition();

                if (visibleItemCount + pastItems + 6 < totalItemCount)
                {
                    return;
                }

                if (IsLoading)
                {
                    return;
                }

                LoadMoreEvent?.Invoke(this, null);
            }
        public override void OnScrolled(RecyclerView recyclerView, int dx, int dy)
        {
            base.OnScrolled(recyclerView, dx, dy);

            visibleItemCount = recyclerView.ChildCount;
            totalItemCount   = mLayoutManager.ItemCount;
            firstVisibleItem = mLayoutManager.FindFirstVisibleItemPosition();

            if (loading)
            {
                if (totalItemCount > previousTotal)
                {
                    loading       = false;
                    previousTotal = totalItemCount;
                }
            }
            if (!loading && (totalItemCount - visibleItemCount) <= (firstVisibleItem + visibleThreshold))
            {
                // End has been reached
                var adapter = recyclerView.GetAdapter() as FeedPostAdapter;

                if (OnEndReach != null)
                {
                    OnEndReach(page);
                    page++;
                }

                loading = true;
            }
        }
        void SharedInitialize()
        {
            user          = CrossSettings.Current.GetValueOrDefaultJson <User>("User");
            layoutManager = new LinearLayoutManager(activity);
            SetLayoutManager(layoutManager);
            // emptyFeedLayout = FindViewById<LinearLayout>(Resource.Id.emptyFeedLayout);
            var list = new List <FeedItem>();

            if (headerView != null)
            {
                list.Add(new FeedItem());
            }
            adapter = new CustomRecyclerViewAdapter <FeedItem>(list, GetView, CreateViewHolder, GetViewType);
            SetAdapter(adapter);



            // adapter.NoContentText = "No content yet. Try to follow some profiles.";

            AddOnScrollListener(new RecyclerViewScrollListener(() =>
            {
                var visibleItemCount  = ChildCount;
                var totalItemCount    = adapter.Items.Count(/*m => m.PostType != NewsFeedPostTypes.Advertisement*/);
                var pastVisiblesItems = layoutManager.FindFirstVisibleItemPosition();

                if ((visibleItemCount + pastVisiblesItems) >= totalItemCount && !LoadingData && totalItemCount > 9 && totalItemCount != 0 && itemsLoaded >= 20)
                {
                    GetNewsFeedItems(false);
                }
            }));

            GetNewsFeedItems(true);
        }
Beispiel #10
0
            // 대화를 클릭했을 때 발생하는 메소드
            void OnClick(int iPosition, int type)
            {
                if (type == (int)CLICK_TYPE.CLICK)
                {
                    //일반 터치 시 대화 액티비티로 이동
                    Context context = MainActivity._Instance;

                    Intent intent = new Intent(context, typeof(DialogueActivity));
                    intent.PutExtra("address", _DialogueSet[iPosition].Address);

                    context.StartActivity(intent);

                    //현재 스크롤 위치 기억
                    LinearLayoutManager layoutManager = (LinearLayoutManager)_LayoutManager;
                    TabFragManager._Instance.ScrollPosition[_DialogueSet.Lable] = layoutManager.FindFirstVisibleItemPosition();
                }
                else if (type == (int)CLICK_TYPE.LONG_CLICK)
                {
                    string majorLableStr = "대표 레이블 = " + _DialogueSet[iPosition].MajorLable + "\n";
                    string lableStr      = "레이블 = ";
                    foreach (int lableElem in _DialogueSet[iPosition].Lables)
                    {
                        lableStr += lableElem + " ";
                    }
                    string msgCnt = "\n문자 수 = " + _DialogueSet[iPosition].Count.ToString();
                    Toast.MakeText(Android.App.Application.Context, majorLableStr + lableStr + msgCnt, ToastLength.Short).Show();
                    //롱 터치 시 옵션 제공 (현재는 디버깅용으로 레이블 표시)
                }
            }
            public override void OnScrolled(RecyclerView recyclerView, int dx, int dy)
            {
                try
                {
                    base.OnScrolled(recyclerView, dx, dy);

                    var visibleItemCount = recyclerView.ChildCount;
                    var totalItemCount   = recyclerView.GetAdapter().ItemCount;

                    var pastVisibleItems = LayoutManager.FindFirstVisibleItemPosition();
                    if (pastVisibleItems == 0 && (visibleItemCount != totalItemCount))
                    {
                        //Load More  from API Request
                        if (LoadMoreEvent != null)
                        {
                            LoadMoreEvent(this, null);
                        }
                        //Start Load More messages From Database
                    }
                    else
                    {
                        if (SwipeRefreshLayout.Refreshing)
                        {
                            SwipeRefreshLayout.Refreshing = false;
                            SwipeRefreshLayout.Enabled    = false;
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
        public override void OnScrolled(RecyclerView recyclerView, int dx, int dy)
        {
            base.OnScrolled(recyclerView, dx, dy);

            var visibleItemCount  = recyclerView.ChildCount;
            var totalItemCount    = recyclerView.GetAdapter().ItemCount;
            var pastVisiblesItems = LayoutManager.FindFirstVisibleItemPosition();

            if ((visibleItemCount + pastVisiblesItems) >= totalItemCount && !IsLoading && dy > 0)
            {
                LoadMoreEvent?.Invoke(this, null);
            }

            if (scrolledDistance > HIDE_THRESHOLD && controlsVisible)
            {
                OnHide?.Invoke(this, null);
                controlsVisible  = false;
                scrolledDistance = 0;
            }

            else if (scrolledDistance < -HIDE_THRESHOLD && !controlsVisible)
            {
                OnShow?.Invoke(this, null);
                controlsVisible  = true;
                scrolledDistance = 0;
            }

            if ((controlsVisible && dy > 0) || (!controlsVisible && dy < 0))
            {
                scrolledDistance += dy;
            }
        }
Beispiel #13
0
        public override void OnPause()
        {
            base.OnPause();

            //현재 스크롤 위치 기억
            LinearLayoutManager layoutManager = (LinearLayoutManager)_LayoutManager;

            TabFragManager._Instance.ScrollPosition[_DialogueSet.Lable] = layoutManager.FindFirstVisibleItemPosition();
        }
        // This happens many times a second during a scroll, so be wary of the code you place here.
        // We are given a few useful parameters to help us work out if we need to load some more data,
        // but first we check if we are waiting for the previous load to finish.
        public override void OnScrolled(RecyclerView recyclerView, int dx, int dy)
        {
            var lastVisibleItemPosition = mLayoutManager.FindFirstVisibleItemPosition();

            if (lastVisibleItemPosition < visibleThreshold)
            {
                LoadMore?.Invoke(this, new LoadMoreEventArgs {
                    Page = lastVisibleItemPosition, TotalItemsCount = 0
                });
            }
        }
        public override void OnScrolled(RecyclerView recyclerView, int dx, int dy)
        {
            base.OnScrolled(recyclerView, dx, dy);

            int currentFirstVisible = LayoutManager.FindFirstVisibleItemPosition();

            if (currentFirstVisible == 0)
            {
                LoadMoreEvent(this, true);
            }
        }
        public override void OnScrolled(RecyclerView recyclerView, int dx, int dy)
        {
            base.OnScrolled(recyclerView, dx, dy);

            var visibleItemCount  = recyclerView.ChildCount;
            var totalItemCount    = recyclerView.GetAdapter().ItemCount;
            var pastVisiblesItems = LayoutManager.FindFirstVisibleItemPosition();

            if ((visibleItemCount + pastVisiblesItems) >= totalItemCount)
            {
                LoadMoreEvent(this, null);
            }
        }
        public override void OnScrolled(RecyclerView recyclerView, int dx, int dy)
        {
            base.OnScrolled(recyclerView, dx, dy);

            int visibleItemCount  = recyclerView.ChildCount;
            int totalItemCount    = recyclerView.GetAdapter().ItemCount;
            int pastVisiblesItems = LayoutManager.FindFirstVisibleItemPosition();

            if ((visibleItemCount + pastVisiblesItems) >= totalItemCount)
            {
                Log.Error("ONSCROLLED ", visibleItemCount + ", " + totalItemCount + " " + pastVisiblesItems);

                LoadMoreEvent(this, null);
            }
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            rootView      = (LinearLayout)inflater.Inflate(Resource.Layout.reading_and_writing_fragment, container, false);
            mRecyclerView = rootView.FindViewById <RecyclerView>(Resource.Id.recyclerView);

            mRecyclerView.HasFixedSize = true;

            mLayoutManager = new LinearLayoutManager(Activity);
            mRecyclerView.SetLayoutManager(mLayoutManager);

            mAdapter = new RecyclerViewAdapter(App.db.GetAllImages(), Activity);
            mRecyclerView.SetAdapter(mAdapter);

            if (App.CurrentImagePossition != -1)
            {
                if (!(mLayoutManager.FindFirstVisibleItemPosition() <= App.CurrentImagePossition && mLayoutManager.FindLastVisibleItemPosition() >= App.CurrentImagePossition))
                {
                    Activity.RunOnUiThread(() =>
                    {
                        mLayoutManager.ScrollToPositionWithOffset(App.CurrentImagePossition, 20);
                    });;
                }
                //StartPostponedEnterTransition();
            }
            else
            {
                //StartPostponedEnterTransition();
            }

            mAdapter.ItemClick += delegate
            {
                var view = mRecyclerView.FindViewHolderForAdapterPosition(mAdapter.ClickedPosition) as RecyclerViewHolder;

                var tmp = view.Slika.TransitionName;
                GuessingImageFragment gif = new GuessingImageFragment(mAdapter.clickedImage.Id);
                //gif.SharedElementEnterTransition = new AutoTransition();
                //gif.EnterTransition = new Fade();
                //setExitTransition(new Fade());
                Activity.FragmentManager.BeginTransaction()
                .Replace(App.fragmentContainer.Id, gif, "guessing")
                .AddSharedElement(view.Slika, mAdapter.clickedImage.Name)
                .AddToBackStack(null)
                .Commit();
                App.CurrentFragment = gif;
            };

            return(rootView);
        }
Beispiel #19
0
        public override void OnScrolled(Android.Support.V7.Widget.RecyclerView recyclerView, int dx, int dy)
        {
            LinearLayoutManager layoutManager = (LinearLayoutManager)recyclerView.GetLayoutManager();

            int firstVisible = layoutManager.FindFirstVisibleItemPosition();
            int visibleCount = Math.Abs(firstVisible - layoutManager.FindLastCompletelyVisibleItemPosition());
            int itemCount    = recyclerView.GetAdapter().ItemCount;

            if (firstVisible != _lastFirstVisible || visibleCount != _lastVisibleCount || itemCount != _lastItemCount)
            {
                _scrollListener.OnScroll(null, firstVisible, visibleCount, itemCount);
                _lastVisibleCount = firstVisible;
                _lastVisibleCount = visibleCount;
                _lastItemCount    = itemCount;
            }
        }
        public override void OnScrolled(RecyclerView recyclerView, int dx, int dy)
        {
            base.OnScrolled(recyclerView, dx, dy);

            var childCount = recyclerView.ChildCount;
            var itemCount  = recyclerView.GetAdapter().ItemCount;
            var firstVisibleItemPosition = _linearLayoutManager.FindFirstVisibleItemPosition();

            if (childCount + firstVisibleItemPosition >= itemCount)
            {
                if (LoadMoreEvent != null)
                {
                    LoadMoreEvent(this, null);
                }
            }
        }
Beispiel #21
0
        //TODO: called too often
        public void SaveFilePos()
        {
            if (curFilePath.Equals(""))
            {
                return;
            }

            int curRow = linesLayoutManager.FindFirstVisibleItemPosition() - 1;

            GetPreferences(FileCreationMode.Private).Edit().PutLong(curFilePath, GetPosition(lines, curRow, -1, true)).Commit();

            List <string> recent = new List <string>();

            for (int i = 0; i < 4; i++)
            {
                string item = GetPreferences(FileCreationMode.Private).GetString("recent" + i, "");
                if (item.Length > 0)
                {
                    recent.Add(item);
                }
            }
            int pos = recent.IndexOf(curFilePath);

            if (pos > -1)
            {
                recent.RemoveAt(pos);
            }
            if (recent.Count > 3)
            {
                recent.RemoveAt(3);
            }
            recent.Insert(0, curFilePath);

            for (int i = 0; i < recent.Count; i++)
            {
                GetPreferences(FileCreationMode.Private).Edit().PutString("recent" + i, recent[i]).Commit();
            }

            if (Build.VERSION.SdkInt < BuildVersionCodes.Honeycomb)
            {
                SupportInvalidateOptionsMenu();
            }
            else
            {
                InvalidateOptionsMenu();
            }
        }
        private void CreateRowView()
        {
            _rows = new RecyclerView(Context);
            ((SimpleItemAnimator)_rows.GetItemAnimator()).SupportsChangeAnimations = false;

            var layoutManager = new LinearLayoutManager(Context);

            _rows.SetLayoutManager(layoutManager);

            var dividerDecoration = new DividerItemDecoration(Context, layoutManager.Orientation);

            dividerDecoration.SetDrawable(HorizontalRowDivider);
            _rows.AddItemDecoration(dividerDecoration);

            if (LazyLoad)
            {
                _rows.ScrollChange += (s, e) =>
                {
                    int firstVisibleItemPosition = layoutManager.FindFirstVisibleItemPosition();

                    if (!_gettingRows && firstVisibleItemPosition > 0 && _adapter.ItemCount % LazyLoadLimit == 0 && firstVisibleItemPosition + _rows.ChildCount >= _adapter.ItemCount)
                    {
                        _gettingRows = true;

                        var dialog = new ProgressDialog(Context, Resource.Style.ProgressDialogTheme)
                        {
                            Indeterminate = true
                        };
                        dialog.SetCancelable(false);
                        dialog.Show();

                        try
                        {
                            Task.Run(() => _adapter.AddRows(GetNextRowSet()));
                        }
                        finally
                        {
                            dialog.Dismiss();
                        }

                        _gettingRows = false;
                    }
                };
            }
        }
Beispiel #23
0
 void UpdateProgressBar(int position, long progress)
 {
     queue[position].progress = (int)(progress * 100);
     DownloadQueue.instance?.RunOnUiThread(() =>
     {
         LinearLayoutManager LayoutManager = (LinearLayoutManager)DownloadQueue.instance?.ListView?.GetLayoutManager();
         if (LayoutManager != null && position >= LayoutManager.FindFirstVisibleItemPosition() && position <= LayoutManager.FindLastVisibleItemPosition())
         {
             View view                = DownloadQueue.instance.ListView.GetChildAt(position - LayoutManager.FindFirstVisibleItemPosition());
             DownloadHolder holder    = (DownloadHolder)DownloadQueue.instance.ListView.GetChildViewHolder(view);
             holder.Progress.Progress = (int)(progress * 100);
         }
     });
     if (queue.Count == 1)
     {
         SetNotificationProgress((int)(progress * 100));
     }
 }
        public override void OnScrolled(RecyclerView recyclerView, int dx, int dy)
        {
            base.OnScrolled(recyclerView, dx, dy);

            var visibleItemCount  = recyclerView.ChildCount;
            var totalItemCount    = recyclerView.GetAdapter().ItemCount;
            var pastVisiblesItems = LayoutManager.FindFirstVisibleItemPosition();

            if (totalItemCount != 0
                //&& pastVisiblesItems > 0
                &&
                (
                    RemainingItemsToTriggerFetch >= totalItemCount ||
                    (visibleItemCount + pastVisiblesItems + RemainingItemsToTriggerFetch) >= totalItemCount
                ))
            {
                LoadMoreEvent?.Invoke(this, null);
            }
        }
        public override void OnScrolled(RecyclerView recyclerView, int dx, int dy)
        {
            base.OnScrolled(recyclerView, dx, dy);

            LinearLayoutManager layoutManager = (LinearLayoutManager)recyclerView.GetLayoutManager();

            int firstVisible = layoutManager.FindFirstVisibleItemPosition();
            int visibleCount = Math.Abs(firstVisible - layoutManager.FindLastVisibleItemPosition());
            int itemCount    = recyclerView.GetAdapter().ItemCount;

            if (firstVisible != lastFirstVisible ||
                visibleCount != lastVisibleCount ||
                itemCount != lastItemCount)
            {
                scrollListener.OnScroll(null, firstVisible, visibleCount, itemCount);
                lastFirstVisible = firstVisible;
                lastVisibleCount = visibleCount;
                lastItemCount    = itemCount;
            }
        }
            public override void OnScrolled(RecyclerView recyclerView, int dx, int dy)
            {
                try
                {
                    base.OnScrolled(recyclerView, dx, dy);

                    var visibleItemCount = recyclerView.ChildCount;
                    var totalItemCount   = recyclerView.GetAdapter().ItemCount;

                    var pastVisiblesItems = LayoutManager.FindFirstVisibleItemPosition();
                    if (visibleItemCount + pastVisiblesItems + 8 >= totalItemCount)
                    {
                        if (IsLoading == false)
                        {
                            LoadMoreEvent?.Invoke(this, null);
                            IsLoading = true;
                        }
                    }
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception);
                }
            }
            public async override void OnScrolled(RecyclerView recyclerView, int dx, int dy)
            {
                base.OnScrolled(recyclerView, dx, dy);

                visibleItemCount = recyclerView.ChildCount;
                totalItemCount   = linearLayoutManager.ItemCount;
                firstVisibleItem = linearLayoutManager.FindFirstVisibleItemPosition();

                if (loading)
                {
                    if (totalItemCount > previousTotal)
                    {
                        loading       = false;
                        previousTotal = totalItemCount;
                    }
                }

                if (!loading && (totalItemCount - visibleItemCount) <= (firstVisibleItem + visibleThreshold))
                {
                    loading = true;
                    // Request more entries.
                    await viewModel.LoadMore();
                }
            }
        /// <summary>
        /// This method calculates the current scroll position and its offset to help new attached
        /// recyclerView on window at that position and offset
        /// </summary>
        /// <seealso cref="GetScrollPosition()"/>
        /// <seealso cref="GetScrollPositionOffset()"/>
        private void RenewScrollPosition(RecyclerView recyclerView)
        {
            LinearLayoutManager layoutManager = (LinearLayoutManager)recyclerView.GetLayoutManager();

            mScrollPosition = layoutManager.FindFirstCompletelyVisibleItemPosition();
            // That means there is no completely visible Position.
            if (mScrollPosition == -1)
            {
                mScrollPosition = layoutManager.FindFirstVisibleItemPosition();
                // That means there is just a visible item on the screen
                if (mScrollPosition == layoutManager.FindLastVisibleItemPosition())
                {
                }
                else
                {
                    // in this case we use the position which is the last & first visible item.
                    // That means there are 2 visible item on the screen. However, second one is not
                    // completely visible.
                    mScrollPosition = mScrollPosition + 1;
                }
            }

            mScrollPositionOffset = layoutManager.FindViewByPosition(mScrollPosition).Left;
        }
        public override void OnScrolled(RecyclerView recyclerView, int dx, int dy)
        {
            base.OnScrolled(recyclerView, dx, dy);

            visibleItemCount = recyclerView.ChildCount;
            totalItemCount   = _linearLayoutManager.ItemCount;
            firstVisibleItem = _linearLayoutManager.FindFirstVisibleItemPosition();

            if (loading)
            {
                if (totalItemCount > previousTotal)
                {
                    loading       = false;
                    previousTotal = totalItemCount;
                }
            }

            if (!loading && (totalItemCount - visibleItemCount) <= firstVisibleItem)
            {
                // End has been reached
                LoadMore();
                loading = true;
            }
        }
Beispiel #30
0
        public void OnClick(View v)
        {
            LinearLayoutManager linearLayoutManager = (LinearLayoutManager)mRecyclerView.GetLayoutManager();

            adapter.AddItem(linearLayoutManager.FindFirstVisibleItemPosition() + 1, insertData);
        }