Skip to content

Commit 9f15853

Browse files
committed
don't call pause/resume twice, fix #334
1 parent 21009f6 commit 9f15853

File tree

1 file changed

+4
-46
lines changed

1 file changed

+4
-46
lines changed

core/src/processing/core/PApplet.java

Lines changed: 4 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,10 @@ public void onResume() {
535535
// Don't call resume() when the app is starting and setup() has not been
536536
// called yet
537537
// https://github.com/processing/processing-android/issues/274
538+
539+
// Also, no need to call resume() from anywhere else (for example, from
540+
// onStart) since onResume() is always called in the activity lifecyle:
541+
// https://developer.android.com/guide/components/activities/activity-lifecycle.html
538542
resume();
539543
}
540544
}
@@ -698,7 +702,6 @@ public int sketchSmooth() {
698702

699703

700704
final public boolean sketchFullScreen() {
701-
//return false;
702705
return fullScreen;
703706
}
704707

@@ -731,10 +734,6 @@ final public int sketchPixelDensity() {
731734
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
732735

733736

734-
// public interface SketchSurfaceView {
735-
// public PGraphics getGraphics();
736-
// }
737-
738737
public void surfaceChanged() {
739738
surfaceChanged = true;
740739
}
@@ -762,24 +761,18 @@ public void surfaceWindowFocusChanged(boolean hasFocus) {
762761
* then motionX, motionY, motionPressed, and motionEvent will not be set.
763762
*/
764763
public boolean surfaceTouchEvent(MotionEvent event) {
765-
// println(event);
766764
nativeMotionEvent(event);
767-
// return super.onTouchEvent(event);
768765
return true;
769766
}
770767

771768

772769
public void surfaceKeyDown(int code, android.view.KeyEvent event) {
773-
// System.out.println("got onKeyDown for " + code + " " + event);
774770
nativeKeyEvent(event);
775-
// return super.onKeyDown(code, event);
776771
}
777772

778773

779774
public void surfaceKeyUp(int code, android.view.KeyEvent event) {
780-
// System.out.println("got onKeyUp for " + code + " " + event);
781775
nativeKeyEvent(event);
782-
// return super.onKeyUp(code, event);
783776
}
784777

785778

@@ -795,7 +788,6 @@ public void surfaceKeyUp(int code, android.view.KeyEvent event) {
795788
* PAppletGL needs to have a usable screen before getting things rolling.
796789
*/
797790
public void start() {
798-
resume();
799791
surface.resumeThread();
800792
}
801793

@@ -811,7 +803,6 @@ public void start() {
811803
public void stop() {
812804
// this used to shut down the sketch, but that code has
813805
// been moved to dispose()
814-
pause();
815806
surface.pauseThread();
816807

817808
//TODO listeners
@@ -833,39 +824,6 @@ public void pause() {
833824
public void resume() {
834825
}
835826

836-
/**
837-
* Called by the browser or applet viewer to inform this applet
838-
* that it is being reclaimed and that it should destroy
839-
* any resources that it has allocated.
840-
* <p/>
841-
* This also attempts to call PApplet.stop(), in case there
842-
* was an inadvertent override of the stop() function by a user.
843-
* <p/>
844-
* destroy() supposedly gets called as the applet viewer
845-
* is shutting down the applet. stop() is called
846-
* first, and then destroy() to really get rid of things.
847-
* no guarantees on when they're run (on browser quit, or
848-
* when moving between pages), though.
849-
*/
850-
// public void destroy() {
851-
// ((PApplet)this).exit();
852-
// }
853-
854-
855-
/**
856-
* This returns the last width and height specified by the user
857-
* via the size() command.
858-
*/
859-
// public Dimension getPreferredSize() {
860-
// return new Dimension(width, height);
861-
// }
862-
863-
864-
// public void addNotify() {
865-
// super.addNotify();
866-
// println("addNotify()");
867-
// }
868-
869827

870828
//////////////////////////////////////////////////////////////
871829

0 commit comments

Comments
 (0)