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

Error Create Pieces #241

Open
lucazin opened this issue Jul 14, 2020 · 13 comments
Open

Error Create Pieces #241

lucazin opened this issue Jul 14, 2020 · 13 comments

Comments

@lucazin
Copy link

lucazin commented Jul 14, 2020

Please someone can help me ?

Fatal Exception: java.lang.IndexOutOfBoundsException
Index: 0, Size: 0
java.util.ArrayList.get (ArrayList.java:437)
com.nightonke.boommenu.BoomMenuButton.createPieces (BoomMenuButton.java:419)
com.nightonke.boommenu.BoomMenuButton.doLayoutJobs (BoomMenuButton.java:401)
com.nightonke.boommenu.BoomMenuButton.access$1600 (BoomMenuButton.java:66)
com.nightonke.boommenu.BoomMenuButton$7.run (BoomMenuButton.java:1016)
android.os.Handler.handleCallback (Handler.java:883)

@NamGungGeon
Copy link

NamGungGeon commented Jul 25, 2020

I've encountered same error, but i'm solved it. Seeing BoomMenuButton.java, createPieces() is called when view's onLayout(activity's onResume() phase). Maybe, When view's onLayout is started and BoomMenuButton isn't initiailzed(not set builder), this exception is thrown. Solution is do initializing boomMenuButton before starting view's onLayout phase.

@lucazin
Copy link
Author

lucazin commented Nov 21, 2020

But how?
My boom menu is inside adapter.

@NamGungGeon
Copy link

I don't know your code. But I think you maybe do lazy-initializing about boommenu in adapter. View inside adapter is also has own lifecycle. In getView() of Adapter, do init boommenu.

@lucazin
Copy link
Author

lucazin commented Nov 22, 2020

Nam..

I initialize boommenu in ViewHolder Class and inside onBind i use boom menu.
i not use getview.

@lucazin
Copy link
Author

lucazin commented Nov 22, 2020

protected static class CardapioVH extends RecyclerView.ViewHolder {

    public BoomMenuButton ListaBoomInfoProduto;

    public CardapioVH(View view)
    {
        super(view);
    
 
        ListaBoomInfoProduto = (BoomMenuButton) view.findViewById(R.id.ListaBoomInfoProduto);
    }
}

@lucazin
Copy link
Author

lucazin commented Nov 22, 2020

BoomMenu.setPiecePlaceEnum(PiecePlaceEnum.HAM_2);
BoomMenu.setButtonPlaceEnum(ButtonPlaceEnum.HAM_2);

                            BoomMenu.clearBuilders();
                            for (int i = 0; i < BoomMenu.getPiecePlaceEnum().pieceNumber(); i++)
                            {
                                if(i == 0)
                               {
                                    //region Informacao Produto
                                    BoomMenu.addBuilder
                                            (
                                                    new HamButton.Builder()
                                                            .normalImageRes(R.drawable.xml_delivery_item_lista_item_informacao)
                                                            .normalText("Mais Informações")
                                                            .subNormalText(Alimentacao_ProdutosInfo.getNOME_PRODUTO())
                                                            .listener(new OnBMClickListener() {
                                                                @Override
                                                                public void onBoomButtonClick(int index)
                                                                {
                                                                    InformacoesItem(Alimentacao_ProdutosInfo,position);
                                                                }
                                                            })
                                                            .normalColorRes(R.color.blue_300)
                                                            .imageRect(new Rect(50, 40, Util.dp2px(50), Util.dp2px(50)))
                                                            .rippleEffect(true)
                                            );
                                    //endregion
                                }

@NamGungGeon
Copy link

NamGungGeon commented Nov 22, 2020

Try initialize boommenu in CardapioVH's constructor with dummy builders.
Your view is created(inflated) in not onBindViewHolder() but onCreateViewHolder().

@NamGungGeon
Copy link

solve it?

@lucazin
Copy link
Author

lucazin commented Jan 5, 2021

Sorry for late answer, i was in hospital.. now im safe.

No not resolve my friend.

Sometimes i get this kind of error.. not always but sometimes i receive and fails the app...what can i do ?

The indexes are correct in code, i dont know why..its not always this happen..

image

@NamGungGeon
Copy link

NamGungGeon commented Jan 5, 2021

I'm sorry to hear that...

Could you move your initializing codes(addBuilder) to ViewHolder's Constructor?

@lucazin
Copy link
Author

lucazin commented Jun 14, 2023

Sorry for late.

but add builder, create menu dynamic inside adapter onbind with text and values.. how can do that

@lucazin
Copy link
Author

lucazin commented Aug 11, 2023

not solve yet, someone can help me ?

@lucazin
Copy link
Author

lucazin commented Aug 13, 2023

public ComandasVH onCreateViewHolder(@nonnull ViewGroup parent, int viewType)

here?

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