Hi
I’m making use of the infinite scroll component, and it works well except for one thing. If I use setComponentLimit, I get a weir behavior every time top components are removed. The scroll goes crazy and jumps down. I’ve uploaded a video where you can see that effect. The scrolling is smooth at the beginning, but starts to fail a bit later. The video is from actual Android device, not simulator, although I get the same error everywhere. https://www.youtube.com/watch?v=dxFa7kfnRM4&feature=youtu.be Here is the relevant parts of the code used. Container contPlanes = new Container(new BoxLayout(BoxLayout.Y_AXIS)); contPlanes.addPullToRefresh(() -> { actualizaPlanes(f); }); contPlanes.setScrollableY(true); contPlanes.setScrollVisible(false); InfiniteScrollAdapter infinito = InfiniteScrollAdapter.createInfiniteScroll(contPlanes, new Runnable() { int paginaPlan = 0; @Override public void run() { ArrayList<Planes> arrayPlanes = fetchDataPlanes(paginaPlan); Container[] contenedorPlan = new Container[arrayPlanes.size()]; for (int x=0; x<contenedorPlan.length; x++) { Planes plan = arrayPlanes.get(x); if(plan == null) { InfiniteScrollAdapter.addMoreComponents(contPlanes, new Component[0], false); return; } SpanLabel tituloPlan = new SpanLabel(plan.getTitulo()); tituloPlan.setTextUIID(Display.getInstance().isTablet() ? "ContainerSplash" : "ContainerSplashPhone"); Label lblUbicacion = new Label(plan.getLocalidad() + ". " + plan.getDireccion()); lblUbicacion.setUIID(Display.getInstance().isTablet() ? "ContainerSplash" : "ContainerSplashPhone"); FontImage.setMaterialIcon(lblUbicacion, FontImage.MATERIAL_LOCATION_ON); Container contTitulo = new Container(new BoxLayout(BoxLayout.Y_AXIS)); contTitulo.addAll(tituloPlan, lblUbicacion); Button imagenPlan = new Button() { @Override protected Dimension calcPreferredSize() { return new Dimension(anchoImagen, altoImagenFinal); } }; imagenPlan.setUIID("FondoPlan"); URLImage imagen = URLImage.createToFileSystem(imgEnc, cachePlanes + plan.getId() + ".png", urlPlanes + plan.getId() + ".png", URLImage.RESIZE_SCALE); imagenPlan.setIcon(imagen); final URLImage imagenCopia = imagen; Date fechaPlanGui = plan.getFechaComienzo(); String fechaConFormato = traduceFechas(formatoMeta.format(fechaPlanGui)); String cadenaFecha; Label lblFecha = new Label(cadenaFecha); lblFecha.setUIID(Display.getInstance().isTablet() ? "ComandoAtras" : "TextoBlancoPhone"); FontImage.setMaterialIcon(lblFecha, FontImage.MATERIAL_TODAY); Label lblHora = new Label(horaMeta.format(plan.getFechaComienzo()).equals("00:00") ? "Ver detalles" : horaMeta.format( plan.getFechaComienzo()) + "h"); lblHora.setUIID(Display.getInstance().isTablet() ? "ComandoAtras" : "TextoBlancoPhone"); FontImage.setMaterialIcon(lblHora, FontImage.MATERIAL_ACCESS_TIME); Label lblPrecio = new Label(plan.getPrecio().equals("0") ? "Gratis" : plan.getPrecio() + "€"); lblPrecio.setUIID(Display.getInstance().isTablet() ? "ComandoAtras" : "TextoBlancoPhone"); FontImage.setMaterialIcon(lblPrecio, FontImage.MATERIAL_PAYMENT); Container contMetadatos = new Container(new GridLayout(3)); Button btnFavorita = new Button(); if (listaFavoritas.contains(plan.getId() + "_" + formatAntes.format(plan.getFechaComienzo()))) { btnFavorita.setUIID("FondoFavoritaSelec"); FontImage.setMaterialIcon(btnFavorita, FontImage.MATERIAL_FAVORITE, 6); } else { btnFavorita.setUIID("FondoFavorita"); FontImage.setMaterialIcon(btnFavorita, FontImage.MATERIAL_FAVORITE_BORDER, 6); } Container contIconos = new Container(new BoxLayout(BoxLayout.X_AXIS)); contIconos.add(btnFavorita); Label lblVeces = new Label("-"); lblVeces.setUIID("FondoFavorita"); contIconos.add(FlowLayout.encloseBottom(lblVeces)); Container contFavorita = new Container(new BorderLayout()); contFavorita.add(BorderLayout.EAST, contIconos); contMetadatos.setUIID("TitularSlide"); contMetadatos.add(lblFecha).addAll(FlowLayout.encloseCenter(lblHora), FlowLayout.encloseRight(lblPrecio)); Container contOverlay = new Container(new BorderLayout()); contOverlay.add(BorderLayout.NORTH, contFavorita).add(BorderLayout.SOUTH, contMetadatos); Container contCentro = new Container(new LayeredLayout()); contCentro.add(imagenPlan); contCentro.add(contOverlay); contenedorPlan[x] = new Container(new BorderLayout()); contenedorPlan[x].setUIID(plan.getDestacado() ? "ComponentePublicidad" : "ComponenteNoticia"); contenedorPlan[x].add(BorderLayout.NORTH, contTitulo).add(BorderLayout.CENTER, contCentro); imagenPlan.addActionListener((evt) -> { f.setTransitionOutAnimator(CommonTransitions.createCover(CommonTransitions.SLIDE_HORIZONTAL, false, 300)); detallePlan(f); }); } paginaPlan++; InfiniteScrollAdapter.addMoreComponents(contPlanes, contenedorPlan, paginaPlan*6 < planes.length); } }, true); infinito.setComponentLimit(20); -- You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. Visit this group at https://groups.google.com/group/codenameone-discussions. To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/ea62eceb-414b-4f14-9021-0cdcb54052dd%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
