Skip to content

Commit 6fefe58

Browse files
committed
fix NPE
Signed-off-by: Umair Khan <[email protected]>
1 parent 5c17f5a commit 6fefe58

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/in/omerjerk/processing/video/android/Capture.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@ public class Capture extends PImage implements PConstants {
1414

1515
private static Context context;
1616

17-
private static ArrayList<String> camerasList;
17+
private static ArrayList<String> camerasList = new ArrayList<>();
1818

1919
private static final String KEY_FRONT_CAMERA = "front-camera-%d";
2020
private static final String KEY_BACK_CAMERA = "back-camera-%d";
2121

22+
public Capture (PApplet context) {
23+
Capture.context = context;
24+
}
25+
2226
public static String[] list() {
2327
ensureContext();
2428
if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
@@ -42,10 +46,7 @@ public static String[] list() {
4246

4347
private static void ensureContext() {
4448
if (context == null) {
45-
context = PApplet.getInstance();
46-
if (context == null) {
47-
throw new NullPointerException("null context");
48-
}
49+
throw new RuntimeException("Create the instance of Capture class first.");
4950
}
5051
}
5152
}

0 commit comments

Comments
 (0)