cwac-camera崩溃缩放到

时间:2015-03-01 14:50:23

标签: android commonsware-cwac cwac-camera

我正在使用cwac-camera附带的CameraDemo应用程序。我尝试使用方法updateZoom()从主活动中更改缩放栏,但我有时会从zoomTo返回获得nullpointerexception。大多数时候缩放都会起作用,但偶尔程序会崩溃。

更新了缩放:

public void updateZoom()
{
  zoom.setEnabled(false);
   current.zoomTo(zoom.getProgress()).onComplete(new Runnable() {
          @Override
          public void run() {
            zoom.setEnabled(true);
          }
        }).go();
}

调用updateZoom():

zoom.incrementProgressBy(20);
updateZoom();

错误日志:

03-01 09:47:55.763: E/AndroidRuntime(31950): FATAL EXCEPTION: main
03-01 09:47:55.763: E/AndroidRuntime(31950): Process: com.commonsware.cwac.camera.demo, PID: 31950
03-01 09:47:55.763: E/AndroidRuntime(31950): java.lang.NullPointerException
03-01 09:47:55.763: E/AndroidRuntime(31950):    at com.commonsware.cwac.camera.CameraFragment.zoomTo(CameraFragment.java:269)
03-01 09:47:55.763: E/AndroidRuntime(31950):    at com.commonsware.cwac.camera.demo.MainActivity.updateZoom(MainActivity.java:163)
03-01 09:47:55.763: E/AndroidRuntime(31950):    at com.commonsware.cwac.camera.demo.MainActivity$1.onPose(MainActivity.java:116)

1 个答案:

答案 0 :(得分:0)

您在updateZoom()没有CameraFragment的时候致电CameraView,因此当NullPointerException尝试时您获得CameraFragmentzoomTo()来电传递给CameraView