forked from nicolasgramlich/AndEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRunnableHandler.java
More file actions
63 lines (50 loc) · 1.85 KB
/
RunnableHandler.java
File metadata and controls
63 lines (50 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package org.andengine.engine.handler.runnable;
import java.util.ArrayList;
import org.andengine.engine.handler.IUpdateHandler;
/**
* (c) 2010 Nicolas Gramlich
* (c) 2011 Zynga Inc.
*
* @author Nicolas Gramlich
* @since 10:24:39 - 18.06.2010
*/
public class RunnableHandler implements IUpdateHandler {
// ===========================================================
// Constants
// ===========================================================
// ===========================================================
// Fields
// ===========================================================
private final ArrayList<Runnable> mRunnables = new ArrayList<Runnable>();
// ===========================================================
// Constructors
// ===========================================================
// ===========================================================
// Getter & Setter
// ===========================================================
// ===========================================================
// Methods for/from SuperClass/Interfaces
// ===========================================================
@Override
public synchronized void onUpdate(final float pSecondsElapsed) {
final ArrayList<Runnable> runnables = this.mRunnables;
final int runnableCount = runnables.size();
for(int i=0; i<runnableCount; i++){
runnables.get(i).run();
}
runnables.clear();
}
@Override
public synchronized void reset() {
this.mRunnables.clear();
}
// ===========================================================
// Methods
// ===========================================================
public synchronized void postRunnable(final Runnable pRunnable) {
this.mRunnables.add(pRunnable);
}
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
}