2016-05-29 2 views
1

Fade animation не работает. Звонок серийно тоже не работает. Если я добавлю только один компонент для угасания, проблема все еще существует. Вот видео о том, как он выглядит в симуляторе.Re fade animation не работает должным образом codenameone

https://www.youtube.com/watch?v=mMyhUC6m9Vk

public class QuizSplash { 

private Form current; 
private Resources theme; 
Label bb; 
Label appleLabel; 
Label whiteBgLabel; 
Image whiteBg; 
Image apple; 
int deviceHeight; 

public void init(Object context) { 
    theme = UIManager.initFirstTheme("/theme"); 
    deviceHeight = Display.getInstance().getDisplayHeight(); 
    whiteBg = (Image) theme.getImage("whiteBg.png"); 
    apple = (Image) theme.getImage("apple.png").scaledWidth(deviceHeight/5); 
} 

public void start() { 
    if (current != null) { 
     current.show(); 
     return; 
    } 
    showSplashAnimation(); 
} 

public void showSplashAnimation() { 
    Form f = new Form(new LayeredLayout()); 
    f.setUIID("FormAnimation"); 
    f.getAllStyles().setBgColor(0x339900); 
    f.getAllStyles().setBgTransparency(255); 

    whiteBgLabel = new Label(whiteBg.scaledHeight(deviceHeight - 80)); 
    whiteBgLabel.setUIID("treeLabel"); 
    whiteBgLabel.getAllStyles().setBgColor(0xffffff); 
    f.add(FlowLayout.encloseCenter(whiteBgLabel)); 
    whiteBgLabel.setVisible(false); 

    Container bottomContainer = new Container(new BoxLayout(BoxLayout.X_AXIS)); 
    bottomContainer.setUIID("bottomContainer"); 
    bottomContainer.getAllStyles().setPadding(Component.LEFT, 40); 
    f.add(FlowLayout.encloseBottom(bottomContainer)); 

    Container appleContainer = new Container(new FlowLayout(Component.CENTER, Component.BOTTOM)); 
    appleLabel = new Label(apple); 
    appleLabel.setUIID("apple"); 
    appleLabel.getAllStyles().setPadding(0, 0, 0, 0); 
    appleLabel.getAllStyles().setMargin(0, 0, 0, 0); 
    appleContainer.add(appleLabel); 
    bottomContainer.add(appleContainer); 
    appleLabel.setVisible(false); 

    bb = new Label(apple); 
    bb.setVisible(false); 
    bottomContainer.add(bb); 

    //text container to fade in at last - update added starts......................... 
    quizContainer = new Container(new BoxLayout(BoxLayout.Y_AXIS)); 
    f.add(FlowLayout.encloseIn(quizContainer)); 

    TextArea question = new TextArea("Here is the question?"); 
    question.setVisible(false); 
    question.setUIID("Label"); 
    question.setEditable(false); 
    question.setGrowByContent(true); 
    question.setGrowLimit(3); 
    quizContainer.add(question); 

    Container ansContainer = new Container(new FlowLayout(Component.CENTER)); 
    quizContainer.add(ansContainer); 
    Label yes = new Label("YES"); 
    yes.setVisible(false); 
    Label no = new Label("No"); 
    no.setVisible(false); 
    ansContainer.add(yes); 
    ansContainer.add(no); 
    //update added ends......................... 

    f.show(); 

    bb.setX(-bb.getWidth()); 
    bb.setVisible(true); 
    bb.getParent().animateHierarchyAndWait(2500); 

    Display.getInstance().callSerially(new Runnable() { 

     @Override 
     public void run() { 
      appleLabel.setVisible(true); 
      appleContainer.animateHierarchyFadeAndWait(2000, 0); 
      whiteBgLabel.setVisible(true); 
      whiteBgLabel.getParent().animateLayoutFadeAndWait(3000, 0); 

     //update added starts............... 
     question.setVisible(true); 
     yes.setVisible(true); 
     no.setVisible(true); 
     quizContainer.animateLayoutFadeAndWait(2000, 0); 
     //update added ends........... 
     } 
    }); 

} 

public void stop() { 
    current = Display.getInstance().getCurrent(); 
} 

public void destroy() { 
} 

} 

Update 1: Следующий код работает в тренажере, но в реальных устройствах компонента замирания яблок в хорошо и другой имеет такую ​​же проблему.

bb.setX(-bb.getWidth()); 
    bb.setVisible(true); 
    bb.getParent().animateHierarchyAndWait(2500); 
    Display.getInstance().callSerially(() -> { 

     Display.getInstance().callSerially(() -> { 
      appleLabel.setVisible(true); 
      appleContainer.animateHierarchyFadeAndWait(2000, 0); 

      Display.getInstance().callSerially(() -> { 
       whiteBgLabel.setVisible(true); 
       whiteBgLabel.getParent().animateLayoutFadeAndWait(2000, 0); 

       Display.getInstance().callSerially(() -> { 
        question.setVisible(true); 
        yes.setVisible(true); 
        no.setVisible(true); 
        quizContainer.animateLayoutFadeAndWait(2000, 0); 
       }); 
      }); 
     }); 
    }); 

Обновление 2: Следующий код не работает как в имитаторе и устройств

