That fuck shit the fascists are using
at master 82 lines 1.8 kB view raw
1package org.tm.archive.ringrtc; 2 3import android.os.Parcel; 4import android.os.Parcelable; 5 6import androidx.annotation.NonNull; 7 8public class CameraState implements Parcelable { 9 10 public static final CameraState UNKNOWN = new CameraState(Direction.NONE, 0); 11 12 private final Direction activeDirection; 13 private final int cameraCount; 14 15 public CameraState(@NonNull Direction activeDirection, int cameraCount) { 16 this.activeDirection = activeDirection; 17 this.cameraCount = cameraCount; 18 } 19 20 private CameraState(Parcel in) { 21 this(Direction.valueOf(in.readString()), in.readInt()); 22 } 23 24 public int getCameraCount() { 25 return cameraCount; 26 } 27 28 public Direction getActiveDirection() { 29 return activeDirection; 30 } 31 32 public boolean isEnabled() { 33 return this.activeDirection != Direction.NONE; 34 } 35 36 @Override 37 public String toString() { 38 return "count: " + cameraCount + ", activeDirection: " + activeDirection; 39 } 40 41 @Override 42 public void writeToParcel(Parcel dest, int flags) { 43 dest.writeString(activeDirection.name()); 44 dest.writeInt(cameraCount); 45 } 46 47 @Override 48 public int describeContents() { 49 return 0; 50 } 51 52 public enum Direction { 53 FRONT, BACK, NONE, PENDING; 54 55 public boolean isUsable() { 56 return this == FRONT || this == BACK; 57 } 58 59 public Direction switchDirection() { 60 switch (this) { 61 case FRONT: 62 return BACK; 63 case BACK: 64 return FRONT; 65 default: 66 return this; 67 } 68 } 69 } 70 71 public static final Creator<CameraState> CREATOR = new Creator<CameraState>() { 72 @Override 73 public CameraState createFromParcel(Parcel in) { 74 return new CameraState(in); 75 } 76 77 @Override 78 public CameraState[] newArray(int size) { 79 return new CameraState[size]; 80 } 81 }; 82}