本文整理汇总了C#中RecyclerView.GetLayoutManager方法的典型用法代码示例。如果您正苦于以下问题:C# RecyclerView.GetLayoutManager方法的具体用法?C# RecyclerView.GetLayoutManager怎么用?C# RecyclerView.GetLayoutManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RecyclerView
的用法示例。
在下文中一共展示了RecyclerView.GetLayoutManager方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnScrolled
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();
}
示例2: GetMovementFlags
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);
}
}
示例3: OnScrolled
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);
}
}
示例4: GetOrientation
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.");
}
}
示例5: OnScrolled
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);
}
}
示例6: OnScrolled
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;
});
}
}
示例7: GetItemOffsets
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;
}
}
示例8: CanRecyclerViewScroll
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);
}
示例9: GetOrientation
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.");
}
}
示例10: OnScrolled
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);
}
}
}
}