flexbox-layout icon indicating copy to clipboard operation
flexbox-layout copied to clipboard

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

Open lmvpintonextbitt opened this issue 2 years ago • 3 comments

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*

lmvpintonextbitt avatar Oct 02 '23 16:10 lmvpintonextbitt

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

runemart avatar Nov 30 '23 08:11 runemart