我有一个Recyclerviewer,可在用户滚动时重新加载照片。但由于我连续拍了3张照片,我遇到了一个问题:
我需要一次最多加载12张照片,以确保recyclerview可滚动。每次滚动发生时,继续一次加载12张照片。这并不是真的很好。如何让我的recyclerviewer等待第一张照片加载,一旦完成,请加载下一张照片直到屏幕填满。并且只有当用户开始滚动到"白色空间"更多图片开始显示?这是我的RecyclerViewer:
private void InitRecView()
{
mRecyclerView = FindViewById<RecyclerView>(Resource.Id.recyclerView);
if (picturesinarow != 1)
{
//3 in a row
loadPhotos.LoadMoreItems(12);//(Constants.LOADNEXTITEMSTHRESHHOLD);
}
else
{
loadPhotos.LoadMoreItems(3);
}
mLayoutManager = new GridLayoutManager
(this, this.picturesinarow, GridLayoutManager.Vertical, false);
mRecyclerView.SetLayoutManager(mLayoutManager);
mAdapter = new PhotoAlbumAdapter
(loadPhotos, this.picturesinarow, (RecyclerLayout)this.recyclerLayout, this.hasHeader, this.thumbnails, this);
mRecyclerView.SetAdapter(mAdapter);
mLayoutManager.SetSpanSizeLookup(new GridViewSpansizeLookup(mAdapter, mLayoutManager));
var onScrollListener = new XamarinRecyclerViewOnScrollListener(mLayoutManager);
onScrollListener.LoadMoreEvent += (object sender, EventArgs e) =>
{
int oldCount = loadPhotos.pictures.Count;
if (picturesinarow != 1)
{
//3 in a row
loadPhotos.LoadMoreItems(12);
}
else
{
loadPhotos.LoadMoreItems(2);
}
if (!mRecyclerView.IsComputingLayout)
mAdapter.NotifyItemRangeChanged(oldCount - 1, loadPhotos.pictures.Count);
};
mRecyclerView.AddOnScrollListener(onScrollListener);
mAdapter.ItemClick += OnItemClick;
}