Skip to content

Commit

Permalink
Redraw on surfaceChanged to prevent visual jumps.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jules Kerssemakers committed Jan 9, 2024
1 parent 216017b commit 2c36a29
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/src/main/java/com/nicobrailo/pianoli/PianoCanvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -393,12 +393,16 @@ public boolean onTouchEvent(MotionEvent event) {


@Override
public void surfaceChanged(@NonNull SurfaceHolder surfaceHolder, int i, int i1, int i2) {
Log.i("PianOli::PianoCanvas", "surfaceChanged: ignoring!");
public void surfaceChanged(@NonNull SurfaceHolder surfaceHolder, int format, int newWidth, int newHeight) {
Log.i("PianOli::DrawingCanvas", "surfaceChanged: new dimensions: " +
"w="+newWidth +
" h="+newHeight);
redraw(surfaceHolder);
}

@Override
public void surfaceDestroyed(@NonNull SurfaceHolder surfaceHolder) {
Log.i("PianOli::PianoCanvas", "surfaceDestroyed: ignoring!");
// no cleanup needed. we only use very simple drawing primitives, so there's nothing (graphical) to release.
}
}

0 comments on commit 2c36a29

Please sign in to comment.