Add default to controls

pull/493/head
Mattia Iavarone 5 years ago
parent e38418ae6d
commit 301d5d5dc2
  1. 5
      cameraview/src/main/java/com/otaliastudios/cameraview/controls/Audio.java
  2. 12
      cameraview/src/main/java/com/otaliastudios/cameraview/controls/ControlParser.java
  3. 5
      cameraview/src/main/java/com/otaliastudios/cameraview/controls/Engine.java
  4. 5
      cameraview/src/main/java/com/otaliastudios/cameraview/controls/Flash.java
  5. 5
      cameraview/src/main/java/com/otaliastudios/cameraview/controls/Grid.java
  6. 5
      cameraview/src/main/java/com/otaliastudios/cameraview/controls/Hdr.java
  7. 5
      cameraview/src/main/java/com/otaliastudios/cameraview/controls/Mode.java
  8. 5
      cameraview/src/main/java/com/otaliastudios/cameraview/controls/Preview.java
  9. 5
      cameraview/src/main/java/com/otaliastudios/cameraview/controls/VideoCodec.java
  10. 5
      cameraview/src/main/java/com/otaliastudios/cameraview/controls/WhiteBalance.java

@ -3,6 +3,7 @@ package com.otaliastudios.cameraview.controls;
import com.otaliastudios.cameraview.CameraView; import com.otaliastudios.cameraview.CameraView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
/** /**
@ -34,7 +35,7 @@ public enum Audio implements Control {
return value; return value;
} }
@Nullable @NonNull
static Audio fromValue(int value) { static Audio fromValue(int value) {
Audio[] list = Audio.values(); Audio[] list = Audio.values();
for (Audio action : list) { for (Audio action : list) {
@ -42,6 +43,6 @@ public enum Audio implements Control {
return action; return action;
} }
} }
return null; return DEFAULT;
} }
} }

@ -6,6 +6,7 @@ import android.content.res.TypedArray;
import com.otaliastudios.cameraview.R; import com.otaliastudios.cameraview.R;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
/** /**
* Parses controls from XML attributes. * Parses controls from XML attributes.
@ -36,42 +37,53 @@ public class ControlParser {
this.engine = array.getInteger(R.styleable.CameraView_cameraEngine, Engine.DEFAULT.value()); this.engine = array.getInteger(R.styleable.CameraView_cameraEngine, Engine.DEFAULT.value());
} }
@NonNull
public Preview getPreview() { public Preview getPreview() {
return Preview.fromValue(preview); return Preview.fromValue(preview);
} }
@NonNull
public Facing getFacing() { public Facing getFacing() {
//noinspection ConstantConditions
return Facing.fromValue(facing); return Facing.fromValue(facing);
} }
@NonNull
public Flash getFlash() { public Flash getFlash() {
return Flash.fromValue(flash); return Flash.fromValue(flash);
} }
@NonNull
public Grid getGrid() { public Grid getGrid() {
return Grid.fromValue(grid); return Grid.fromValue(grid);
} }
@NonNull
public Mode getMode() { public Mode getMode() {
return Mode.fromValue(mode); return Mode.fromValue(mode);
} }
@NonNull
public WhiteBalance getWhiteBalance() { public WhiteBalance getWhiteBalance() {
return WhiteBalance.fromValue(whiteBalance); return WhiteBalance.fromValue(whiteBalance);
} }
@NonNull
public Hdr getHdr() { public Hdr getHdr() {
return Hdr.fromValue(hdr); return Hdr.fromValue(hdr);
} }
@NonNull
public Audio getAudio() { public Audio getAudio() {
return Audio.fromValue(audio); return Audio.fromValue(audio);
} }
@NonNull
public VideoCodec getVideoCodec() { public VideoCodec getVideoCodec() {
return VideoCodec.fromValue(videoCodec); return VideoCodec.fromValue(videoCodec);
} }
@NonNull
public Engine getEngine() { public Engine getEngine() {
return Engine.fromValue(engine); return Engine.fromValue(engine);
} }

@ -3,6 +3,7 @@ package com.otaliastudios.cameraview.controls;
import com.otaliastudios.cameraview.CameraView; import com.otaliastudios.cameraview.CameraView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
/** /**
@ -35,7 +36,7 @@ public enum Engine implements Control {
return value; return value;
} }
@Nullable @NonNull
static Engine fromValue(int value) { static Engine fromValue(int value) {
Engine[] list = Engine.values(); Engine[] list = Engine.values();
for (Engine action : list) { for (Engine action : list) {
@ -43,6 +44,6 @@ public enum Engine implements Control {
return action; return action;
} }
} }
return null; return DEFAULT;
} }
} }

@ -4,6 +4,7 @@ package com.otaliastudios.cameraview.controls;
import com.otaliastudios.cameraview.CameraOptions; import com.otaliastudios.cameraview.CameraOptions;
import com.otaliastudios.cameraview.CameraView; import com.otaliastudios.cameraview.CameraView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
/** /**
@ -56,7 +57,7 @@ public enum Flash implements Control {
return value; return value;
} }
@Nullable @NonNull
static Flash fromValue(int value) { static Flash fromValue(int value) {
Flash[] list = Flash.values(); Flash[] list = Flash.values();
for (Flash action : list) { for (Flash action : list) {
@ -64,6 +65,6 @@ public enum Flash implements Control {
return action; return action;
} }
} }
return null; return DEFAULT;
} }
} }

@ -3,6 +3,7 @@ package com.otaliastudios.cameraview.controls;
import com.otaliastudios.cameraview.CameraView; import com.otaliastudios.cameraview.CameraView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
/** /**
@ -46,7 +47,7 @@ public enum Grid implements Control {
return value; return value;
} }
@Nullable @NonNull
static Grid fromValue(int value) { static Grid fromValue(int value) {
Grid[] list = Grid.values(); Grid[] list = Grid.values();
for (Grid action : list) { for (Grid action : list) {
@ -54,6 +55,6 @@ public enum Grid implements Control {
return action; return action;
} }
} }
return null; return DEFAULT;
} }
} }

@ -3,6 +3,7 @@ package com.otaliastudios.cameraview.controls;
import com.otaliastudios.cameraview.CameraView; import com.otaliastudios.cameraview.CameraView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
/** /**
@ -34,7 +35,7 @@ public enum Hdr implements Control {
return value; return value;
} }
@Nullable @NonNull
static Hdr fromValue(int value) { static Hdr fromValue(int value) {
Hdr[] list = Hdr.values(); Hdr[] list = Hdr.values();
for (Hdr action : list) { for (Hdr action : list) {
@ -42,6 +43,6 @@ public enum Hdr implements Control {
return action; return action;
} }
} }
return null; return DEFAULT;
} }
} }

@ -3,6 +3,7 @@ package com.otaliastudios.cameraview.controls;
import com.otaliastudios.cameraview.CameraView; import com.otaliastudios.cameraview.CameraView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import java.io.File; import java.io.File;
@ -46,7 +47,7 @@ public enum Mode implements Control {
return value; return value;
} }
@Nullable @NonNull
static Mode fromValue(int value) { static Mode fromValue(int value) {
Mode[] list = Mode.values(); Mode[] list = Mode.values();
for (Mode action : list) { for (Mode action : list) {
@ -54,6 +55,6 @@ public enum Mode implements Control {
return action; return action;
} }
} }
return null; return DEFAULT;
} }
} }

@ -3,6 +3,7 @@ package com.otaliastudios.cameraview.controls;
import com.otaliastudios.cameraview.CameraView; import com.otaliastudios.cameraview.CameraView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
/** /**
@ -44,7 +45,7 @@ public enum Preview implements Control {
return value; return value;
} }
@Nullable @NonNull
static Preview fromValue(int value) { static Preview fromValue(int value) {
Preview[] list = Preview.values(); Preview[] list = Preview.values();
for (Preview action : list) { for (Preview action : list) {
@ -52,6 +53,6 @@ public enum Preview implements Control {
return action; return action;
} }
} }
return null; return DEFAULT;
} }
} }

@ -3,6 +3,7 @@ package com.otaliastudios.cameraview.controls;
import com.otaliastudios.cameraview.CameraView; import com.otaliastudios.cameraview.CameraView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
/** /**
@ -41,7 +42,7 @@ public enum VideoCodec implements Control {
return value; return value;
} }
@Nullable @NonNull
static VideoCodec fromValue(int value) { static VideoCodec fromValue(int value) {
VideoCodec[] list = VideoCodec.values(); VideoCodec[] list = VideoCodec.values();
for (VideoCodec action : list) { for (VideoCodec action : list) {
@ -49,6 +50,6 @@ public enum VideoCodec implements Control {
return action; return action;
} }
} }
return null; return DEFAULT;
} }
} }

@ -4,6 +4,7 @@ package com.otaliastudios.cameraview.controls;
import com.otaliastudios.cameraview.CameraOptions; import com.otaliastudios.cameraview.CameraOptions;
import com.otaliastudios.cameraview.CameraView; import com.otaliastudios.cameraview.CameraView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
/** /**
@ -65,7 +66,7 @@ public enum WhiteBalance implements Control {
return value; return value;
} }
@Nullable @NonNull
static WhiteBalance fromValue(int value) { static WhiteBalance fromValue(int value) {
WhiteBalance[] list = WhiteBalance.values(); WhiteBalance[] list = WhiteBalance.values();
for (WhiteBalance action : list) { for (WhiteBalance action : list) {
@ -73,6 +74,6 @@ public enum WhiteBalance implements Control {
return action; return action;
} }
} }
return null; return DEFAULT;
} }
} }
Loading…
Cancel
Save