Skip to content

Commit 71bab6a

Browse files
committed
state restore
1 parent 92cbdc2 commit 71bab6a

File tree

4 files changed

+30
-16
lines changed

4 files changed

+30
-16
lines changed

core/src/processing/android/PWatchFaceCanvas.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,16 @@ public void onVisibilityChanged(boolean visible) {
190190
}
191191
}
192192

193+
@Override
194+
public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height) {
195+
super.onSurfaceChanged(holder, format, width, height);
196+
if (sketch != null) {
197+
sketch.displayWidth = width;
198+
sketch.displayHeight = height;
199+
sketch.g.setSize(sketch.sketchWidth(), sketch.sketchHeight());
200+
sketch.surfaceChanged();
201+
}
202+
}
193203

194204
@Override
195205
public void onPeekCardPositionUpdate(Rect rect) {

core/src/processing/core/PApplet.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -582,9 +582,8 @@ public void onResume() {
582582

583583
// TODO need to bring back app state here!
584584
// At least we restore the current style.
585-
if (savedStyle != null) {
585+
if (savedStyle != null && g != null) {
586586
g.style(savedStyle);
587-
savedStyle = null;
588587
}
589588

590589
handleMethods("resume");
@@ -597,8 +596,10 @@ public void onResume() {
597596
public void onPause() {
598597
// TODO need to save all application state here!
599598
// At least we save the current style.
600-
savedStyle = new PStyle();
601-
g.getStyle(savedStyle);
599+
if (g != null) {
600+
savedStyle = new PStyle();
601+
g.getStyle(savedStyle);
602+
}
602603

603604
handleMethods("pause");
604605

@@ -698,6 +699,9 @@ public SurfaceView getSurfaceView() {
698699

699700
public void surfaceChanged() {
700701
surfaceChanged = true;
702+
if (savedStyle != null && g != null) {
703+
g.style(savedStyle);
704+
}
701705
}
702706

703707

core/src/processing/core/PGraphicsAndroid2D.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,16 @@ public PGraphicsAndroid2D() {
128128
*
129129
* Note that this will nuke any cameraMode() settings.
130130
*/
131-
@Override
132-
public void setSize(int iwidth, int iheight) { // ignore
133-
width = iwidth;
134-
height = iheight;
135-
width1 = width - 1;
136-
height1 = height - 1;
137-
138-
allocate();
139-
reapplySettings();
140-
}
131+
// @Override
132+
// public void setSize(int iwidth, int iheight) { // ignore
133+
// width = iwidth;
134+
// height = iheight;
135+
// width1 = width - 1;
136+
// height1 = height - 1;
137+
//
138+
// allocate();
139+
// reapplySettings();
140+
// }
141141

142142

143143
@Override

core/src/processing/opengl/PGraphicsOpenGL.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,8 +590,8 @@ public void setPrimary(boolean primary) {
590590

591591
@Override
592592
public void setSize(int iwidth, int iheight) {
593-
width = iwidth;
594-
height = iheight;
593+
super.setSize(iwidth, iheight);
594+
595595
updatePixelSize();
596596

597597
// init perspective projection based on new dimensions

0 commit comments

Comments
 (0)