mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
Fix NPE when camera is not in ready state
Fixes #3567 Closes #3570 // FREEBIE
This commit is contained in:
parent
5fdd5cad4e
commit
d6d881b0ca
@ -22,6 +22,7 @@ import android.content.pm.ActivityInfo;
|
||||
import android.hardware.Camera;
|
||||
import android.hardware.Camera.PreviewCallback;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
@ -240,8 +241,8 @@ public class CameraView extends FrameLayout {
|
||||
if (camera != null) camera.setOneShotPreviewCallback(callback);
|
||||
}
|
||||
|
||||
public Camera.Parameters getCameraParameters() {
|
||||
return camera.getParameters();
|
||||
public @Nullable Camera.Parameters getCameraParameters() {
|
||||
return camera == null || !cameraReady ? null : camera.getParameters();
|
||||
}
|
||||
|
||||
void previewCreated() {
|
||||
|
@ -70,6 +70,11 @@ import java.util.List;
|
||||
}
|
||||
|
||||
final Parameters cameraParameters = getCameraParameters();
|
||||
if (cameraParameters == null) {
|
||||
Log.w(TAG, "camera not in capture-ready state");
|
||||
return;
|
||||
}
|
||||
|
||||
setOneShotPreviewCallback(new Camera.PreviewCallback() {
|
||||
@Override
|
||||
public void onPreviewFrame(byte[] data, final Camera camera) {
|
||||
|
Loading…
Reference in New Issue
Block a user