@@ -349,14 +349,18 @@ public RequestBuilder<TranscodeType> clone() {
349
349
* @see RequestManager#clear(Target)
350
350
*/
351
351
public <Y extends Target <TranscodeType >> Y into (@ NonNull Y target ) {
352
+ return into (target , getMutableOptions ());
353
+ }
354
+
355
+ private <Y extends Target <TranscodeType >> Y into (@ NonNull Y target , RequestOptions options ) {
352
356
Util .assertMainThread ();
353
357
Preconditions .checkNotNull (target );
354
358
if (!isModelSet ) {
355
359
throw new IllegalArgumentException ("You must call #load() before calling #into()" );
356
360
}
357
361
358
- requestOptions . lock ();
359
- Request request = buildRequest (target );
362
+ options = options . autoClone ();
363
+ Request request = buildRequest (target , options );
360
364
361
365
Request previous = target .getRequest ();
362
366
if (request .isEquivalentTo (previous )) {
@@ -378,6 +382,7 @@ public <Y extends Target<TranscodeType>> Y into(@NonNull Y target) {
378
382
return target ;
379
383
}
380
384
385
+
381
386
/**
382
387
* Sets the {@link ImageView} the resource will be loaded into, cancels any existing loads into
383
388
* the view, and frees any resources Glide may have previously loaded into the view so they may be
@@ -393,26 +398,27 @@ public Target<TranscodeType> into(ImageView view) {
393
398
Util .assertMainThread ();
394
399
Preconditions .checkNotNull (view );
395
400
401
+ RequestOptions requestOptions = this .requestOptions ;
396
402
if (!requestOptions .isTransformationSet ()
397
403
&& requestOptions .isTransformationAllowed ()
398
404
&& view .getScaleType () != null ) {
399
- if ( requestOptions . isLocked ()) {
400
- requestOptions = requestOptions . clone ();
401
- }
405
+ // Clone in this method so that if we use this RequestBuilder to load into a View and then
406
+ // into a different target, we don't retain the transformation applied based on the previous
407
+ // View's scale type.
402
408
switch (view .getScaleType ()) {
403
409
case CENTER_CROP :
404
- requestOptions .optionalCenterCrop ();
410
+ requestOptions .clone (). optionalCenterCrop ();
405
411
break ;
406
412
case CENTER_INSIDE :
407
- requestOptions .optionalCenterInside ();
413
+ requestOptions .clone (). optionalCenterInside ();
408
414
break ;
409
415
case FIT_CENTER :
410
416
case FIT_START :
411
417
case FIT_END :
412
- requestOptions .optionalFitCenter ();
418
+ requestOptions .clone (). optionalFitCenter ();
413
419
break ;
414
420
case FIT_XY :
415
- requestOptions .optionalCenterInside ();
421
+ requestOptions .clone (). optionalCenterInside ();
416
422
break ;
417
423
case CENTER :
418
424
case MATRIX :
@@ -421,7 +427,7 @@ public Target<TranscodeType> into(ImageView view) {
421
427
}
422
428
}
423
429
424
- return into (context .buildImageViewTarget (view , transcodeClass ));
430
+ return into (context .buildImageViewTarget (view , transcodeClass ), requestOptions );
425
431
}
426
432
427
433
/**
@@ -578,15 +584,15 @@ private Priority getThumbnailPriority(Priority current) {
578
584
}
579
585
}
580
586
581
- private Request buildRequest (Target <TranscodeType > target ) {
587
+ private Request buildRequest (Target <TranscodeType > target , RequestOptions requestOptions ) {
582
588
return buildRequestRecursive (target , null , transitionOptions , requestOptions .getPriority (),
583
- requestOptions .getOverrideWidth (), requestOptions .getOverrideHeight ());
589
+ requestOptions .getOverrideWidth (), requestOptions .getOverrideHeight (), requestOptions );
584
590
}
585
591
586
592
private Request buildRequestRecursive (Target <TranscodeType > target ,
587
593
@ Nullable ThumbnailRequestCoordinator parentCoordinator ,
588
594
TransitionOptions <?, ? super TranscodeType > transitionOptions ,
589
- Priority priority , int overrideWidth , int overrideHeight ) {
595
+ Priority priority , int overrideWidth , int overrideHeight , RequestOptions requestOptions ) {
590
596
if (thumbnailBuilder != null ) {
591
597
// Recursive case: contains a potentially recursive thumbnail request builder.
592
598
if (isThumbnailBuilt ) {
@@ -619,8 +625,15 @@ private Request buildRequestRecursive(Target<TranscodeType> target,
619
625
transitionOptions , priority , overrideWidth , overrideHeight );
620
626
isThumbnailBuilt = true ;
621
627
// Recursively generate thumbnail requests.
622
- Request thumbRequest = thumbnailBuilder .buildRequestRecursive (target , coordinator ,
623
- thumbTransitionOptions , thumbPriority , thumbOverrideWidth , thumbOverrideHeight );
628
+ Request thumbRequest =
629
+ thumbnailBuilder .buildRequestRecursive (
630
+ target ,
631
+ coordinator ,
632
+ thumbTransitionOptions ,
633
+ thumbPriority ,
634
+ thumbOverrideWidth ,
635
+ thumbOverrideHeight ,
636
+ requestOptions );
624
637
isThumbnailBuilt = false ;
625
638
coordinator .setRequests (fullRequest , thumbRequest );
626
639
return coordinator ;
@@ -648,8 +661,6 @@ private Request obtainRequest(Target<TranscodeType> target,
648
661
RequestOptions requestOptions , RequestCoordinator requestCoordinator ,
649
662
TransitionOptions <?, ? super TranscodeType > transitionOptions , Priority priority ,
650
663
int overrideWidth , int overrideHeight ) {
651
- requestOptions .lock ();
652
-
653
664
return SingleRequest .obtain (
654
665
context ,
655
666
model ,
0 commit comments