327 | * API levels < KITKAT (19) only allow 1 mime type 328 | * so the remaining types provided are ignored on those devices. 329 | * 330 | * @return This Builder object to allow for chaining of calls. 331 | */ 332 | public Builder setMimeTypes(@Nullable MimeType... mimeTypes) { 333 | if (mimeTypes == null || mimeTypes.length == 0) { 334 | return this; 335 | } 336 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { 337 | this.mimeTypes = new ArrayList<>(); 338 | for (MimeType mimeType : mimeTypes) { 339 | if (!this.mimeTypes.contains(mimeType)) { 340 | this.mimeTypes.add(mimeType); 341 | } 342 | } 343 | } else { 344 | this.mimeTypes = Collections.singletonList(mimeTypes[0]); 345 | } 346 | return this; 347 | } 348 | 349 | /** 350 | * Sets whether multiple items can be selected for a gallery request. 351 | *
352 | * API levels < JELLY_BEAN_MR2 (18) do not support selecting multiple items 353 | * so this value is ignored on those devices. 354 | * 355 | * @return This Builder object to allow for chaining of calls. 356 | */ 357 | public Builder setMultiSelectEnabled(boolean multiSelectEnabled) { 358 | this.multiSelectEnabled = multiSelectEnabled; 359 | return this; 360 | } 361 | 362 | /** 363 | * Sets the Uri to output to for photo requests. 364 | *
365 | * If none is supplied then will output to MediaStore.Images.Media.EXTERNAL_CONTENT_URI, 366 | * which requires WRITE_EXTERNAL_STORAGE permission. 367 | * 368 | * @return This Builder object to allow for chaining of calls. 369 | */ 370 | public Builder setOutputUri(Uri outputUri) { 371 | this.outputUri = outputUri; 372 | return this; 373 | } 374 | 375 | /** 376 | * Creates a Request with the arguments supplied to this builder. 377 | */ 378 | public Request build() { 379 | return new Request(source, mimeTypes, multiSelectEnabled, outputUri); 380 | } 381 | 382 | } 383 | 384 | } 385 | 386 | } 387 | --------------------------------------------------------------------------------