bb.setX(-bb.getWidth()); 
    bb.setVisible(true); 
    bb.getParent().animateHierarchyAndWait(2500); 

    Display.getInstance().callSerially(() -> { 
     appleLabel.setVisible(true); 
      appleContainer.animateHierarchyFadeAndWait(2000, 0); 

    }); 
    Display.getInstance().callSerially(() -> { 
     whiteBgLabel.setVisible(true); 
     whiteBgLabel.getParent().animateLayoutFadeAndWait(2000, 0); 
    }); 
    Display.getInstance().callSerially(() -> { 
     question.setVisible(true); 
     yes.setVisible(true); 
     no.setVisible(true); 
     quizContainer.animateLayoutFadeAndWait(2000, 0); 
    }); 

Update3: замена вызова последовательно с flushAnimation не работает в тренажере и устройства

bb.setX(-bb.getWidth()); 
bb.setVisible(true); 
bb.getParent().animateHierarchyAndWait(2500); 
Display.getInstance().callSerially(() -> { 

    Display.getInstance().callSerially(() -> { 
     appleLabel.setVisible(true); 
     appleContainer.animateHierarchyFadeAndWait(2000, 0); 

     f.getAnimationManager().flushAnimation(() -> { 
      whiteBgLabel.setVisible(true); 
      whiteBgLabel.getParent().animateLayoutFadeAndWait(2000, 0); 
      f.getAnimationManager().flushAnimation(() -> { 
       question.setVisible(true); 
       yes.setVisible(true); 
       no.setVisible(true); 
       quizContainer.animateLayoutFadeAndWait(2000, 0); 
      }); 
     }); 
    }); 
}); 

Добавление флеш Анимация внутри вызова серийно не работает в устройствах

bb.setX(-bb.getWidth()); 
bb.setVisible(true); 
bb.getParent().animateHierarchyAndWait(2500); 
Display.getInstance().callSerially(() -> { 

    Display.getInstance().callSerially(() -> { 
     appleLabel.setVisible(true); 
     appleContainer.animateHierarchyFadeAndWait(2000, 0); 

     Display.getInstance().callSerially(() -> { 
      f.getAnimationManager().flushAnimation(() -> { 
       whiteBgLabel.setVisible(true); 
       whiteBgLabel.getParent().animateLayoutFadeAndWait(2000, 0); 
       f.getAnimationManager().flushAnimation(() -> { 
        question.setVisible(true); 
        yes.setVisible(true); 
        no.setVisible(true); 
        quizContainer.animateLayoutFadeAndWait(2000, 0); 
       }); 
      }); 
     }); 
    }); 
}); 

Update 4:

Form f = new Form(new BoxLayout(BoxLayout.Y_AXIS)); 
Label a = new Label(apple); 
Label b = new Label(apple); 
Label c = new Label(apple); 
Label d = new Label(apple); 
a.setVisible(false); 
b.setVisible(false); 
c.setVisible(false); 
d.setVisible(false); 
f.add(FlowLayout.encloseCenter(a)); 
f.add(FlowLayout.encloseCenter(b)); 
f.add(FlowLayout.encloseCenter(c)); 
f.add(FlowLayout.encloseCenter(d)); 

f.show(); 

a.setVisible(true); 
a.getParent().animateLayoutFadeAndWait(2000, 0); 

Display.getInstance().callSerially(() -> { 
    Display.getInstance().callSerially(() -> { 
     b.setVisible(true); 
     b.getParent().animateLayoutFadeAndWait(2000, 0); 

     f.getAnimationManager().flushAnimation(() -> { 
      Display.getInstance().callSerially(() -> { 
       c.setVisible(true); 
       c.getParent().animateLayoutFadeAndWait(2000, 0); 

       Display.getInstance().callSerially(() -> { 
        d.setVisible(true); 
        d.getParent().animateLayoutFadeAndWait(2000, 0); 
       }); 
      }); 
     }); 
    }); 
}); 
+0

[ok я зарегистрировал проблему здесь] (https://github.com/codenameone/CodenameOne/issues/1785) – beck

+0

Можете ли вы также приложить изображения к проблеме, чтобы я мог ее запустить? –

+0

[прикрепленные изображения] (https://drive.google.com/open?id=0B8ATnICIY2S8UWdQVTlXMVNWcWc) – beck

ответ

0

Это не работает хорошо для меня. Я бы предложил установить ярлыки сами по себе, чтобы они отображались как ложные, а не только их родительские контейнеры, поскольку перерисовка, вызванная самим ярлыком, могла пройти через.

Также вы можете попробовать запустить анимацию в шоу-слушателе, а не только callSerially, это должно дать форме достаточно времени для появления.

+0

Разве код не компилировался? Это скомпилировано для меня. Вы хотите, чтобы я сам рассказал о проекте? Сначала я тестировал, установив видимость ярлыков на false, но это не сработало, поэтому я установил видимость своих родителей на false, но тот же результат. И я продолжал звонить в основном в show listener (не работает), а также пытался showlistener без вызова серийно, но ничего хорошего – beck

+0

https://drive.google.com/file/d/0B8ATnICIY2S8MFVhcUdFOHkwS1E/view?usp=sharing – beck

+0

Он скомпилирован, но я не знаю, я вижу Apple и вижу только часть мигания. Многое не ясно, что вы сделали, например. разрешения для изображений и т. д., а так как код немного подробный, сложнее его прорыть. Я предлагаю установить все вещи, которые не должны отображаться на видимом false. У вас слишком много вещей, происходящих сразу в этом тестовом примере, поэтому нам трудно следовать конкретной проблеме. Я предлагаю устранить все, пока вы не найдете самый узкий возможный тестовый пример. –