Created
July 4, 2021 09:11
-
-
Save PhongHuynh93/5635bce7e687a021ba95927169109ba0 to your computer and use it in GitHub Desktop.
glide
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@NonNull | |
public ViewTarget<ImageView, TranscodeType> into(@NonNull ImageView view) { | |
Util.assertMainThread(); | |
Preconditions.checkNotNull(view); | |
BaseRequestOptions<?> requestOptions = this; | |
if (!requestOptions.isTransformationSet() | |
&& requestOptions.isTransformationAllowed() | |
&& view.getScaleType() != null) { | |
// Clone in this method so that if we use this RequestBuilder to load into a View and then | |
// into a different target, we don't retain the transformation applied based on the previous | |
// View's scale type. | |
switch (view.getScaleType()) { | |
case CENTER_CROP: | |
requestOptions = requestOptions.clone().optionalCenterCrop(); | |
break; | |
case CENTER_INSIDE: | |
requestOptions = requestOptions.clone().optionalCenterInside(); | |
break; | |
case FIT_CENTER: | |
case FIT_START: | |
case FIT_END: | |
requestOptions = requestOptions.clone().optionalFitCenter(); | |
break; | |
case FIT_XY: | |
requestOptions = requestOptions.clone().optionalCenterInside(); | |
break; | |
case CENTER: | |
case MATRIX: | |
default: | |
// Do nothing. | |
} | |
} | |
return into( | |
glideContext.buildImageViewTarget(view, transcodeClass), | |
/*targetListener=*/ null, | |
requestOptions, | |
Executors.mainThreadExecutor()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment