Search in sources :

Example 26 with RoundedBitmapDrawable

use of android.support.v4.graphics.drawable.RoundedBitmapDrawable in project JustAndroid by chinaltz.

the class PictureAlbumDirectoryAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
    final LocalMediaFolder folder = folders.get(position);
    String name = folder.getName();
    int imageNum = folder.getImageNum();
    String imagePath = folder.getFirstImagePath();
    boolean isChecked = folder.isChecked();
    int checkedNum = folder.getCheckedNum();
    holder.tv_sign.setVisibility(checkedNum > 0 ? View.VISIBLE : View.INVISIBLE);
    holder.itemView.setSelected(isChecked);
    Glide.with(holder.itemView.getContext()).load(imagePath).asBitmap().error(R.drawable.ic_placeholder).centerCrop().override(150, 150).diskCacheStrategy(DiskCacheStrategy.RESULT).into(new BitmapImageViewTarget(holder.first_image) {

        @Override
        protected void setResource(Bitmap resource) {
            RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(mContext.getResources(), resource);
            circularBitmapDrawable.setCornerRadius(8);
            holder.first_image.setImageDrawable(circularBitmapDrawable);
        }
    });
    holder.image_num.setText("(" + imageNum + ")");
    holder.tv_folder_name.setText(name);
    holder.itemView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (onItemClickListener != null)
                for (LocalMediaFolder mediaFolder : folders) {
                    mediaFolder.setChecked(false);
                }
            folder.setChecked(true);
            notifyDataSetChanged();
            onItemClickListener.onItemClick(folder.getName(), folder.getImages());
        }
    });
}
Also used : RoundedBitmapDrawable(android.support.v4.graphics.drawable.RoundedBitmapDrawable) LocalMediaFolder(com.ningcui.mylibrary.viewLib.Imagepicker.entity.LocalMediaFolder) Bitmap(android.graphics.Bitmap) BitmapImageViewTarget(com.bumptech.glide.request.target.BitmapImageViewTarget) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Example 27 with RoundedBitmapDrawable

use of android.support.v4.graphics.drawable.RoundedBitmapDrawable in project BGABadgeView-Android by bingoogolapple.

the class MainActivity method testBadgeView.

private void testBadgeView() {
    mTestBv.showTextBadge("9");
    mTestBv.getBadgeViewHelper().setBadgeTextSizeSp(15);
    mTestBv.getBadgeViewHelper().setBadgePaddingDp(8);
    mTestBv.getBadgeViewHelper().setBadgeTextColorInt(Color.parseColor("#FF0000"));
    mTestBv.getBadgeViewHelper().setBadgeBgColorInt(Color.parseColor("#00FF00"));
    mTestBv.getBadgeViewHelper().setDraggable(true);
    mTestBv.getBadgeViewHelper().setBadgePaddingDp(7);
    mTestBv.getBadgeViewHelper().setBadgeBorderWidthDp(2);
    mTestBv.getBadgeViewHelper().setBadgeBorderColorInt(Color.parseColor("#0000FF"));
    mTestBtv.showCirclePointBadge();
    mNormalBiv.showCirclePointBadge();
    Bitmap avatarBadgeBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.avatar_vip);
    RoundedBitmapDrawable roundedDrawable = RoundedBitmapDrawableFactory.create(getResources(), BitmapFactory.decodeResource(getResources(), R.mipmap.avator));
    roundedDrawable.getPaint().setAntiAlias(true);
    roundedDrawable.setCornerRadius(30);
    mRoundedBiv.setImageDrawable(roundedDrawable);
    mRoundedBiv.showDrawableBadge(avatarBadgeBitmap);
    Bitmap avatarBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.avator);
    RoundedBitmapDrawable circleDrawable = RoundedBitmapDrawableFactory.create(getResources(), avatarBitmap);
    circleDrawable.getPaint().setAntiAlias(true);
    circleDrawable.setCornerRadius(Math.max(avatarBitmap.getWidth(), avatarBitmap.getHeight()) / 2.0f);
    mCircleBiv.setImageDrawable(circleDrawable);
    mCircleBiv.showDrawableBadge(avatarBadgeBitmap);
    mTestBll.showDrawableBadge(avatarBadgeBitmap);
    mTestBrl.showTextBadge("LoveAndroid");
    mTestBfl.showTextBadge("8");
    mChatBfab.showTextBadge("8");
    mChatBfab.setDragDismissDelegate(new BGADragDismissDelegate() {

        @Override
        public void onDismiss(BGABadgeable badgeable) {
            ToastUtil.show("清空聊天消息");
        }
    });
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            mRoundedBiv.hiddenBadge();
        }
    }, 3000);
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            mRoundedBiv.showCirclePointBadge();
        }
    }, 6000);
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            mRoundedBiv.showDrawableBadge(BitmapFactory.decodeResource(getResources(), R.mipmap.avatar_vip));
        }
    }, 9000);
}
Also used : RoundedBitmapDrawable(android.support.v4.graphics.drawable.RoundedBitmapDrawable) Bitmap(android.graphics.Bitmap) BGADragDismissDelegate(cn.bingoogolapple.badgeview.BGADragDismissDelegate) BGABadgeable(cn.bingoogolapple.badgeview.BGABadgeable) Handler(android.os.Handler)

