Search in sources :

Example 6 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)

Example 7 with RoundedBitmapDrawable

use of android.support.v4.graphics.drawable.RoundedBitmapDrawable in project cyborg-core by nu-art.

the class RoundedImageView method setRoundedBitmapDrawable.

private void setRoundedBitmapDrawable(Bitmap bitmapSquare) {
    int original_width = bitmapSquare.getWidth();
    int original_height = bitmapSquare.getHeight();
    int square_dimension = Math.min(original_width, original_height);
    if (original_height != original_width) {
        int x = (original_width - square_dimension) / 2;
        int y = (original_height - square_dimension) / 2;
        bitmapSquare = Bitmap.createBitmap(bitmapSquare, x, y, square_dimension, square_dimension);
    }
    RoundedBitmapDrawable roundedImage = RoundedBitmapDrawableFactory.create(getResources(), bitmapSquare);
    roundedImage.setCornerRadius(corners == -1 ? Math.max(original_width, original_height) / 2.0f : corners);
    roundedImage.setAntiAlias(true);
    setImageDrawable(roundedImage);
}
Also used : RoundedBitmapDrawable(android.support.v4.graphics.drawable.RoundedBitmapDrawable)

Example 8 with RoundedBitmapDrawable

use of android.support.v4.graphics.drawable.RoundedBitmapDrawable in project iosched by google.

the class MyIOActivity method showAvatar.

// -- Auth
private void showAvatar() {
    if (mAvatar == null) {
        // Attempt to update avatar image, but avatar view doesn't exist yet
        return;
    }
    mAvatar.setTitle(R.string.description_avatar_signed_in);
    Uri photoUrl = AccountUtils.getActiveAccountPhotoUrl(this);
    if (photoUrl == null) {
        return;
    }
    Glide.with(this).load(photoUrl.toString()).asBitmap().into(new SimpleTarget<Bitmap>(100, 100) {

        @Override
        public void onResourceReady(Bitmap resource, GlideAnimation glideAnimation) {
            if (mAvatar == null) {
                return;
            }
            RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), resource);
            circularBitmapDrawable.setCircular(true);
            mAvatar.setIcon(circularBitmapDrawable);
        }
    });
}
Also used : RoundedBitmapDrawable(android.support.v4.graphics.drawable.RoundedBitmapDrawable) Bitmap(android.graphics.Bitmap) GlideAnimation(com.bumptech.glide.request.animation.GlideAnimation) Uri(android.net.Uri)

Example 9 with RoundedBitmapDrawable

use of android.support.v4.graphics.drawable.RoundedBitmapDrawable in project Onboarding by eoinfogarty.

the class BaseSceneFragment method setSharedImageRadius.

public void setSharedImageRadius(ImageView imageView, float percent) {
    RoundedBitmapDrawable roundedDrawable = ((RoundedBitmapDrawable) imageView.getDrawable());
    float radius = roundedDrawable.getIntrinsicWidth() / 2f;
    roundedDrawable.setCornerRadius(radius * percent);
    imageView.setImageDrawable(roundedDrawable);
    imageView.requestLayout();
}
Also used : RoundedBitmapDrawable(android.support.v4.graphics.drawable.RoundedBitmapDrawable)

Example 10 with RoundedBitmapDrawable

use of android.support.v4.graphics.drawable.RoundedBitmapDrawable in project Onboarding by eoinfogarty.

the class SceneOneFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
    binding = DataBindingUtil.inflate(inflater, R.layout.fragment_scene_one, container, false);
    setRootPositionTag(binding.root);
    Resources resources = getResources();
    Bitmap bitmap = BitmapFactory.decodeResource(resources, R.drawable.img_shared);
    RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(resources, bitmap);
    drawable.setAntiAlias(true);
    if (savedState != null) {
        // restore shared image view position and radius
        binding.sharedImage.setTranslationY(savedState.getFloat(KEY_SHARED_VIEW_Y));
        drawable.setCornerRadius(savedState.getFloat(KEY_SHARED_VIEW_RADIUS));
    }
    binding.sharedImage.setImageDrawable(drawable);
    return binding.getRoot();
}
Also used : RoundedBitmapDrawable(android.support.v4.graphics.drawable.RoundedBitmapDrawable) Bitmap(android.graphics.Bitmap) Resources(android.content.res.Resources)

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