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