From e17bc46865f413de9fc66c0de4c50d0febd47e88 Mon Sep 17 00:00:00 2001 From: benfry Date: Sun, 6 Mar 2011 04:45:33 +0000 Subject: [PATCH] fix NPE problem since registered methods not properly added back --- android/core/src/processing/core/PApplet.java | 12 +++++++++++- android/todo.txt | 10 ++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/android/core/src/processing/core/PApplet.java b/android/core/src/processing/core/PApplet.java index a432c6d3f..97d75f6ae 100644 --- a/android/core/src/processing/core/PApplet.java +++ b/android/core/src/processing/core/PApplet.java @@ -513,6 +513,15 @@ public class PApplet extends Activity implements PConstants, Runnable { redraw = true; // draw this guy once firstMotion = true; + // these need to be inited before setup + sizeMethods = new RegisteredMethods(); + preMethods = new RegisteredMethods(); + drawMethods = new RegisteredMethods(); + postMethods = new RegisteredMethods(); + mouseEventMethods = new RegisteredMethods(); + keyEventMethods = new RegisteredMethods(); + disposeMethods = new RegisteredMethods(); + Context context = getApplicationContext(); sketchPath = context.getFilesDir().getAbsolutePath(); @@ -2494,7 +2503,7 @@ public class PApplet extends Activity implements PConstants, Runnable { * Not to be called or overriden by users. If called multiple times, * will only notify listeners once. Register a dispose listener instead. */ - public void dispose(){ + public void dispose() { // moved here from stop() finished = true; // let the sketch know it is shut down time @@ -2504,6 +2513,7 @@ public class PApplet extends Activity implements PConstants, Runnable { // call to shut down renderer, in case it needs it (pdf does) if (g != null) g.dispose(); + disposeMethods.handle(); } diff --git a/android/todo.txt b/android/todo.txt index 73b34670d..bd839f974 100644 --- a/android/todo.txt +++ b/android/todo.txt @@ -81,6 +81,12 @@ _ sketches must be removed manually if the debug keystore changes _ http://code.google.com/p/processing/issues/detail?id=236 _ register(this, "pause") -> libs will need pause events on android +_ add registered methods again +_ need to figure out generic event queueing first +_ may need a different subset of methods, and introduce new ones +_ that will be usable on both android and desktop +_ dispose() was calling disposeMethods.handle(), but they're null + _ thread is continually running - 'inside handleDraw()' running continually _ inside run() it shouldn't still be going @@ -188,10 +194,6 @@ _ this is currently draining batteries X look into touch event code, see if there's a good way to integrate _ make a decision on how to integrate touch event code -_ add registered methods again -_ need to figure out generic event queueing first -_ may need a different subset of methods, and introduce new ones -_ that will be usable on both android and desktop _ "Unable to resolve target 'Google...'" when APIs aren't installed _ add an error message that explains what to do