66import android .os .Parcelable ;
77
88import java .util .ArrayList ;
9+ import java .util .Arrays ;
910import java .util .List ;
1011
12+ import me .devilsen .czxing .code .BarcodeFormat ;
1113import me .devilsen .czxing .view .ScanActivityDelegate ;
1214
1315/**
@@ -76,6 +78,11 @@ public ScannerManager setScanLineColors(List<Integer> scanLineColors) {
7678 return this ;
7779 }
7880
81+ public ScannerManager setBarcodeFormat (BarcodeFormat ... barcodeFormats ){
82+ scanOption .barcodeFormats = Arrays .asList (barcodeFormats );
83+ return this ;
84+ }
85+
7986 public ScannerManager setOnScanResultDelegate (ScanActivityDelegate .OnScanDelegate delegate ) {
8087 ScanActivityDelegate .getInstance ().setScanResultDelegate (delegate );
8188 return this ;
@@ -105,6 +112,7 @@ public static class ScanOption implements Parcelable {
105112 private String flashLightOffText ;
106113 private String scanNoticeText ;
107114
115+ private List <BarcodeFormat > barcodeFormats ;
108116 private List <Integer > scanLineColors ;
109117
110118 public int getCornerColor () {
@@ -147,6 +155,10 @@ public List<Integer> getScanLineColors() {
147155 return scanLineColors ;
148156 }
149157
158+ public BarcodeFormat [] getBarcodeFormat () {
159+ return barcodeFormats .toArray (new BarcodeFormat [0 ]);
160+ }
161+
150162 @ Override
151163 public int describeContents () {
152164 return 0 ;
@@ -163,6 +175,7 @@ public void writeToParcel(Parcel dest, int flags) {
163175 dest .writeString (this .flashLightOnText );
164176 dest .writeString (this .flashLightOffText );
165177 dest .writeString (this .scanNoticeText );
178+ dest .writeList (this .barcodeFormats );
166179 dest .writeList (this .scanLineColors );
167180 }
168181
@@ -179,6 +192,8 @@ protected ScanOption(Parcel in) {
179192 this .flashLightOnText = in .readString ();
180193 this .flashLightOffText = in .readString ();
181194 this .scanNoticeText = in .readString ();
195+ this .barcodeFormats = new ArrayList <>();
196+ in .readList (this .barcodeFormats , BarcodeFormat .class .getClassLoader ());
182197 this .scanLineColors = new ArrayList <>();
183198 in .readList (this .scanLineColors , Integer .class .getClassLoader ());
184199 }
0 commit comments