File tree Expand file tree Collapse file tree 2 files changed +19
-11
lines changed
Expand file tree Collapse file tree 2 files changed +19
-11
lines changed Original file line number Diff line number Diff line change @@ -785,8 +785,11 @@ public void onPermissionsGranted() {
785785 // TODO this is only used by A2D, when finishing up a draw. but if the
786786 // surfaceview has changed, then it might belong to an a3d surfaceview. hrm.
787787 public SurfaceHolder getSurfaceHolder () {
788- return surfaceView .getHolder ();
789- // return surfaceHolder;
788+ if (surfaceView != null ) {
789+ return surfaceView .getHolder ();
790+ } else {
791+ return null ;
792+ }
790793 }
791794
792795
Original file line number Diff line number Diff line change 3333import android .graphics .*;
3434import android .graphics .Bitmap .Config ;
3535import android .graphics .Paint .Style ;
36+ import android .view .SurfaceHolder ;
3637
3738
3839/**
@@ -208,17 +209,21 @@ public void endDraw() {
208209// }
209210
210211 if (primaryGraphics ) {
211- Canvas screen = null ;
212- try {
213- screen = parent .getSurfaceHolder ().lockCanvas (null );
214- if (screen != null ) {
215- screen .drawBitmap (bitmap , new Matrix (), null );
216- }
217- } finally {
218- if (screen != null ) {
219- parent .getSurfaceHolder ().unlockCanvasAndPost (screen );
212+ SurfaceHolder holder = parent .getSurfaceHolder ();
213+ if (holder != null ) {
214+ Canvas screen = null ;
215+ try {
216+ screen = holder .lockCanvas (null );
217+ if (screen != null ) {
218+ screen .drawBitmap (bitmap , new Matrix (), null );
219+ }
220+ } finally {
221+ if (screen != null ) {
222+ holder .unlockCanvasAndPost (screen );
223+ }
220224 }
221225 }
226+
222227 } else {
223228 // TODO this is probably overkill for most tasks...
224229 loadPixels ();
You can’t perform that action at this time.
0 commit comments