brownemint / Ti-Android-CameraView

MIT License
23 stars 15 forks source link

crush on resume #2

Closed pilosof closed 10 years ago

pilosof commented 10 years ago

[ERROR] : TiApplication: (main) [3,5337] Sending event: exception on thread: main msg:java.lang.NullPointerException; Titanium 3.2.2,2014/03/05 12:22,96e9a07 [ERROR] : TiApplication: java.lang.NullPointerException [ERROR] : TiApplication: at pw.custom.androidcamera.CameraViewProxy$CameraView.surfaceCreated(CameraViewProxy.java:114) [ERROR] : TiApplication: at android.view.SurfaceView.updateWindow(SurfaceView.java:572) [ERROR] : TiApplication: at android.view.SurfaceView.onWindowVisibilityChanged(SurfaceView.java:232) [ERROR] : TiApplication: at android.view.View.dispatchWindowVisibilityChanged(View.java:8123) [ERROR] : TiApplication: at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1077) [ERROR] : TiApplication: at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1077) [ERROR] : TiApplication: at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1077) [ERROR] : TiApplication: at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1077) [ERROR] : TiApplication: at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1077) [ERROR] : TiApplication: at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1077) [ERROR] : TiApplication: at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1077) [ERROR] : TiApplication: at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1077) [ERROR] : TiApplication: at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1077) [ERROR] : TiApplication: at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1077) [ERROR] : TiApplication: at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1344) [ERROR] : TiApplication: at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1103) [ERROR] : TiApplication: at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6018) [ERROR] : TiApplication: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:799) [ERROR] : TiApplication: at android.view.Choreographer.doCallbacks(Choreographer.java:599) [ERROR] : TiApplication: at android.view.Choreographer.doFrame(Choreographer.java:559) [ERROR] : TiApplication: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:784) [ERROR] : TiApplication: at android.os.Handler.handleCallback(Handler.java:733) [ERROR] : TiApplication: at android.os.Handler.dispatchMessage(Handler.java:95) [ERROR] : TiApplication: at android.os.Looper.loop(Looper.java:157) [ERROR] : TiApplication: at android.app.ActivityThread.main(ActivityThread.java:5872) [ERROR] : TiApplication: at java.lang.reflect.Method.invokeNative(Native Method) [ERROR] : TiApplication: at java.lang.reflect.Method.invoke(Method.java:515) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:674) [ERROR] : TiApplication: at dalvik.system.NativeStart.main(Native Method)

brownemint commented 10 years ago

Thanks for making me aware of this. Will fix it asap.

pilosof commented 10 years ago

already fixed :) moved the creation to surfacecreated

public void surfaceCreated(SurfaceHolder previewHolder) {
        try
        {
            this.camera = getCameraInstance();
brownemint commented 10 years ago

Cool. Do you want to create a pull request for that and I'll merge it back into the master

pilosof commented 10 years ago

it's ok, just do it :) also have a look at

https://github.com/pikanji/CameraPreviewSample/blob/master/src/net/pikanji/camerapreviewsample/CameraPreview.java

he does a nice job of adapting the supported camera ratios and changing the surface so the preview is not distorted

brownemint commented 10 years ago

Cool. Thanks for the tip.