English 中文(简体)
时间框架和系统时间
原标题:TimingFramework and System time

我在应用程序中遇到动画问题, 以及系统时间可以更改的事实。 我以这种方式创建动画对象 :

animator = new Animator(600, Animator.INFINITE, Animator.RepeatBehavior.REVERSE, setter);

The setter is an alpha property that is varying from 0.0 to 1.0. The problem is that whenever i change the system time, the animation stops/blocks. It restarts sometimes after a while, depending on the system time i set. Is there a way that i can fix this ? Thanks a lot.

最佳回答

Put in a Timer and schedule to work during the same time duration of the animator (timer s run method will instantiate the animator object). So whenever the animator stops it will be re-instantiated like the following way:
The timer methods check if the animator is working or not, and when the answer is negative, it will instantiate another animator with the same parameters but only to animate in a period time duration equal to the remaining time.

代码示例:

public void execute() {
start();
timer_.scheduleRepeating(100);
}

public void start() {
    timer_ = new Timer() {
       public void run() {
        update();
        }
    };
}


public void update() {
    if (time > neededTime) {
        timer_.cancel();
    }else {
      if(!animator) {  //needs some optimization
        animator = new Animator( ....
      }
    }   
 }  
问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签