I'm using the CameraDemo app included with cwac-camera. I'm trying to make the zoom bar change from the main activity using a method updateZoom() but I'm getting a nullpointerexception sometimes from the zoomTo return. Most of the time the zoom will work but then occasionally the program will crash.
Updated zoom:
public void updateZoom()
{
zoom.setEnabled(false);
current.zoomTo(zoom.getProgress()).onComplete(new Runnable() {
@Override
public void run() {
zoom.setEnabled(true);
}
}).go();
}
Call to updateZoom():
zoom.incrementProgressBy(20);
updateZoom();
Error Logs:
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)
您呼叫updateZoom()
在一个点时, CameraFragment
没有CameraView
,所以你得到一个NullPointerException
时CameraFragment
试图传递zoomTo()
调用一起到CameraView
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.