final float timelinePosition) { if ((uiToolkitHandler != null) && !uiToolkitHandler.isInReadyState(mainObject)) return; for (int i = this.callbacks.size() - 1; i >= 0; i--) { Timeline.this.uiToolkitHandler.runOnUIThread(mainObject, new Runnable() { public void run() {
@Override public void onTimelinePulse(float durationFraction, float timelinePosition) { for (AbstractFieldInfo fInfo : propertiesToInterpolate) { // check whether the object is in the ready state if ((uiToolkitHandler != null) && !uiToolkitHandler.isInReadyState(fInfo.object)) continue; // System.err.println("Timeline @" + Timeline.this.hashCode() // + " at position " + timelinePosition); fInfo.updateFieldValue(timelinePosition); } } }
@Override public void run() { boolean shouldRunOnUIThread = false; Class<?> clazz = timeline.callback.getClass(); while ((clazz != null) && !shouldRunOnUIThread) { shouldRunOnUIThread = clazz .isAnnotationPresent(RunOnUIThread.class); clazz = clazz.getSuperclass(); } if (shouldRunOnUIThread && (timeline.uiToolkitHandler != null)) { timeline.uiToolkitHandler.runOnUIThread( timeline.mainObject, new Runnable() { public void run() { // System.err.println("Timeline @" // + timeline.hashCode()); timeline.callback.onTimelinePulse( durationFraction, timelinePosition); } }); } else { // System.err.println("Timeline @" + timeline.hashCode()); timeline.callback.onTimelinePulse(durationFraction, timelinePosition); } } };
UIToolkitHandler uiToolkitHandler = (UIToolkitHandler) pluginClass .newInstance(); uiToolkitHandler.isHandlerFor(new Object()); this.uiToolkitHandlers .add(uiToolkitHandler);
@Override public void onTimelinePulse(float durationFraction, float timelinePosition) { for (AbstractFieldInfo fInfo : propertiesToInterpolate) { // check whether the object is in the ready state if ((uiToolkitHandler != null) && !uiToolkitHandler.isInReadyState(fInfo.object)) continue; // System.err.println("Timeline @" + Timeline.this.hashCode() // + " at position " + timelinePosition); fInfo.updateFieldValue(timelinePosition); } } }
@Override public void run() { boolean shouldRunOnUIThread = false; Class<?> clazz = timeline.callback.getClass(); while ((clazz != null) && !shouldRunOnUIThread) { shouldRunOnUIThread = clazz .isAnnotationPresent(RunOnUIThread.class); clazz = clazz.getSuperclass(); } if (shouldRunOnUIThread && (timeline.uiToolkitHandler != null)) { timeline.uiToolkitHandler.runOnUIThread( timeline.mainObject, new Runnable() { public void run() { timeline.callback.onTimelineStateChanged( oldState, newState, durationFraction, timelinePosition); } }); } else { timeline.callback.onTimelineStateChanged(oldState, newState, durationFraction, timelinePosition); } } };
UIToolkitHandler uiToolkitHandler = (UIToolkitHandler) pluginClass .newInstance(); uiToolkitHandler.isHandlerFor(new Object()); this.uiToolkitHandlers .add(uiToolkitHandler);
final float timelinePosition) { if ((uiToolkitHandler != null) && !uiToolkitHandler.isInReadyState(mainObject)) return; for (int i = this.callbacks.size() - 1; i >= 0; i--) { Timeline.this.uiToolkitHandler.runOnUIThread(mainObject, new Runnable() { @Override
@Override public void onTimelinePulse(float durationFraction, float timelinePosition) { for (AbstractFieldInfo fInfo : propertiesToInterpolate) { // check whether the object is in the ready state if ((uiToolkitHandler != null) && !uiToolkitHandler.isInReadyState(fInfo.object)) continue; // System.err.println("Timeline @" + Timeline.this.hashCode() // + " at position " + timelinePosition); fInfo.updateFieldValue(timelinePosition); } } }
@Override public void run() { boolean shouldRunOnUIThread = false; Class<?> clazz = timeline.callback.getClass(); while ((clazz != null) && !shouldRunOnUIThread) { shouldRunOnUIThread = clazz .isAnnotationPresent(RunOnUIThread.class); clazz = clazz.getSuperclass(); } if (shouldRunOnUIThread && (timeline.uiToolkitHandler != null)) { timeline.uiToolkitHandler.runOnUIThread( timeline.mainObject, new Runnable() { public void run() { timeline.callback.onTimelineStateChanged( oldState, newState, durationFraction, timelinePosition); } }); } else { timeline.callback.onTimelineStateChanged(oldState, newState, durationFraction, timelinePosition); } } };
UIToolkitHandler uiToolkitHandler = (UIToolkitHandler) pluginClass .newInstance(); uiToolkitHandler.isHandlerFor(new Object()); this.uiToolkitHandlers .add(uiToolkitHandler);
final float timelinePosition) { if ((uiToolkitHandler != null) && !uiToolkitHandler.isInReadyState(mainObject)) return; for (int i = this.callbacks.size() - 1; i >= 0; i--) { Timeline.this.uiToolkitHandler.runOnUIThread(mainObject, new Runnable() { public void run() {
@Override public void onTimelineStateChanged(TimelineState oldState, TimelineState newState, float durationFraction, float timelinePosition) { if (newState == TimelineState.READY) { for (AbstractFieldInfo fInfo : propertiesToInterpolate) { // check whether the object is in the ready state if ((uiToolkitHandler != null) && !uiToolkitHandler.isInReadyState(fInfo.object)) continue; fInfo.onStart(); } } // Fix for issue 5 - update field values only when // either old or new state (or both) are active. Otherwise // it's a transition between inactive states (such as from // DONE to IDLE) that shouldn't trigger the property changes if (oldState.isActive || newState.isActive) { for (AbstractFieldInfo fInfo : propertiesToInterpolate) { // check whether the object is in the ready state if ((uiToolkitHandler != null) && !uiToolkitHandler.isInReadyState(fInfo.object)) continue; fInfo.updateFieldValue(timelinePosition); } } }
@Override public void run() { boolean shouldRunOnUIThread = false; Class<?> clazz = timeline.callback.getClass(); while ((clazz != null) && !shouldRunOnUIThread) { shouldRunOnUIThread = clazz .isAnnotationPresent(RunOnUIThread.class); clazz = clazz.getSuperclass(); } if (shouldRunOnUIThread && (timeline.uiToolkitHandler != null)) { timeline.uiToolkitHandler.runOnUIThread( timeline.mainObject, new Runnable() { @Override public void run() { // System.err.println("Timeline @" // + timeline.hashCode()); timeline.callback.onTimelinePulse( durationFraction, timelinePosition); } }); } else { // System.err.println("Timeline @" + timeline.hashCode()); timeline.callback.onTimelinePulse(durationFraction, timelinePosition); } } };
public Timeline(Object mainTimelineObject) { this.mainObject = mainTimelineObject; for (UIToolkitHandler uiToolkitHandler : TridentConfig.getInstance() .getUIToolkitHandlers()) { if (uiToolkitHandler.isHandlerFor(mainTimelineObject)) { this.uiToolkitHandler = uiToolkitHandler; break; } } // if the main timeline object is handled by a UI toolkit handler, // the setters registered with the different addProperty // APIs need to run with the matching threading policy TimelineCallback setterCallback = (this.uiToolkitHandler != null) ? new UISetter() : new Setter(); this.callback = new Chain(setterCallback); this.duration = 500; this.propertiesToInterpolate = new ArrayList<AbstractFieldInfo>(); this.id = Timeline.getId(); // this.loopsToLive = -1; this.stateStack = new Stack<TimelineState>(); this.stateStack.push(TimelineState.IDLE); this.doneCount = 0; this.ease = new Linear(); }
final float timelinePosition) { if ((uiToolkitHandler != null) && !uiToolkitHandler.isInReadyState(mainObject)) return; for (int i = this.callbacks.size() - 1; i >= 0; i--) { Timeline.this.uiToolkitHandler.runOnUIThread(mainObject, new Runnable() { public void run() {
@Override public void onTimelineStateChanged(TimelineState oldState, TimelineState newState, float durationFraction, float timelinePosition) { if (newState == TimelineState.READY) { for (AbstractFieldInfo fInfo : propertiesToInterpolate) { // check whether the object is in the ready state if ((uiToolkitHandler != null) && !uiToolkitHandler.isInReadyState(fInfo.object)) continue; fInfo.onStart(); } } // Fix for issue 5 - update field values only when // either old or new state (or both) are active. Otherwise // it's a transition between inactive states (such as from // DONE to IDLE) that shouldn't trigger the property changes if (oldState.isActive || newState.isActive) { for (AbstractFieldInfo fInfo : propertiesToInterpolate) { // check whether the object is in the ready state if ((uiToolkitHandler != null) && !uiToolkitHandler.isInReadyState(fInfo.object)) continue; fInfo.updateFieldValue(timelinePosition); } } }
@Override public void run() { boolean shouldRunOnUIThread = false; Class<?> clazz = timeline.callback.getClass(); while ((clazz != null) && !shouldRunOnUIThread) { shouldRunOnUIThread = clazz .isAnnotationPresent(RunOnUIThread.class); clazz = clazz.getSuperclass(); } if (shouldRunOnUIThread && (timeline.uiToolkitHandler != null)) { timeline.uiToolkitHandler.runOnUIThread( timeline.mainObject, new Runnable() { @Override public void run() { timeline.callback.onTimelineStateChanged( oldState, newState, durationFraction, timelinePosition); } }); } else { timeline.callback.onTimelineStateChanged(oldState, newState, durationFraction, timelinePosition); } } };
public Timeline(Object mainTimelineObject) { this.mainObject = mainTimelineObject; for (UIToolkitHandler uiToolkitHandler : TridentConfig.getInstance() .getUIToolkitHandlers()) { if (uiToolkitHandler.isHandlerFor(mainTimelineObject)) { this.uiToolkitHandler = uiToolkitHandler; break; } } // if the main timeline object is handled by a UI toolkit handler, // the setters registered with the different addProperty // APIs need to run with the matching threading policy TimelineCallback setterCallback = (this.uiToolkitHandler != null) ? new UISetter() : new Setter(); this.callback = new Chain(setterCallback); this.duration = 500; this.propertiesToInterpolate = new ArrayList<AbstractFieldInfo>(); this.id = Timeline.getId(); // this.loopsToLive = -1; this.stateStack = new Stack<TimelineState>(); this.stateStack.push(TimelineState.IDLE); this.doneCount = 0; this.ease = new Linear(); }
final float timelinePosition) { if ((uiToolkitHandler != null) && !uiToolkitHandler.isInReadyState(mainObject)) return; for (int i = this.callbacks.size() - 1; i >= 0; i--) { Timeline.this.uiToolkitHandler.runOnUIThread(mainObject, new Runnable() { @Override