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 androidx.annotation.NonNull;
import androidx.annotation.Nullable;
/**
@ -34,7 +35,7 @@ public enum Audio implements Control {
return value;
}
@Nullable
@NonNull
static Audio fromValue(int value) {
Audio[] list = Audio.values();
for (Audio action : list) {
@ -42,6 +43,6 @@ public enum Audio implements Control {
return action;
}
}
return null;
return DEFAULT;
}
}

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

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

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

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

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

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

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

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

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