public synchronized void unregisterApp(GameView app) { if (app == null || !isRegistered(app)) { return; } if (mainContext != null && mainContext.getView() == app) { mainContext = null; } if (allContexts != null) { for (int i = 0; i < allContexts.size(); i++) { GameContext context = (GameContext) allContexts.get(i); if (context.getView() == app) { allContexts.remove(i); break; } } if (mainContext == null) { mainContext = (GameContext) allContexts.get(0); } if (allContexts.size() == 1) { allContexts = null; } } if (getNumRegisteredApps() == 0) { timer.stop(); } }
public synchronized GameContext registerApp(GameView app) { if (app == null) { return null; } GameContext context = getAppContext(app); if (context != null) { return context; } boolean wasEmpty = (getNumRegisteredApps() == 0); GameContext newContext = new GameContext(app, timer); if (mainContext == null) { mainContext = newContext; } else { if (allContexts == null) { allContexts = new ArrayList(); allContexts.add(mainContext); } allContexts.add(newContext); } initContext = newContext; initContextThread = Thread.currentThread(); initContext = null; initContextThread = null; if (wasEmpty) { timer.start(); } return newContext; }
public long getTimeMicros() { return timer.getTimeMicros(); }
public long getTimeMillis() { return timer.getTimeMillis(); }