use of com.bumptech.glide.load.resource.bitmap.RoundedCorners in project glide by bumptech.
the class NonBitmapDrawableResourcesTest method load_withShapeDrawableResourceId_asDrawable_withTransformation_validSize_succeeds.
@Test
public void load_withShapeDrawableResourceId_asDrawable_withTransformation_validSize_succeeds() throws ExecutionException, InterruptedException {
Drawable drawable = Glide.with(context).load(ResourceIds.drawable.shape_drawable).apply(bitmapTransform(new RoundedCorners(10))).submit(100, 200).get();
assertThat(drawable).isNotNull();
assertThat(drawable.getIntrinsicWidth()).isEqualTo(100);
assertThat(drawable.getIntrinsicHeight()).isEqualTo(200);
}
use of com.bumptech.glide.load.resource.bitmap.RoundedCorners in project glide by bumptech.
the class WideGamutTest method roundedCorners_withWideGamutBitmap_producesWideGamutBitmap.
@Test
public void roundedCorners_withWideGamutBitmap_producesWideGamutBitmap() {
Bitmap bitmap = Bitmap.createBitmap(100, 100, Config.RGBA_F16);
byte[] data = asPng(bitmap);
Bitmap result = concurrency.get(GlideApp.with(context).asBitmap().load(data).transform(new RoundedCorners(/*roundingRadius=*/
10)).submit());
assertThat(result).isNotNull();
assertThat(result.getConfig()).isEqualTo(Config.RGBA_F16);
}
use of com.bumptech.glide.load.resource.bitmap.RoundedCorners in project glide by bumptech.
the class RoundedCornersRegressionTest method testRoundedCorners_usePool.
@Test
public void testRoundedCorners_usePool() throws ExecutionException, InterruptedException {
canonicalBitmap = canonicalBitmap.scale(0.1f);
Bitmap redRect = createRect(Color.RED, canonicalBitmap.getWidth(), canonicalBitmap.getHeight(), Bitmap.Config.ARGB_8888);
Glide.get(context).getBitmapPool().put(redRect);
Bitmap roundedRect = bitmapRegressionTester.test(GlideApp.with(context).asBitmap().load(canonicalBitmap.getBitmap()).override(canonicalBitmap.getWidth(), canonicalBitmap.getHeight()).transform(new RoundedCorners(5)));
assertThat(roundedRect).isEqualTo(redRect);
}
use of com.bumptech.glide.load.resource.bitmap.RoundedCorners in project Tusky by Vavassor.
the class NotificationHelper method make.
/**
* Takes a given Mastodon notification and either creates a new Android notification or updates
* the state of the existing notification to reflect the new interaction.
*
* @param context to access application preferences and services
* @param body a new Mastodon notification
* @param account the account for which the notification should be shown
*/
public static void make(final Context context, Notification body, AccountEntity account, boolean isFirstOfBatch) {
body = body.rewriteToStatusTypeIfNeeded(account.getAccountId());
if (!filterNotification(account, body, context)) {
return;
}
String rawCurrentNotifications = account.getActiveNotifications();
JSONArray currentNotifications;
try {
currentNotifications = new JSONArray(rawCurrentNotifications);
} catch (JSONException e) {
currentNotifications = new JSONArray();
}
for (int i = 0; i < currentNotifications.length(); i++) {
try {
if (currentNotifications.getString(i).equals(body.getAccount().getName())) {
currentNotifications.remove(i);
break;
}
} catch (JSONException e) {
Log.d(TAG, Log.getStackTraceString(e));
}
}
currentNotifications.put(body.getAccount().getName());
account.setActiveNotifications(currentNotifications.toString());
// Notification group member
// =========================
final NotificationCompat.Builder builder = newNotification(context, body, account, false);
notificationId++;
builder.setContentTitle(titleForType(context, body, account)).setContentText(bodyForType(body, context));
if (body.getType() == Notification.Type.MENTION || body.getType() == Notification.Type.POLL) {
builder.setStyle(new NotificationCompat.BigTextStyle().bigText(bodyForType(body, context)));
}
// load the avatar synchronously
Bitmap accountAvatar;
try {
FutureTarget<Bitmap> target = Glide.with(context).asBitmap().load(body.getAccount().getAvatar()).transform(new RoundedCorners(20)).submit();
accountAvatar = target.get();
} catch (ExecutionException | InterruptedException e) {
Log.d(TAG, "error loading account avatar", e);
accountAvatar = BitmapFactory.decodeResource(context.getResources(), R.drawable.avatar_default);
}
builder.setLargeIcon(accountAvatar);
// Reply to mention action; RemoteInput is available from KitKat Watch, but buttons are available from Nougat
if (body.getType() == Notification.Type.MENTION && android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
RemoteInput replyRemoteInput = new RemoteInput.Builder(KEY_REPLY).setLabel(context.getString(R.string.label_quick_reply)).build();
PendingIntent quickReplyPendingIntent = getStatusReplyIntent(REPLY_ACTION, context, body, account);
NotificationCompat.Action quickReplyAction = new NotificationCompat.Action.Builder(R.drawable.ic_reply_24dp, context.getString(R.string.action_quick_reply), quickReplyPendingIntent).addRemoteInput(replyRemoteInput).build();
builder.addAction(quickReplyAction);
PendingIntent composePendingIntent = getStatusReplyIntent(COMPOSE_ACTION, context, body, account);
NotificationCompat.Action composeAction = new NotificationCompat.Action.Builder(R.drawable.ic_reply_24dp, context.getString(R.string.action_compose_shortcut), composePendingIntent).build();
builder.addAction(composeAction);
}
builder.setSubText(account.getFullName());
builder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE);
builder.setCategory(NotificationCompat.CATEGORY_SOCIAL);
builder.setOnlyAlertOnce(true);
// only alert for the first notification of a batch to avoid multiple alerts at once
if (!isFirstOfBatch) {
builder.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_SUMMARY);
}
// Summary
// =======
final NotificationCompat.Builder summaryBuilder = newNotification(context, body, account, true);
if (currentNotifications.length() != 1) {
try {
String title = context.getResources().getQuantityString(R.plurals.notification_title_summary, currentNotifications.length(), currentNotifications.length());
String text = joinNames(context, currentNotifications);
summaryBuilder.setContentTitle(title).setContentText(text);
} catch (JSONException e) {
Log.d(TAG, Log.getStackTraceString(e));
}
}
summaryBuilder.setSubText(account.getFullName());
summaryBuilder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE);
summaryBuilder.setCategory(NotificationCompat.CATEGORY_SOCIAL);
summaryBuilder.setOnlyAlertOnce(true);
summaryBuilder.setGroupSummary(true);
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
notificationManager.notify(notificationId, builder.build());
if (currentNotifications.length() == 1) {
notificationManager.notify((int) account.getId(), builder.setGroupSummary(true).build());
} else {
notificationManager.notify((int) account.getId(), summaryBuilder.build());
}
}
use of com.bumptech.glide.load.resource.bitmap.RoundedCorners in project banner by youth5201314.
the class MainActivity method click.
@OnClick({ R.id.style_image, R.id.style_image_title, R.id.style_image_title_num, R.id.style_multiple, R.id.style_net_image, R.id.change_indicator, R.id.rv_banner, R.id.cl_banner, R.id.vp_banner, R.id.banner_video, R.id.banner_tv, R.id.gallery, R.id.topLine })
public void click(View view) {
indicator.setVisibility(View.GONE);
switch(view.getId()) {
case R.id.style_image:
refresh.setEnabled(true);
banner.setAdapter(new ImageAdapter(DataBean.getTestData()));
banner.setIndicator(new CircleIndicator(this));
banner.setIndicatorGravity(IndicatorConfig.Direction.CENTER);
break;
case R.id.style_image_title:
refresh.setEnabled(true);
banner.setAdapter(new ImageTitleAdapter(DataBean.getTestData()));
banner.setIndicator(new CircleIndicator(this));
banner.setIndicatorGravity(IndicatorConfig.Direction.RIGHT);
banner.setIndicatorMargins(new IndicatorConfig.Margins(0, 0, BannerConfig.INDICATOR_MARGIN, BannerUtils.dp2px(12)));
break;
case R.id.style_image_title_num:
refresh.setEnabled(true);
// 这里是将数字指示器和title都放在adapter中的,如果不想这样你也可以直接设置自定义的数字指示器
banner.setAdapter(new ImageTitleNumAdapter(DataBean.getTestData()));
banner.removeIndicator();
break;
case R.id.style_multiple:
refresh.setEnabled(true);
banner.setIndicator(new CircleIndicator(this));
banner.setAdapter(new MultipleTypesAdapter(this, DataBean.getTestData()));
break;
case R.id.style_net_image:
refresh.setEnabled(false);
// 方法一:使用自定义图片适配器
// banner.setAdapter(new ImageNetAdapter(DataBean.getTestData3()));
// 方法二:使用自带的图片适配器
banner.setAdapter(new BannerImageAdapter<DataBean>(DataBean.getTestData3()) {
@Override
public void onBindView(BannerImageHolder holder, DataBean data, int position, int size) {
// 图片加载自己实现
Glide.with(holder.itemView).load(data.imageUrl).thumbnail(Glide.with(holder.itemView).load(R.drawable.loading)).apply(RequestOptions.bitmapTransform(new RoundedCorners(30))).into(holder.imageView);
}
});
banner.setIndicator(new RoundLinesIndicator(this));
banner.setIndicatorSelectedWidth(BannerUtils.dp2px(15));
break;
case R.id.change_indicator:
indicator.setVisibility(View.VISIBLE);
// 在布局文件中使用指示器,这样更灵活
banner.setIndicator(indicator, false);
banner.setIndicatorSelectedWidth(BannerUtils.dp2px(15));
break;
case R.id.gallery:
startActivity(new Intent(this, GalleryActivity.class));
break;
case R.id.rv_banner:
startActivity(new Intent(this, RecyclerViewBannerActivity.class));
break;
case R.id.cl_banner:
startActivity(new Intent(this, ConstraintLayoutBannerActivity.class));
break;
case R.id.vp_banner:
startActivity(new Intent(this, Vp2FragmentRecyclerviewActivity.class));
break;
case R.id.banner_video:
startActivity(new Intent(this, VideoActivity.class));
break;
case R.id.banner_tv:
startActivity(new Intent(this, TVActivity.class));
break;
case R.id.topLine:
startActivity(new Intent(this, TouTiaoActivity.class));
break;
}
}
Aggregations