public override void OnScrolled(RecyclerView recyclerView, int dx, int dy) { base.OnScrolled(recyclerView, dx, dy); if (!(collection is IIncrementalCollection)) return; var layoutManager = recyclerView.GetLayoutManager(); var lastItem = GetLastVisibleItem(layoutManager); if (lastItem + treshold > collection.Count() && dy > 0) LoadMore(); }
public override int GetMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { // Set movement flags based on the layout manager if (recyclerView.GetLayoutManager() is GridLayoutManager) { int dragFlags = ItemTouchHelper.Up | ItemTouchHelper.Down | ItemTouchHelper.Left | ItemTouchHelper.Right; int swipeFlags = 0; return MakeMovementFlags(dragFlags, swipeFlags); } else { int dragFlags = ItemTouchHelper.Up | ItemTouchHelper.Down; int swipeFlags = ItemTouchHelper.Start | ItemTouchHelper.End; return MakeMovementFlags(dragFlags, swipeFlags); } }
private void SetRecyclerViewAdapters() { try { MAdapter = new SocialAdapter(this, SocialModelType.Groups); LayoutManager = new LinearLayoutManager(this); MRecycler.SetLayoutManager(LayoutManager); MRecycler.SetAdapter(MAdapter); MRecycler.HasFixedSize = true; MRecycler.SetItemViewCacheSize(10); MRecycler.GetLayoutManager().ItemPrefetchEnabled = true; var sizeProvider = new FixedPreloadSizeProvider(10, 10); var preLoader = new RecyclerViewPreloader <SocialModelsClass>(this, MAdapter, sizeProvider, 8); MRecycler.AddOnScrollListener(preLoader); } catch (Exception e) { Console.WriteLine(e); } }
private void SetRecyclerViewAdapters() { try { MAdapter = new InviteFriendsAdapter(this) { MUsersPhoneContacts = new ObservableCollection <Methods.PhoneContactManager.UserContact>() }; LayoutManager = new LinearLayoutManager(this); MRecycler.SetLayoutManager(LayoutManager); MRecycler.HasFixedSize = true; MRecycler.SetItemViewCacheSize(10); MRecycler.GetLayoutManager().ItemPrefetchEnabled = true; MRecycler.SetAdapter(MAdapter); } 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 layoutManager = recyclerView.GetLayoutManager() as LinearLayoutManager; var pastVisiblesItems = layoutManager?.FindFirstVisibleItemPosition(); if (visibleItemCount > 0 && totalItemCount % StaticAppSettings.PullDataPageSize > 0) { return; } if (visibleItemCount + pastVisiblesItems >= totalItemCount - _loadWhenNItemsToTheEnd) { LoadMoreEvent?.Invoke(this, null); } }
private void SetRecyclerViewAdapters() { try { MAdapter = new CustomFieldsAdapter(this) { FieldList = new ObservableCollection <CustomField>() }; LayoutManager = new LinearLayoutManager(this); MRecycler.SetLayoutManager(LayoutManager); MRecycler.HasFixedSize = true; MRecycler.SetItemViewCacheSize(10); MRecycler.GetLayoutManager().ItemPrefetchEnabled = true; MRecycler.SetAdapter(MAdapter); } catch (Exception e) { Console.WriteLine(e); } }
private void SetRecyclerViewAdapters() { try { MAdapter = new LastChatsAdapter(this, "Archived") { LastChatsList = new ObservableCollection <Classes.LastChatsClass>() }; LayoutManager = new LinearLayoutManager(this); MRecycler.SetLayoutManager(LayoutManager); MRecycler.HasFixedSize = true; MRecycler.SetItemViewCacheSize(10); MRecycler.GetLayoutManager().ItemPrefetchEnabled = true; MRecycler.SetAdapter(MAdapter); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
private void SetRecyclerViewAdapters() { try { MAdapter = new InvitationLinksAdapter(this) { LinksList = new ObservableCollection <InvitationDataObject>() }; LayoutManager = new LinearLayoutManager(this); MRecycler.SetLayoutManager(LayoutManager); MRecycler.HasFixedSize = true; MRecycler.SetItemViewCacheSize(10); MRecycler.GetLayoutManager().ItemPrefetchEnabled = true; MRecycler.SetAdapter(MAdapter); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
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; } }
private void SetRecyclerViewAdapters() { try { MAdapter = new MessageAdapter(this, UserId) { DifferList = new ObservableCollection <AdapterModelsClassUser>() }; LayoutManager = new LinearLayoutManager(this); MRecycler.SetLayoutManager(LayoutManager); MRecycler.HasFixedSize = true; MRecycler.SetItemViewCacheSize(10); MRecycler.GetLayoutManager().ItemPrefetchEnabled = true; MRecycler.SetAdapter(MAdapter); } catch (Exception e) { Console.WriteLine(e); } }
public override void OnScrolled(RecyclerView recyclerView, int dx, int dy) { var layoutManager = recyclerView.GetLayoutManager() as LinearLayoutManager; if (layoutManager == null) { throw new ArgumentNullException("LayoutManager"); } var adapter = recyclerView.GetAdapter(); if (adapter == null) { throw new ArgumentNullException("Adapter"); } var currentVisibleItemPosition = adapter.ItemCount - layoutManager.FindLastVisibleItemPosition(); _scrollDownButtonVisibilityChangedCommand.Execute(currentVisibleItemPosition > VisibleThreshold); }
private void SetRecyclerViewAdapters() { try { MAdapter = new MessageAdapter(this, UserId, false) { DifferList = new ObservableCollection <AdapterModelsClassMessage>() }; LayoutManager = new LinearLayoutManager(this); MRecycler.SetLayoutManager(LayoutManager); MRecycler.HasFixedSize = true; MRecycler.SetItemViewCacheSize(10); MRecycler.GetLayoutManager().ItemPrefetchEnabled = true; MRecycler.SetAdapter(MAdapter); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
private void SetRecyclerViewAdapters() { try { MAdapter = new NotificationsAdapter(Activity) { NotificationsList = new ObservableCollection <GetNotificationsObject.Datum>(ListUtils.MatchList) }; NotifyLayoutManager = new LinearLayoutManager(Activity); MRecycler.SetLayoutManager(NotifyLayoutManager); MRecycler.SetItemViewCacheSize(10); MRecycler.HasFixedSize = true; MRecycler.GetLayoutManager().ItemPrefetchEnabled = true; var sizeProvider = new ViewPreloadSizeProvider(); var preLoader = new RecyclerViewPreloader <GetNotificationsObject.Datum>(Activity, MAdapter, sizeProvider, 10); MRecycler.AddOnScrollListener(preLoader); MRecycler.SetAdapter(MAdapter); MAdapter.OnItemClick += MAdapterOnItemClick; MAdapter.AddButtonItemClick += MAdapterOnAddButtonItemClick; MAdapter.DeleteButtonItemClick += MAdapterOnDeleteButtonItemClick; TranslateAnimation animation1 = new TranslateAnimation(0.0f, 0.0f, 1500.0f, 0.0f) { Duration = 700 }; // animation duration MRecycler.StartAnimation(animation1); RecyclerViewOnScrollListener xamarinRecyclerViewOnScrollListener = new RecyclerViewOnScrollListener(NotifyLayoutManager); MainScrollEvent = xamarinRecyclerViewOnScrollListener; MainScrollEvent.LoadMoreEvent += MainScrollEventOnLoadMoreEvent; MRecycler.AddOnScrollListener(xamarinRecyclerViewOnScrollListener); MainScrollEvent.IsLoading = false; } catch (Exception e) { Console.WriteLine(e); } }
private void SetRecyclerViewAdapters() { try { MAdapter = new SearchHashtagAdapter(Activity) { HashTagsList = new ObservableCollection <SearchUsersHastagsObject.Hash>() }; LayoutManager = new LinearLayoutManager(Context); MRecycler.SetLayoutManager(LayoutManager); MRecycler.HasFixedSize = true; MRecycler.SetItemViewCacheSize(10); MRecycler.GetLayoutManager().ItemPrefetchEnabled = true; MAdapter.ItemClick += MAdapterOnItemClick; MRecycler.SetAdapter(MAdapter); } catch (Exception e) { Console.WriteLine(e); } }
public override void OnScrolled(RecyclerView recyclerView, int dx, int dy) { base.OnScrolled(recyclerView, dx, dy); if (dx < 0 || dy < 0 || IsReachedBottom || _collectionView.LoadMoreCommand == null) { return; } var layoutManager = recyclerView.GetLayoutManager() as LinearLayoutManager; var visibleItemCount = recyclerView.ChildCount; var totalItemCount = layoutManager.ItemCount; var firstVisibleItem = layoutManager.FindFirstVisibleItemPosition(); if (totalItemCount - visibleItemCount - _collectionView.LoadMoreMargin <= firstVisibleItem) { IsReachedBottom = true; _collectionView.LoadMoreCommand?.Execute(null); } }
private void SetRecyclerViewAdapters() { try { //Pro Recycler View MAdapter = new PaymentHistoryAdapter(this) { AffPaymentList = new ObservableCollection <AffPayment>() }; MRecycler.SetLayoutManager(new LinearLayoutManager(this)); MRecycler.SetItemViewCacheSize(20); MRecycler.HasFixedSize = true; MRecycler.NestedScrollingEnabled = false; MRecycler.GetLayoutManager().ItemPrefetchEnabled = true; MRecycler.SetAdapter(MAdapter); } catch (Exception e) { Console.WriteLine(e); } }
private void SetRecyclerViewAdapters() { try { LayoutManager = new LinearLayoutManager(Activity); MAdapter = new TrendingAdapter(Activity) { TrendingList = new ObservableCollection <Classes.TrendingClass>() }; MAdapter.ItemClick += MAdapterOnItemClick; MRecycler.SetLayoutManager(LayoutManager); MRecycler.HasFixedSize = true; MRecycler.SetItemViewCacheSize(10); MRecycler.GetLayoutManager().ItemPrefetchEnabled = true; MRecycler.SetAdapter(MAdapter); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
private void SetRecyclerViewAdapters(View view) { try { MoreRecylerView = (RecyclerView)view.FindViewById(Resource.Id.Recyler); MoreRecylerView.NestedScrollingEnabled = true; MoreSectionAdapter = new MoreSectionAdapter(Activity); switch (AppSettings.MoreTheme) { case MoreTheme.BeautyTheme: { var layoutManager = new GridLayoutManager(Activity, 4); var countListFirstRow = MoreSectionAdapter.SectionList.Where(q => q.StyleRow == 0).ToList().Count; layoutManager.SetSpanSizeLookup(new MySpanSizeLookup2(countListFirstRow, 1, 4)); //20, 1, 4 MoreRecylerView.SetLayoutManager(layoutManager); MoreRecylerView.SetAdapter(MoreSectionAdapter); break; } default: MoreRecylerView.SetLayoutManager(new LinearLayoutManager(Activity)); MoreRecylerView.SetAdapter(MoreSectionAdapter); break; } //MoreRecylerView.HasFixedSize = true; MoreRecylerView.SetItemViewCacheSize(50); MoreRecylerView.GetLayoutManager().ItemPrefetchEnabled = true; MAdView = view.FindViewById <AdView>(Resource.Id.adView); AdsGoogle.InitAdView(MAdView, MoreRecylerView); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
public override void GetItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { int position = parent.GetChildAdapterPosition(view); int orientation = 0; int headerCount = 0, footerCount = 0; var adapterObj = parent.GetAdapter(); var adapterType = adapterObj.GetType(); if (adapterType.IsAssignableFrom(typeof(RecyclerArrayAdapter <>))) { headerCount = (int)adapterType.GetMethod("GetHeaderCount").Invoke(adapterObj, null); footerCount = (int)adapterType.GetMethod("GetFooterCount").Invoke(adapterObj, null); } RecyclerView.LayoutManager layoutManager = parent.GetLayoutManager(); if (layoutManager is StaggeredGridLayoutManager) { orientation = ((StaggeredGridLayoutManager)layoutManager).Orientation; } else if (layoutManager is GridLayoutManager) { orientation = ((GridLayoutManager)layoutManager).Orientation; } else if (layoutManager is LinearLayoutManager) { orientation = ((LinearLayoutManager)layoutManager).Orientation; } if (position >= headerCount && position < parent.GetAdapter().ItemCount - footerCount || mDrawHeaderFooter) { if (orientation == OrientationHelper.Vertical) { outRect.Bottom = mHeight; } else { outRect.Right = mHeight; } } }
public int GetGoToIndex(RecyclerView recyclerView, int carouselPosition, int newPosition) { if (!(recyclerView.GetLayoutManager() is LinearLayoutManager linearLayoutManager)) { return(-1); } var currentCarouselPosition = carouselPosition; var itemSourceCount = _itemsSource.Count; var diffToStart = currentCarouselPosition + (itemSourceCount - newPosition); var diffToEnd = itemSourceCount - currentCarouselPosition + newPosition; var centerView = recyclerView.GetCenteredView(); if (centerView == null) { return(-1); } var centerPosition = linearLayoutManager.GetPosition(centerView); var increment = currentCarouselPosition - newPosition; var incrementAbs = System.Math.Abs(increment); int goToPosition; if (diffToStart < incrementAbs) { goToPosition = centerPosition - diffToStart; } else if (diffToEnd < incrementAbs) { goToPosition = centerPosition + diffToEnd; } else { goToPosition = centerPosition - increment; } return(goToPosition); }
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; int[] firstVisibleItemPositions; // Check if we're running on Android 5.0 or higher if ((int)Build.VERSION.SdkInt < 23) { firstVisibleItemPositions = new int[2]; } else { firstVisibleItemPositions = new int[3]; } var firstVisibleItem = ((StaggeredGridLayoutManager)recyclerView.GetLayoutManager()).FindFirstVisibleItemPositions( firstVisibleItemPositions)[0]; var pastVisiblesItems = firstVisibleItem; if (visibleItemCount + pastVisiblesItems + 8 >= totalItemCount) { if (IsLoading == false) { LoadMoreEvent?.Invoke(this, null); IsLoading = true; } } } catch (Exception exception) { Crashes.TrackError(exception); } }
private void SetRecyclerViewAdapters() { try { MAdapter = new RowAlbumsAdapter(Activity) { AlbumsList = new ObservableCollection <DataAlbumsObject>() }; MAdapter.OnItemClick += MAdapterOnOnItemClick; LayoutManager = new LinearLayoutManager(Activity); MRecycler.SetLayoutManager(LayoutManager); MRecycler.HasFixedSize = true; MRecycler.SetItemViewCacheSize(10); MRecycler.GetLayoutManager().ItemPrefetchEnabled = true; var sizeProvider = new FixedPreloadSizeProvider(10, 10); var preLoader = new RecyclerViewPreloader <DataAlbumsObject>(Activity, MAdapter, sizeProvider, 10); MRecycler.AddOnScrollListener(preLoader); MRecycler.SetAdapter(MAdapter); RecyclerViewOnScrollListener xamarinRecyclerViewOnScrollListener = new RecyclerViewOnScrollListener(LayoutManager); MainScrollEvent = xamarinRecyclerViewOnScrollListener; MainScrollEvent.LoadMoreEvent += MainScrollEventOnLoadMoreEvent; MRecycler.AddOnScrollListener(xamarinRecyclerViewOnScrollListener); MainScrollEvent.IsLoading = false; Inflated = EmptyStateLayout.Inflate(); EmptyStateInflater x = new EmptyStateInflater(); x.InflateLayout(Inflated, EmptyStateInflater.Type.NoSearchResult); if (!x.EmptyStateButton.HasOnClickListeners) { x.EmptyStateButton.Click += null; x.EmptyStateButton.Click += ContextSearch.TryAgainButton_Click; } } catch (Exception e) { Console.WriteLine(e); } }
private void InitRecyclerView() { _recyclerView = FindViewById <RecyclerView>(R.Id.recycler_view); _recyclerView.SetAdapter(MySliderAdapter); _recyclerView.HasFixedSize = true; _recyclerView.AddOnScrollListener( new MyRvOnScrollListener( null, (rv, newState) => { if (newState == RecyclerView.ScrollStateIdle) { OnActiveCardChange(); } } ) ); _layoutManger = (CardSliderLayoutManager)_recyclerView.GetLayoutManager(); new CardSnapHelper().AttachToRecyclerView(_recyclerView); }
private void SetRecyclerViewAdapters() { try { MRecycler.NestedScrollingEnabled = false; MAdapter = new GiftAdapter(Activity); MAdapter.OnItemClick += GiftAdapterOnItemClick; LayoutManager = new GridLayoutManager(Activity, 3); MRecycler.SetLayoutManager(LayoutManager); MRecycler.SetItemViewCacheSize(20); MRecycler.HasFixedSize = true; MRecycler.GetLayoutManager().ItemPrefetchEnabled = true; var sizeProvider = new FixedPreloadSizeProvider(10, 10); var preLoader = new RecyclerViewPreloader <GiftObject.DataGiftObject>(Activity, MAdapter, sizeProvider, 10); MRecycler.AddOnScrollListener(preLoader); MRecycler.SetAdapter(MAdapter); } catch (Exception e) { Console.WriteLine(e); } }
private void SetRecyclerViewAdapters() { try { MAdapter = new ContactsAdapter(this, false, ContactsAdapter.TypeTextSecondary.About) { UserList = new ObservableCollection <UserDataObject>(), }; LayoutManager = new LinearLayoutManager(this); MRecycler.SetLayoutManager(LayoutManager); MRecycler.HasFixedSize = true; MRecycler.SetItemViewCacheSize(10); MRecycler.GetLayoutManager().ItemPrefetchEnabled = true; var sizeProvider = new FixedPreloadSizeProvider(10, 10); var preLoader = new RecyclerViewPreloader <UserDataObject>(this, MAdapter, sizeProvider, 10); MRecycler.AddOnScrollListener(preLoader); MRecycler.SetAdapter(MAdapter); MRecycler.Visibility = ViewStates.Visible; if (TypePage == "Edit") { // Add first image Default MAdapter.UserList.Add(new UserDataObject { UserId = "0", Avatar = "addImage", Name = GetString(Resource.String.Lbl_AddParticipants), About = GetString(Resource.String.Lbl_Group_Add_Description) }); MAdapter.NotifyDataSetChanged(); } } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
private bool isLastRaw(RecyclerView parent, int pos, int spanCount, int childCount) { RecyclerView.LayoutManager layoutManager = parent.GetLayoutManager(); if (layoutManager is GridLayoutManager) { childCount = childCount - childCount % spanCount; if (pos >= childCount)// 如果是最后一行,则不需要绘制底部 { return(true); } } else if (layoutManager is StaggeredGridLayoutManager) { int orientation = ((StaggeredGridLayoutManager)layoutManager) .Orientation; // StaggeredGridLayoutManager 且纵向滚动 if (orientation == StaggeredGridLayoutManager.Vertical) { childCount = childCount - childCount % spanCount; // 如果是最后一行,则不需要绘制底部 if (pos >= childCount) { return(true); } } else // StaggeredGridLayoutManager 且横向滚动 { // 如果是最后一行,则不需要绘制底部 if ((pos + 1) % spanCount == 0) { return(true); } } } return(false); }
private void SetRecyclerViewAdapters() { try { MAdapter = new VideoRowAdapter(Activity) { VideoList = new ObservableCollection <VideoObject>() }; LayoutManager = new LinearLayoutManager(Context); MRecycler.SetLayoutManager(LayoutManager); MRecycler.HasFixedSize = true; MRecycler.SetItemViewCacheSize(10); MRecycler.GetLayoutManager().ItemPrefetchEnabled = true; var sizeProvider = new FixedPreloadSizeProvider(10, 10); var preLoader = new RecyclerViewPreloader <VideoObject>(Activity, MAdapter, sizeProvider, 10); MRecycler.AddOnScrollListener(preLoader); MRecycler.SetAdapter(MAdapter); } catch (Exception e) { Console.WriteLine(e); } }
private void SetRecyclerViewAdapters() { try { MAdapter = new BlockedUsersAdapter(this) { BlockedUsersList = new ObservableCollection <Block>() }; LayoutManager = new LinearLayoutManager(this); MRecycler.SetLayoutManager(LayoutManager); MRecycler.HasFixedSize = true; MRecycler.SetItemViewCacheSize(10); MRecycler.GetLayoutManager().ItemPrefetchEnabled = true; var sizeProvider = new FixedPreloadSizeProvider(10, 10); var preLoader = new RecyclerViewPreloader <Block>(this, MAdapter, sizeProvider, 10); MRecycler.AddOnScrollListener(preLoader); MRecycler.SetAdapter(MAdapter); } catch (Exception e) { Console.WriteLine(e); } }
protected override void OnTargetFound(View targetView, RecyclerView.State state, Action action) { RecyclerView.LayoutManager manager = mRecyclerView.GetLayoutManager(); if (null == manager) { return; } if (manager is PagerGridLayoutManager) { PagerGridLayoutManager layoutManager = (PagerGridLayoutManager)manager; int pos = mRecyclerView.GetChildAdapterPosition(targetView); int[] snapDistances = layoutManager.GetSnapOffset(pos); int dx = snapDistances[0]; int dy = snapDistances[1]; Logi("dx = " + dx); Logi("dy = " + dy); int time = CalculateTimeForScrolling(Math.Max(Math.Abs(dx), Math.Abs(dy))); if (time > 0) { action.Update(dx, dy, time, new DecelerateInterpolator()); } } }
public void CenterIfNeeded(RecyclerView recyclerView, bool isHorizontal) { if (!(recyclerView.GetLayoutManager() is LinearLayoutManager linearLayoutManager)) { return; } var itemSourceCount = _itemsSource.Count; var firstCompletelyItemVisible = linearLayoutManager.FindFirstCompletelyVisibleItemPosition(); var offSet = recyclerView.ComputeHorizontalScrollOffset(); if (!isHorizontal) { offSet = recyclerView.ComputeVerticalScrollOffset(); } if (firstCompletelyItemVisible == 0) { linearLayoutManager.ScrollToPositionWithOffset(itemSourceCount, -offSet); } }
private void SetRecyclerViewAdapters() { try { MAdapter = new ContactsAdapter(this, true, ContactsAdapter.TypeTextSecondary.LastSeen) { UserList = new ObservableCollection <UserDataObject>() }; LayoutManager = new LinearLayoutManager(this); MRecycler.SetLayoutManager(LayoutManager); MRecycler.HasFixedSize = true; MRecycler.SetItemViewCacheSize(10); MRecycler.GetLayoutManager().ItemPrefetchEnabled = true; var sizeProvider = new FixedPreloadSizeProvider(10, 10); var preLoader = new RecyclerViewPreloader <UserDataObject>(this, MAdapter, sizeProvider, 10); MRecycler.AddOnScrollListener(preLoader); MRecycler.SetAdapter(MAdapter); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
public override void OnScrolled(RecyclerView recyclerView, int dx, int dy) { base.OnScrolled(recyclerView, dx, dy); var infiniteListLoader = _element?.InfiniteListLoader; if (infiniteListLoader == null) { return; } var linearLayoutManager = (LinearLayoutManager)recyclerView.GetLayoutManager(); int lastVisibleItem = linearLayoutManager.FindLastVisibleItemPosition(); if (_lastVisibleItemIndex == lastVisibleItem) { return; } _lastVisibleItemIndex = lastVisibleItem; // InternalLogger.Info($"OnScrolled( lastVisibleItem: {lastVisibleItem} )"); infiniteListLoader.OnScroll(lastVisibleItem); }
public override void OnScrolled (RecyclerView recyclerView, int dx, int dy) { base.OnScrolled (recyclerView, dx, dy); var visibleItemCount = recyclerView.ChildCount; // Console.Error.WriteLine ("isRefeshing"+MySoal_Tab_1.isRefeshing); // if (MyHealth_Tab_2.isRefreshing) { Console.Error.WriteLine ("masuk"); MyHealth_Tab_2.worker.CancelAsync (); if (MyHealth_Tab_2.worker.CancellationPending) { if (MyHealth_Tab_2.worker.IsBusy == true) { } } } var totalItemCount = recyclerView.GetAdapter().ItemCount; var lastVisibleItem = ((LinearLayoutManager)recyclerView.GetLayoutManager()).FindLastCompletelyVisibleItemPosition(); if ((lastVisibleItem+1) == totalItemCount) { Console.Error.WriteLine ("scrolll222"); LoadMoreEvent (this, null); } }
private int GetOrientation(RecyclerView parent) { if (parent.GetLayoutManager() is LinearLayoutManager) { LinearLayoutManager layoutManager = (LinearLayoutManager) parent.GetLayoutManager(); return layoutManager.Orientation; } else { throw new ArgumentException("DividerItemDecoration can only be used with a LinearLayoutManager."); } }
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 lastVisibleItem = ((LinearLayoutManager)recyclerView.GetLayoutManager()).FindLastCompletelyVisibleItemPosition(); if ((lastVisibleItem+1) == totalItemCount) { LoadMoreEvent (this, null); } }
public override void OnScrolled (RecyclerView recyclerView, int dx, int dy) { pref = PreferenceManager.GetDefaultSharedPreferences(Application.Context); LinearLayoutManager linearLayoutManager = (LinearLayoutManager)recyclerView.GetLayoutManager (); int lastVisibleItem = linearLayoutManager.FindLastVisibleItemPosition(); int totalItemCount = recyclerView.GetAdapter().ItemCount; if (!IsLoading && totalItemCount <= (lastVisibleItem + visibleThreshold)) { // End has been reached // Do something var currPrefPage = pref.GetString ("CurrentPage", string.Empty); if (!String.IsNullOrEmpty (currPrefPage)) { if (Int32.Parse (currPrefPage) > 0) { currentPage++; } else { currentPage = 2; } } else { currentPage++; } var editor = pref.Edit(); editor.PutString("CurrentPage",currentPage.ToString()); editor.Apply(); IsLoading = true; Task.Factory.StartNew (async () => { try{ var newPostList = new List<Post>(); await WebClient.LoadPosts(newPostList,currentPage); (recyclerView.GetAdapter()as PostViewAdapter)._Posts.AddRange(newPostList); //recyclerView.GetAdapter().HasStableIds = true; _messageShown = false; Application.SynchronizationContext.Post (_ => {recyclerView.GetAdapter().NotifyDataSetChanged();}, null); //recyclerView.GetAdapter().NotifyItemRangeInserted(recyclerView.GetAdapter().ItemCount,newPostList.Count); }catch(Exception ex){ //Insights.Report(ex,new Dictionary<string,string>{{"Message",ex.Message}},Insights.Severity.Error); var text = ex.Message; if(!_messageShown){ Application.SynchronizationContext.Post (_ => { Toast.MakeText(Application.Context,"При загрузке данных произошла ошибка",ToastLength.Short).Show(); }, null); _messageShown = true; } } IsLoading = false; }); } }
private int GetOrientation (RecyclerView parent) { var layoutManager = parent.GetLayoutManager () as LinearLayoutManager; if (layoutManager != null) { return layoutManager.Orientation; } else { throw new ArgumentException ("DividerItemDecoration can only be used with a LinearLayoutManager."); } }
public override void OnScrolled(RecyclerView recyclerView, int dx, int dy) { var mLayoutManager = (PreCachingLayoutManager)recyclerView.GetLayoutManager(); if (dy > 0) //check for scroll down { visibleItemCount = mLayoutManager.ChildCount; totalItemCount = mLayoutManager.ItemCount; pastVisiblesItems = mLayoutManager.FindFirstVisibleItemPosition(); if (mFragment.detecting) { if ((visibleItemCount + pastVisiblesItems) >= (totalItemCount - offset)) { mFragment.detecting = false; Console.WriteLine("Loading page " + (mFragment.page + 1)); mFragment.refresher.Refreshing = true; mFragment.addPosts(mFragment.site + "feed/?paged=" + (mFragment.page + 1), false); } } } }
public override void GetItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { base.GetItemOffsets(outRect, view, parent, state); var layoutManager = (StaggeredGridLayoutManager)parent.GetLayoutManager(); int position = parent.GetChildAdapterPosition(view); if (position < layoutManager.SpanCount) { outRect.Top = headerView.heightHeader; } }
public static bool CanRecyclerViewScroll(RecyclerView view) { if (view == null || view.GetAdapter() == null || view.GetLayoutManager() == null) return false; RecyclerView.LayoutManager lm = view.GetLayoutManager(); int count = view.GetAdapter().ItemCount; int lastVisible; if (lm is LinearLayoutManager) { LinearLayoutManager llm = (LinearLayoutManager)lm; lastVisible = llm.FindLastVisibleItemPosition(); } else { throw new InvalidOperationException("Material Dialogs currently only supports LinearLayoutManager. Please report any new layout managers."); } if (lastVisible == -1) return false; bool lastItemVisible = lastVisible == count - 1; return !lastItemVisible || (view.ChildCount > 0 && view.GetChildAt(view.ChildCount - 1).Bottom > view.Height - view.PaddingBottom); }