The links that have pages with gif animations are not shown

31 views
Skip to first unread message

rdvg...@gmail.com

unread,
Jul 23, 2018, 8:20:11 PM7/23/18
to CodenameOne Discussions
Hi,

Hello,
 
I have an app that shows an ad matrix (buttons). For each ad there is a different link. When a link with a gif animation is activated, only a black screen is displayed, otherwise the page will be displayed without any problem.



My code.

    private void muestraOfertas(Container cnOfertas, Vector vAnuncios) {

        cnOfertas.removeAll();
        cnOfertas.setScrollableY(true);
        Container cntB = new Container();
        int size = Display.getInstance().convertToPixels(15);
        int ancho = Display.getInstance().getDisplayWidth();
        ancho = (int) (ancho - (ancho * 0.03d));
        boolean ciclo = true;
        int c = 2;
        while (ciclo) {
            c++;
            size = (int) (ancho / c);
            int r = ancho % c;
            if (r <= 0 || c >= vAnuncios.size()) {
                ciclo = false;
            }
        };
        vAnuncios = priorizaCampanas(vAnuncios);
        Button bt[];
        bt = new Button[vAnuncios.size()];
        for (int i = 0; i < vAnuncios.size(); i++) {
            Campana1 cM1 = (Campana1) vAnuncios.elementAt(i);
            bt[i] = new Button();
            bt[i].setUIID("Label");
            Image img;
            if (cM1.getRutaLogo().equals("") || cM1.getRutaLogo().equals("null")) {
                img = res.getImage("promo.png").scaled(size, size);
            } else {
                EncodedImage lugar = EncodedImage.createFromImage(Image.createImage(size, size, 0xffcccccc), true);
                img = URLImage.createToStorage(lugar, Integer.toString(cM1.getCampana()), cM1.getRutaLogo());
            }
            bt[i].setIcon(img);
            cntB.addComponent(bt[i]);

            bt[i].addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                    Display.getInstance().execute(cM1.getEnlace());
                }
            });
        }
        Container cnCentro = new Container(new BoxLayout(BoxLayout.Y_AXIS)).add(cntB);
        cnOfertas.add(BorderLayout.CENTER, cnCentro);
    }

How can i solve this problem?

regards

rdvg...@gmail.com

unread,
Jul 23, 2018, 8:51:45 PM7/23/18
to CodenameOne Discussions
Excuse me, I discovered the problem

Thanks.

Fuad Nassar

unread,
Jun 28, 2019, 4:01:06 AM6/28/19
to CodenameOne Discussions
I have like this problem and I know that depends on the size of the gif image but what the solution for that.
 I need to load and show 1000kb GifImage without seeing black screen  Or anything fishy. 

Shai Almog

unread,
Jun 28, 2019, 11:49:38 PM6/28/19
to CodenameOne Discussions

Fuad Nassar

unread,
Jun 29, 2019, 7:22:13 AM6/29/19
to CodenameOne Discussions
I used same these cn1lib and add this image in src file


sp2.gif

and set this code in main.class
  Form hi = new Form("Gif", new BorderLayout());
        try {
            hi.add(CENTER, new ScaleImageLabel(GifImage.decode(getResourceAsStream("/sp2.gif"), 950272)));
        } catch (IOException err) {
            log(err);
        }
        hi.show();

and after tested that on the real android device (8.0.0.158v) the black screen is keeping show before loading gif img like this 

isuess.jpg


i don't like to keep this black screen and i want to get any way can help to fix this.

some ideas (but i don't know if that possible):
1) load gif image before open app 
2) use native code 
3) get a gif image from theme file 
4) replace black screen to first frame for gif image
5) reduce size of gif image( This can help, but is not a fix to the problem)




On Saturday, June 29, 2019 at 6:49:38 AM UTC+3, Shai Almog wrote:
Message has been deleted

Fuad Nassar

unread,
Jun 29, 2019, 7:25:44 AM6/29/19
to CodenameOne Discussions

Shai Almog

unread,
Jun 29, 2019, 11:13:58 PM6/29/19
to CodenameOne Discussions
Decode can take some time. You can do it on a separate thread so you won't block the EDT. It should work for this particular case although I'm not 100% sure.
Reply all
Reply to author
Forward
0 new messages