Example 28 with RoundedBitmapDrawable

use of android.support.v4.graphics.drawable.RoundedBitmapDrawable in project actor-platform by actorapp.

the class AndroidNotifications method onNotification.

@Override
public void onNotification(Messenger messenger, List<Notification> topNotifications, int messagesCount, int conversationsCount) {
    final NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
    builder.setAutoCancel(true);
    builder.setSmallIcon(R.drawable.ic_app_notify);
    builder.setPriority(NotificationCompat.PRIORITY_DEFAULT);
    builder.setCategory(NotificationCompat.CATEGORY_MESSAGE);
    int defaults = NotificationCompat.DEFAULT_LIGHTS;
    if (messenger.isNotificationVibrationEnabled()) {
        defaults |= NotificationCompat.DEFAULT_VIBRATE;
    }
    // if (silentUpdate) {
    // defaults = 0;
    // }
    builder.setDefaults(defaults);
    // Wearable
    // builder.extend(new NotificationCompat.WearableExtender()
    // .setBackground(((BitmapDrawable) AppContext.getContext().getResources().getDrawable(R.drawable.wear_bg)).getBitmap())
    // .setHintHideIcon(true));
    final Notification topNotification = topNotifications.get(topNotifications.size() - 1);
    // if (!silentUpdate) {
    // builder.setTicker(getNotificationTextFull(topNotification, messenger));
    // }
    android.app.Notification result;
    if (messagesCount == 1) {
        // Single message notification
        final String sender = getNotificationSender(topNotification);
        // final CharSequence text = bypass.markdownToSpannable(messenger().getFormatter().formatNotificationText(topNotification), true).toString();
        final CharSequence text = messenger.getFormatter().formatNotificationText(topNotification);
        visiblePeer = topNotification.getPeer();
        Avatar avatar = null;
        int id = 0;
        String avatarTitle = "";
        switch(visiblePeer.getPeerType()) {
            case PRIVATE:
                avatar = messenger().getUsers().get(visiblePeer.getPeerId()).getAvatar().get();
                id = messenger().getUsers().get(visiblePeer.getPeerId()).getId();
                avatarTitle = messenger().getUsers().get(visiblePeer.getPeerId()).getName().get();
                break;
            case GROUP:
                avatar = messenger().getGroups().get(visiblePeer.getPeerId()).getAvatar().get();
                id = messenger().getGroups().get(visiblePeer.getPeerId()).getId();
                avatarTitle = messenger().getGroups().get(visiblePeer.getPeerId()).getName().get();
                break;
        }
        Drawable avatarDrawable = new AvatarPlaceholderDrawable(avatarTitle, id, 18, context);
        result = buildSingleMessageNotification(avatarDrawable, builder, sender, text, topNotification);
        final NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        manager.notify(NOTIFICATION_ID, result);
        if (avatar != null && avatar.getSmallImage() != null && avatar.getSmallImage().getFileReference() != null) {
            messenger.bindFile(avatar.getSmallImage().getFileReference(), true, new FileVMCallback() {

                @Override
                public void onNotDownloaded() {
                }

                @Override
                public void onDownloading(float progress) {
                }

                @Override
                public void onDownloaded(FileSystemReference reference) {
                    RoundedBitmapDrawable d = getRoundedBitmapDrawable(reference);
                    android.app.Notification result = buildSingleMessageNotification(d, builder, sender, text, topNotification);
                    // NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
                    manager.notify(NOTIFICATION_ID, result);
                }
            });
        } else {
            manager.notify(NOTIFICATION_ID, result);
        }
    } else if (conversationsCount == 1) {
        // Single conversation notification
        String sender = getNotificationSender(topNotification);
        builder.setContentTitle(sender);
        builder.setContentText(messagesCount + context.getString(R.string.notifications_single_conversation_аfter_messages_count));
        visiblePeer = topNotification.getPeer();
        final NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
        for (Notification n : topNotifications) {
            if (topNotification.getPeer().getPeerType() == PeerType.GROUP) {
                inboxStyle.addLine(getNotificationTextFull(n, messenger));
            } else {
                inboxStyle.addLine(messenger.getFormatter().formatNotificationText(n));
            }
        }
        inboxStyle.setSummaryText(messagesCount + context.getString(R.string.notifications_single_conversation_аfter_messages_count));
        Avatar avatar = null;
        int id = 0;
        String avatarTitle = "";
        switch(visiblePeer.getPeerType()) {
            case PRIVATE:
                avatar = messenger().getUsers().get(visiblePeer.getPeerId()).getAvatar().get();
                id = messenger().getUsers().get(visiblePeer.getPeerId()).getId();
                avatarTitle = messenger().getUsers().get(visiblePeer.getPeerId()).getName().get();
                break;
            case GROUP:
                avatar = messenger().getGroups().get(visiblePeer.getPeerId()).getAvatar().get();
                id = messenger().getGroups().get(visiblePeer.getPeerId()).getId();
                avatarTitle = messenger().getGroups().get(visiblePeer.getPeerId()).getName().get();
                break;
        }
        Drawable avatarDrawable = new AvatarPlaceholderDrawable(avatarTitle, id, 18, context);
        result = buildSingleConversationNotification(builder, inboxStyle, avatarDrawable, topNotification);
        final NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        manager.notify(NOTIFICATION_ID, result);
        if (avatar != null && avatar.getSmallImage() != null && avatar.getSmallImage().getFileReference() != null) {
            messenger.bindFile(avatar.getSmallImage().getFileReference(), true, new FileVMCallback() {

                @Override
                public void onNotDownloaded() {
                }

                @Override
                public void onDownloading(float progress) {
                }

                @Override
                public void onDownloaded(FileSystemReference reference) {
                    RoundedBitmapDrawable d = getRoundedBitmapDrawable(reference);
                    android.app.Notification result = buildSingleConversationNotification(builder, inboxStyle, d, topNotification);
                    manager.notify(NOTIFICATION_ID, result);
                }
            });
        } else {
            manager.notify(NOTIFICATION_ID, result);
        }
    } else {
        // Multiple conversations notification
        builder.setContentTitle(ActorSDK.sharedActor().getAppName());
        builder.setContentText(messagesCount + context.getString(R.string.notification_multiple_canversations_after_msg_count) + conversationsCount + context.getString(R.string.notifications_multiple_canversations_after_coversations_count));
        visiblePeer = null;
        intent = new Intent(context, RootActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        builder.setContentIntent(PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT));
        NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
        for (Notification n : topNotifications) {
            inboxStyle.addLine(getNotificationTextFull(n, messenger));
        }
        inboxStyle.setSummaryText(messagesCount + context.getString(R.string.notification_multiple_canversations_after_msg_count) + conversationsCount + context.getString(R.string.notifications_multiple_canversations_after_coversations_count));
        result = builder.setStyle(inboxStyle).build();
        addCustomLedAndSound(topNotification, result);
        NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        manager.notify(NOTIFICATION_ID, result);
    }
}
Also used : RoundedBitmapDrawable(android.support.v4.graphics.drawable.RoundedBitmapDrawable) FileSystemReference(im.actor.runtime.files.FileSystemReference) NotificationManager(android.app.NotificationManager) SpannableStringBuilder(android.text.SpannableStringBuilder) AvatarPlaceholderDrawable(im.actor.sdk.view.avatar.AvatarPlaceholderDrawable) Drawable(android.graphics.drawable.Drawable) RoundedBitmapDrawable(android.support.v4.graphics.drawable.RoundedBitmapDrawable) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) Notification(im.actor.core.entity.Notification) Avatar(im.actor.core.entity.Avatar) NotificationCompat(android.support.v4.app.NotificationCompat) AvatarPlaceholderDrawable(im.actor.sdk.view.avatar.AvatarPlaceholderDrawable) FileVMCallback(im.actor.core.viewmodel.FileVMCallback)

