Search in sources :

Example 26 with DrawableRes

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);
}
Also used : Context(android.content.Context) DrawableRes(android.support.annotation.DrawableRes) Drawable(android.graphics.drawable.Drawable) Nullable(android.support.annotation.Nullable)

Example 27 with DrawableRes

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);
        }
    }
}
Also used : DrawableRes(android.support.annotation.DrawableRes) Bundle(android.os.Bundle) Drawable(android.graphics.drawable.Drawable)

Aggregations

DrawableRes (android.support.annotation.DrawableRes)27 Context (android.content.Context)8 XmlResourceParser (android.content.res.XmlResourceParser)7 VisibleForTesting (android.support.annotation.VisibleForTesting)6 AttributeSet (android.util.AttributeSet)6 PreferenceControllerMixin (com.android.settings.core.PreferenceControllerMixin)6 IOException (java.io.IOException)6 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)6 Drawable (android.graphics.drawable.Drawable)5 View (android.view.View)5 Intent (android.content.Intent)4 TextView (android.widget.TextView)4 TypedArray (android.content.res.TypedArray)3 ColorInt (android.support.annotation.ColorInt)3 ImageView (android.widget.ImageView)3 Assignment (com.instructure.canvasapi2.models.Assignment)3 Assignment.submissionTypeToAPIString (com.instructure.canvasapi2.models.Assignment.submissionTypeToAPIString)3 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 NotificationManager (android.app.NotificationManager)2