OSDN Git Service

[fixed] some changes to AndroidGraphics.destroy(). Also fixed order of applistener...
authorbadlogicgames <badlogicgames@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Wed, 1 Dec 2010 23:17:24 +0000 (23:17 +0000)
committerbadlogicgames <badlogicgames@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Wed, 1 Dec 2010 23:17:24 +0000 (23:17 +0000)
backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/AndroidGraphics.java

index acafe85..cf5b070 100644 (file)
@@ -313,21 +313,17 @@ public final class AndroidGraphics implements Graphics, Renderer {
 \r
        void resume() {\r
                synchronized (synch) {\r
-                       running = false;\r
+                       running = true;\r
                        resume = true;\r
                }\r
        }\r
 \r
        void pause() {\r
-               long startTime = System.nanoTime();\r
                synchronized (synch) {\r
                        running = false;\r
                        pause = true;\r
                }\r
-               Gdx.app.log("AndroidGraphics", "synch took: " + (System.nanoTime()-startTime)/1000000000.0f);\r
-               startTime = System.nanoTime();\r
                while (pause); // busy wait. ya, nasty...               \r
-               Gdx.app.log("AndroidGraphics", "wait took: " + (System.nanoTime()-startTime)/1000000000.0f);\r
        }\r
 \r
        void destroy() {\r
@@ -335,12 +331,7 @@ public final class AndroidGraphics implements Graphics, Renderer {
                        running = false;\r
                        destroy = true;\r
                }\r
-               boolean cond = false;\r
-               while (!cond) {\r
-                       synchronized (synch) {\r
-                               cond = !destroy;\r
-                       }\r
-               }\r
+               while (destroy);\r
        }\r
 \r
        @Override\r
@@ -361,35 +352,37 @@ public final class AndroidGraphics implements Graphics, Renderer {
                        ldestroy = destroy;\r
                        lresume = resume;\r
                        \r
+                       if (resume) {                           \r
+                               resume = false;\r
+                       }\r
+                       \r
                        if (pause) {                    \r
                                pause = false;                  \r
                        }\r
                        \r
                        if (destroy) {                          \r
                                destroy = false;\r
-                       }\r
-\r
-                       if (resume) {                           \r
-                               resume = false;\r
-                               running = true;\r
-                       }               \r
+                       }                       \r
+               }\r
+               \r
+               if (lresume) {\r
+                       app.listener.resume();\r
+                       Gdx.app.log("AndroidGraphics", "resumed");\r
                }\r
-                               \r
+               \r
                if (lrunning) {\r
                        ((AndroidInput)Gdx.input).processEvents();\r
                        app.listener.render();\r
                }\r
 \r
-               if (lpause) {\r
+               if (lpause) {                   \r
                        app.listener.pause();\r
-               }\r
-\r
-               if (lresume) {\r
-                       app.listener.resume();\r
+                       Gdx.app.log("AndroidGraphics", "paused");\r
                }\r
 \r
                if (ldestroy) {\r
                        app.listener.dispose();\r
+                       Gdx.app.log("AndroidGraphics", "destroyed");\r
                }               \r
                \r
                if (time - frameStart > 1000000000) {\r