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);
}
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;
}
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);
}
}
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);
}
}
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;
}
Aggregations