Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stikcy header breaks on Android side for Vertical grid layout. #2

Open
gsalve opened this issue Apr 3, 2020 · 4 comments
Open

Stikcy header breaks on Android side for Vertical grid layout. #2

gsalve opened this issue Apr 3, 2020 · 4 comments

Comments

@gsalve
Copy link

gsalve commented Apr 3, 2020

For grid layout it is not working correctly at some cases.

Screenshot_1585898086
Screenshot_1585898081

@gsalve
Copy link
Author

gsalve commented Apr 3, 2020

May be this is beacause of the Empty footer view that was added in the bottom.

@gsalve gsalve closed this as completed Apr 3, 2020
@gsalve gsalve reopened this Apr 3, 2020
@gsalve
Copy link
Author

gsalve commented Apr 3, 2020

If we scroll fast through the Grid list view then it is showing.

Screenshot_1585898926

@gsalve
Copy link
Author

gsalve commented Apr 3, 2020

GetHeaderLayout returns the wrong item if we scroll fast.
headerView = recyclerView.GetChildAt(topItemInRecyclerViewIndex); it is not giving correct data always if we scroll fast.

public VIEW GetHeaderLayout(int itemPosition)
{
var headerPosition = 0;

        for (int i = 0; i < VM.Items.Count; i++)
        {
            itemPosition -= VM.Items[i].Count;
            itemPosition--;
            if (itemPosition >= 0)
            {
                headerPosition++;
            }
            else
            {
                break;
            }
        }            

        if (_stickyHeaderCache.ContainsKey(headerPosition))
        {
            return _stickyHeaderCache[headerPosition];
        }

        System.Console.WriteLine("$$$$$ itemPosition : headerPosition :" +itemPosition + " : " + headerPosition);

        var recyclerView = (View as RecyclerView);
        var topItemInRecyclerViewIndex = 0;
        var headerView = recyclerView.GetChildAt(topItemInRecyclerViewIndex);
        var headerView1 = recyclerView.GetChildAt(topItemInRecyclerViewIndex + 1);

        if (headerView.Height >= headerView1.Height)
		{
            System.Console.WriteLine("$$$$$ invalid added :" + headerPosition);
            return default;
        }
            
        if (IsHeader(itemPosition))
        {
            var bitmap = Bitmap.CreateBitmap(headerView.Width, headerView.Height, Bitmap.Config.Argb8888);
            var canvas = new Canvas(bitmap);
            headerView.Draw(canvas);

            var imageView = new ImageView(Context);
            imageView.SetImageBitmap(bitmap);
            var layoutParams = new LayoutParams(headerView.Width, headerView.Height);
            imageView.LayoutParameters = layoutParams;
            _stickyHeaderCache.Add(headerPosition, imageView);

            System.Console.WriteLine("$$$$$ headerPosition added :" + headerPosition);
            System.Console.WriteLine("$$$$$ recyclerView :" + recyclerView);

            return imageView;
        }
        return default;
    }

    public bool IsHeader(int itemPosition) => StickyHeaderAdapter.GetItemViewType(itemPosition) == ItemViewType.GroupHeader ? true : false;
}

@valentasm1
Copy link

@gsalve did you found solution on fast scroll issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants