Search in sources :

Example 1 with RoundedBitmapDrawable

use of android.support.v4.graphics.drawable.RoundedBitmapDrawable in project android-topeka by googlesamples.

the class AvatarView method setAvatarPreLollipop.

private void setAvatarPreLollipop(@DrawableRes int resId) {
    Drawable drawable = ResourcesCompat.getDrawable(getResources(), resId, getContext().getTheme());
    BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
    @SuppressWarnings("ConstantConditions") RoundedBitmapDrawable roundedDrawable = RoundedBitmapDrawableFactory.create(getResources(), bitmapDrawable.getBitmap());
    roundedDrawable.setCircular(true);
    setImageDrawable(roundedDrawable);
}
Also used : RoundedBitmapDrawable(android.support.v4.graphics.drawable.RoundedBitmapDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Drawable(android.graphics.drawable.Drawable) RoundedBitmapDrawable(android.support.v4.graphics.drawable.RoundedBitmapDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) RoundedBitmapDrawable(android.support.v4.graphics.drawable.RoundedBitmapDrawable)

Example 2 with RoundedBitmapDrawable

use of android.support.v4.graphics.drawable.RoundedBitmapDrawable in project android_packages_apps_Dialer by LineageOS.

the class IconFactory method createCircularDrawable.

@NonNull
private Drawable createCircularDrawable(@NonNull Bitmap bitmap) {
    RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(context.getResources(), bitmap);
    roundedBitmapDrawable.setCircular(true);
    roundedBitmapDrawable.setAntiAlias(true);
    return roundedBitmapDrawable;
}
Also used : RoundedBitmapDrawable(android.support.v4.graphics.drawable.RoundedBitmapDrawable) NonNull(android.support.annotation.NonNull)

Example 3 with RoundedBitmapDrawable

use of android.support.v4.graphics.drawable.RoundedBitmapDrawable in project android_packages_apps_Dialer by LineageOS.

the class ContactPhotoManagerImpl method getDrawableForBitmap.

/**
 * Given a bitmap, returns a drawable that is configured to display the bitmap based on the
 * specified request.
 */
private Drawable getDrawableForBitmap(Resources resources, Bitmap bitmap, Request request) {
    if (request.mIsCircular) {
        final RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(resources, bitmap);
        drawable.setAntiAlias(true);
        drawable.setCornerRadius(bitmap.getHeight() / 2);
        return drawable;
    } else {
        return new BitmapDrawable(resources, bitmap);
    }
}
Also used : RoundedBitmapDrawable(android.support.v4.graphics.drawable.RoundedBitmapDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) RoundedBitmapDrawable(android.support.v4.graphics.drawable.RoundedBitmapDrawable)

Example 4 with RoundedBitmapDrawable

use of android.support.v4.graphics.drawable.RoundedBitmapDrawable in project gh4a by slapperwan.

the class AvatarHandler method applyAvatarToView.

private static void applyAvatarToView(ViewDelegate view, Bitmap avatar) {
    Resources res = view.getContext().getResources();
    RoundedBitmapDrawable d = RoundedBitmapDrawableFactory.create(res, avatar);
    d.setCornerRadius(Math.max(avatar.getWidth() / 2, avatar.getHeight() / 2));
    d.setAntiAlias(true);
    Drawable old = view.getDrawable();
    if (old instanceof DefaultAvatarDrawable) {
        TransitionDrawable transition = new TransitionDrawable(new Drawable[] { old, d });
        transition.setCrossFadeEnabled(true);
        transition.startTransition(res.getInteger(android.R.integer.config_shortAnimTime));
        view.setDrawable(transition);
    } else {
        view.setDrawable(d);
    }
}
Also used : RoundedBitmapDrawable(android.support.v4.graphics.drawable.RoundedBitmapDrawable) TransitionDrawable(android.graphics.drawable.TransitionDrawable) Drawable(android.graphics.drawable.Drawable) TransitionDrawable(android.graphics.drawable.TransitionDrawable) RoundedBitmapDrawable(android.support.v4.graphics.drawable.RoundedBitmapDrawable) Resources(android.content.res.Resources)

Example 5 with RoundedBitmapDrawable

use of android.support.v4.graphics.drawable.RoundedBitmapDrawable in project RoMote by wseemann.

the class DeviceAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder = null;
    LayoutInflater mInflater = (LayoutInflater) mContext.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.device, null);
        holder = new ViewHolder();
        holder.mIcon = (ImageView) convertView.findViewById(android.R.id.icon);
        holder.mText1 = (TextView) convertView.findViewById(android.R.id.text1);
        holder.mText2 = (TextView) convertView.findViewById(android.R.id.text2);
        holder.mText3 = (TextView) convertView.findViewById(R.id.text3);
        holder.mImageButton = (ImageView) convertView.findViewById(R.id.overflow_button);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }
    final Device device = (Device) getItem(position);
    Device connectedDevice = null;
    try {
        connectedDevice = PreferenceUtils.getConnectedDevice(mContext);
    } catch (Exception ex) {
    }
    Resources res = parent.getContext().getResources();
    Bitmap image = Bitmap.createBitmap(70, 70, Bitmap.Config.ARGB_8888);
    if (connectedDevice != null && device.getSerialNumber().equals(connectedDevice.getSerialNumber())) {
        image.eraseColor(res.getColor(R.color.purple));
    } else {
        image.eraseColor(res.getColor(R.color.semi_transparent));
    }
    RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(res, image);
    roundedBitmapDrawable.setCornerRadius(Math.max(image.getWidth(), image.getHeight()) / 2.0f);
    holder.mIcon.setImageDrawable(roundedBitmapDrawable);
    // device.getUserDeviceName());
    holder.mText1.setText(device.getModelName());
    holder.mText2.setText("SN: " + device.getSerialNumber());
    if (connectedDevice != null && device.getSerialNumber().equals(connectedDevice.getSerialNumber())) {
        holder.mText3.setText(R.string.connected);
    } else {
        holder.mText3.setText(R.string.not_connected);
    }
    holder.mImageButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Message message = mHandler.obtainMessage();
            v.setTag(device);
            message.obj = v;
            mHandler.sendMessage(message);
        }
    });
    return convertView;
}
Also used : RoundedBitmapDrawable(android.support.v4.graphics.drawable.RoundedBitmapDrawable) Bitmap(android.graphics.Bitmap) Message(android.os.Message) Device(com.jaku.model.Device) LayoutInflater(android.view.LayoutInflater) Resources(android.content.res.Resources) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

RoundedBitmapDrawable (android.support.v4.graphics.drawable.RoundedBitmapDrawable)30 Bitmap (android.graphics.Bitmap)14 View (android.view.View)5 ImageView (android.widget.ImageView)5 TextView (android.widget.TextView)5 Resources (android.content.res.Resources)4 BitmapDrawable (android.graphics.drawable.BitmapDrawable)4 Drawable (android.graphics.drawable.Drawable)4 NonNull (android.support.annotation.NonNull)3 Nullable (android.support.annotation.Nullable)3 RecyclerView (android.support.v7.widget.RecyclerView)3 IOException (java.io.IOException)3 Uri (android.net.Uri)2 SpannableStringBuilder (android.text.SpannableStringBuilder)2 LayoutInflater (android.view.LayoutInflater)2 GlideAnimation (com.bumptech.glide.request.animation.GlideAnimation)2 BitmapImageViewTarget (com.bumptech.glide.request.target.BitmapImageViewTarget)2 NotificationManager (android.app.NotificationManager)1 PendingIntent (android.app.PendingIntent)1 Context (android.content.Context)1