Components of the forms disappear

22 views
Skip to first unread message

rdvg...@gmail.com

unread,
Aug 27, 2018, 11:21:15 PM8/27/18
to CodenameOne Discussions
Hi,

I have an app that I am testing on android (Samsung J7 Prime) and sporadically the components of certain form disappear (see images). When I press the Home button and look for the application, the components appear magically. 

Attached you will see the images in the same way with and without components that as mentioned are shown after pressing the home button and selecting my application.

Thank you for your support.

Screenshot_20180827-171109.pngScreenshot_20180827-171012.png 


Shai Almog

unread,
Aug 28, 2018, 1:46:40 AM8/28/18
to CodenameOne Discussions
Hi,
are you changing the layout in any way without validating after you showed the form?

rdvg...@gmail.com

unread,
Aug 28, 2018, 12:21:23 PM8/28/18
to CodenameOne Discussions
Hi,

No, I'm going to show the code (really simple) for validation.

    private void formaTienda(final Form fmLiber) {
        final Form fmTienda = new Form(new BorderLayout());
        fmTienda.getToolbar().setBackCommand("", e -> fmLiber.showBack());
        fmTienda.getToolbar().getStyle().setAlignment(Label.LEFT);
        fmTienda.setTitle(idioma.getTiendas());

        TextField txNombreFiltro = new TextField();
        TextField txNombreBusqueda = new TextField();
        txNombreBusqueda.setHint(idioma.getTienda());

        Container cnTiendas = new Container(BoxLayout.y());
        cnTiendas.setScrollableY(true);

        Container cnBusqueda = new Container(new BorderLayout()).add(BorderLayout.CENTER, txNombreBusqueda);
        Container cnFiltro = new Container(new BorderLayout());

        Style s = UIManager.getInstance().getComponentStyle("Menu");
        FontImage iBusqueda = (FontImage) FontImage.createMaterial(FontImage.MATERIAL_SEARCH, s);
        Button btBusqueda = new Button(iBusqueda, "Transparent");
        cnBusqueda.add(BorderLayout.WEST, btBusqueda);
        btBusqueda.addActionListener((ActionListener) (ActionEvent e) -> {
            ArrayList lArt = leeArrayListTienda(txNombreBusqueda.getText(), "N");
            if (lArt != null) {
                if (lArt.size() < LIMITE_DATOS) {
                    cnTiendas.removeAll();
                    for (int i = 0; i < lArt.size(); i++) {
                        Tienda tDa = (Tienda) lArt.get(i);
                        Container cnItemTienda = creaItemTienda(fmTienda, tDa);
                        cnTiendas.add(cnItemTienda);
                    }
                    cnTiendas.revalidate();
                    fmTienda.replace(cnBusqueda, cnFiltro, CommonTransitions.createSlide(CommonTransitions.SLIDE_VERTICAL, true, 200));
                } else {
                    Dialog.show(idioma.getInformacion(), idioma.getMensaje21(), idioma.getContinuar(), null);
                }
            } else {
                Dialog.show(idioma.getInformacion(), idioma.getMensaje41(), idioma.getContinuar(), null);
            }
        });

        FontImage iFiltro = (FontImage) FontImage.createMaterial(FontImage.MATERIAL_FILTER_LIST, s);
        Button btFiltro = new Button(iFiltro, "Transparent");
        btFiltro.setVerticalAlignment(Label.BOTTOM);
        btFiltro.setAlignment(CENTER);
        btFiltro.setTextPosition(Label.BOTTOM);
        cnFiltro.add(BorderLayout.WEST, btFiltro);
        cnFiltro.add(BorderLayout.CENTER, txNombreFiltro);

        btFiltro.addActionListener((ActionListener) (ActionEvent e) -> {
            txNombreBusqueda.setText("");
            txNombreFiltro.setText("");
            fmTienda.replace(cnFiltro, cnBusqueda, CommonTransitions.createSlide(CommonTransitions.SLIDE_VERTICAL, true, 200));
            cnTiendas.removeAll();
        });

        txNombreFiltro.addDataChangeListener((int type, int index) -> {
            String t = txNombreFiltro.getText();
            if (t.length() < 1) {
                for (Component cmp : cnTiendas) {
                    cmp.setHidden(false);
                    cmp.setVisible(true);
                }
            } else {
                t = t.toLowerCase();
                for (Component cmp : cnTiendas) {
                    boolean show = false;
                    String val = null;
                    if (cmp instanceof Container) {
                        val = (String) cmp.getClientProperty("busqueda");
                    }
                    show = val != null && val.toLowerCase().indexOf(t) > -1;
                    cmp.setHidden(!show);
                    cmp.setVisible(show);
                }
            }
            cnTiendas.animateLayout(250);
        });

        s = UIManager.getInstance().getComponentStyle("Title");
        FontImage iInformacion = FontImage.createMaterial(FontImage.MATERIAL_INFO, s);
        fmTienda.getToolbar().addCommandToRightBar(new Command("", iInformacion) {
            @Override
            public void actionPerformed(ActionEvent evt) {
                muestraInformacion(fmTienda, idioma.getTiendas(), idioma.getMensaje68() + idioma.getMensaje23());
            }
        });

        FloatingActionButton btNuevo = FloatingActionButton.createFAB(FontImage.MATERIAL_ADD);
        btNuevo.bindFabToContainer(fmTienda.getContentPane(), Component.RIGHT, Component.BOTTOM);
        btNuevo.addActionListener((e) -> {
            Tienda tDa = new Tienda();
            mantenimientoTienda(fmTienda, tDa, ADICIONAR);
            cnTiendas.revalidate();
        });

        fmTienda.add(BorderLayout.NORTH, cnBusqueda);
        fmTienda.add(BorderLayout.CENTER, cnTiendas);
        fmTienda.setTransitionOutAnimator(CommonTransitions.createSlide(
                CommonTransitions.SLIDE_VERTICAL, true, 500));
        fmTienda.show();
    }

Shai Almog

unread,
Aug 29, 2018, 2:11:02 AM8/29/18
to CodenameOne Discussions
Hi,
from a cursory look I don't see anything that should cause this. If you can isolate the problem to a runnable test case it would help. I suggest logging to see what happens and ideally trying to reproduce it on the simulator where you can use the Component Inspector to try and understand what happened to the components.
Reply all
Reply to author
Forward
0 new messages