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

java.lang.ArrayIndexOutOfBoundsException: length=10; index=-1 #630

Open
lmvpintonextbitt opened this issue Oct 2, 2023 · 1 comment
Open

Comments

@lmvpintonextbitt
Copy link

lmvpintonextbitt commented Oct 2, 2023

Issues and steps to reproduce

I have an issue with a flexbox. I have this code on oncreate the activity

          _cfWoStatusList.HasFixedSize = false;
           _llManagerWoStatusList = new FlexboxLayoutManager(Context);
           _llManagerWoStatusList.FlexDirection = FlexDirection.Row;
           _llManagerWoStatusList.FlexWrap = FlexWrap.Wrap;
           _llManagerWoStatusList.JustifyContent = JustifyContent.FlexStart + JustifyContent.SpaceAround;
           _llManagerWoStatusList.AlignItems = AlignItems.FlexStart + AlignContent.SpaceAround;
           _llManagerWoStatusList.AutoMeasureEnabled = true;
           _cfWoStatusList.SetLayoutManager(_llManagerWoStatusList);

           FlexboxItemDecoration itemDecoration = new FlexboxItemDecoration(Context);
           itemDecoration.SetOrientation(FlexboxItemDecoration.Horizontal);
           itemDecoration.SetDrawable(Context.GetDrawable(Resource.Drawable.flexbox_divider_horizontal));
           _cfWoStatusList.AddItemDecoration(itemDecoration);

           _cfWoStatusItems = new List<CfWoStatusGrpModel>();
           var _woUtils = new WoUtils();
           _adapterWoStatusGrp = new DashboardWoStatusGrpAdapter(Screen.CurrentFragment, _cfWoStatusItems, _woUtils);
           _cfWoStatusList.SetAdapter(_adapterWoStatusGrp);

Somethimes, I have this error java.lang.ArrayIndexOutOfBoundsException: length=10; index=-1
 at com.google.android.flexbox.FlexboxLayoutManager.getPositionToFlexLineIndex(FlexboxLayoutManager.java:2565)
 at com.google.android.flexbox.FlexboxItemDecoration.isFirstItemInLine(FlexboxItemDecoration.java:288)
 at com.google.android.flexbox.FlexboxItemDecoration.setOffsetAlongMainAxis(FlexboxItemDecoration.java:155)
 at com.google.android.flexbox.FlexboxItemDecoration.getItemOffsets(FlexboxItemDecoration.java:116)

I poupalte the list of itens on one adapter
                   _cfWoStatusItems.Clear();
                    _cfWoStatusList.SetItemViewCacheSize(response.Result.Count);
                    _adapterWoStatusGrp.NotifyDataSetChanged();
                    _cfWoStatusItems.AddRange(response.Result);
                    _adapterWoStatusGrp.NotifyItemRangeInserted(_cfWoStatusItems.Count, response.Result.Count);
                    _adapterWoStatusGrp.NotifyDataSetChanged();

Can you help me?

## Expected behavior
*Please describe what you expected would happen.*

## Version of the flexbox library
FlexboxLayout.Xamarin.Android nugget 3.0.0

## Link to code
*Please link to the code we can use to reproduce this issue.*
*A complete project we can build/run is preferred, if you can't provide one, please show*
*us relevant code*
@runemart
Copy link

I'm seeing the same exception in Google Play crash list, and it's always "length=10; index=-1"
(Version 3.0.0).

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