use of android.support.annotation.DrawableRes in project glide by bumptech.
the class ResourceDrawableDecoder method decode.
@Nullable
@Override
public Resource<Drawable> decode(@NonNull Uri source, int width, int height, @NonNull Options options) {
@DrawableRes int resId = loadResourceIdFromUri(source);
String packageName = source.getAuthority();
Context targetContext = packageName.equals(context.getPackageName()) ? context : getContextForPackage(source, packageName);
// We can't get a theme from another application.
Drawable drawable = DrawableDecoderCompat.getDrawable(context, targetContext, resId);
return NonOwnedDrawableResource.newInstance(drawable);
}
use of android.support.annotation.DrawableRes in project edx-app-android by edx.
the class WhatsNewItemFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
final Bundle args = getArguments();
final WhatsNewItemModel model = args.getParcelable(ARG_MODEL);
binding.title.setText(escapePlatformName(model.getTitle()));
binding.message.setText(escapePlatformName(model.getMessage()));
@DrawableRes final int imageRes = UiUtil.getDrawable(getContext(), model.getImage());
binding.image.setImageResource(imageRes);
// We need different scale types for portrait and landscape images
final Drawable drawable = UiUtil.getDrawable(getContext(), imageRes);
if (drawable != null) {
if (drawable.getIntrinsicHeight() > drawable.getIntrinsicWidth()) {
binding.image.setScaleType(ImageView.ScaleType.FIT_END);
} else {
binding.image.setScaleType(ImageView.ScaleType.FIT_CENTER);
}
}
}
Aggregations