Example 29 with RoundedBitmapDrawable

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

the class MyIODialogFragment method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Context context = getContext();
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    boolean signedIn = AccountUtils.hasActiveAccount(context);
    if (signedIn) {
        LayoutInflater inflater = LayoutInflater.from(context);
        View titleView = inflater.inflate(R.layout.myio_auth_dialog_signedin_title, null);
        TextView name = (TextView) titleView.findViewById(R.id.name);
        TextView email = (TextView) titleView.findViewById(R.id.email);
        final ImageView avatar = (ImageView) titleView.findViewById(R.id.avatar);
        name.setText(AccountUtils.getActiveAccountDisplayName(context));
        email.setText(AccountUtils.getActiveAccountName(context));
        // Note: this may be null if the user has not set up a profile photo.
        Uri url = AccountUtils.getActiveAccountPhotoUrl(context);
        if (url != null) {
            Glide.with(context).load(url.toString()).asBitmap().fitCenter().placeholder(R.drawable.ic_default_avatar).into(new BitmapImageViewTarget(avatar) {

                @Override
                protected void setResource(Bitmap resource) {
                    RoundedBitmapDrawable roundedBmp = RoundedBitmapDrawableFactory.create(context.getResources(), resource);
                    roundedBmp.setCircular(true);
                    avatar.setImageDrawable(roundedBmp);
                }
            });
        }
        builder.setCustomTitle(titleView);
        builder.setMessage(buildDialogText(context, R.string.my_io_body_intro_signed_in, R.string.my_io_dialog_first_bullet_point_signed_in, R.string.my_io_dialog_second_bullet_point_signed_in, R.string.my_io_dialog_third_bullet_point_signed_in, Color.BLACK));
    } else {
        builder.setMessage(buildDialogText(getContext(), R.string.my_io_body_intro_signed_out, R.string.my_io_dialog_first_bullet_point_signed_out, R.string.my_io_dialog_second_bullet_point_signed_out, R.string.my_io_dialog_third_bullet_point_signed_out, Color.BLACK));
    }
    builder.setPositiveButton(signedIn ? R.string.signout_prompt : R.string.signin_prompt, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            MyIOActivity myIOActivity = ((MyIOActivity) getActivity());
            if (AccountUtils.hasActiveAccount(myIOActivity)) {
                myIOActivity.signOut();
            } else {
                myIOActivity.signIn();
            }
            dismiss();
        }
    });
    return builder.create();
}
Also used : Context(android.content.Context) AlertDialog(android.support.v7.app.AlertDialog) RoundedBitmapDrawable(android.support.v4.graphics.drawable.RoundedBitmapDrawable) BitmapImageViewTarget(com.bumptech.glide.request.target.BitmapImageViewTarget) DialogInterface(android.content.DialogInterface) SpannableStringBuilder(android.text.SpannableStringBuilder) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) Uri(android.net.Uri) Bitmap(android.graphics.Bitmap) LayoutInflater(android.view.LayoutInflater) OnClickListener(android.content.DialogInterface.OnClickListener) TextView(android.widget.TextView) ImageView(android.widget.ImageView) NonNull(android.support.annotation.NonNull)

Example 30 with RoundedBitmapDrawable

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

the class ImageUtilsModule method cropRoundedImage.

@NonNull
public Bitmap cropRoundedImage(Bitmap image) {
    RoundedBitmapDrawable roundedImage;
    int originalWidth = image.getWidth();
    int originalHeight = image.getHeight();
    int dimen = Math.min(originalWidth, originalHeight);
    image = Bitmap.createBitmap(image, (originalWidth - dimen) / 2, (originalHeight - dimen) / 2, dimen, dimen);
    roundedImage = RoundedBitmapDrawableFactory.create(getResources(), image);
    roundedImage.setAntiAlias(true);
    roundedImage.setCircular(true);
    // roundedImage.setCornerRadius(dimen / 2);
    return drawableToBitmap(roundedImage);
}
Also used : RoundedBitmapDrawable(android.support.v4.graphics.drawable.RoundedBitmapDrawable) NonNull(android.support.annotation.NonNull)

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