类android.support.v4.graphics.drawable.RoundedBitmapDrawable源码实例Demo

下面列出了怎么用android.support.v4.graphics.drawable.RoundedBitmapDrawable的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: YCAudioPlayer   文件: ImageUtil.java
/**
 * 加载带有圆角的矩形图片  用glide处理
 *
 * @param path   路径
 * @param round  圆角半径
 * @param resId  加载失败时的图片
 * @param target 控件
 */
public static void loadImgByPicassoWithRound(final Context activity, String path, final int round, int resId, final ImageView target) {
    if (path != null && path.length() > 0) {
        Glide.with(activity)
                .load(path)
                .asBitmap()
                .placeholder(resId)
                .error(resId)
                //设置缓存
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .into(new BitmapImageViewTarget(target) {
                    @Override
                    protected void setResource(Bitmap resource) {
                        super.setResource(resource);
                        RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(activity.getResources(), resource);
                        //设置圆角弧度
                        circularBitmapDrawable.setCornerRadius(round);
                        target.setImageDrawable(circularBitmapDrawable);
                    }
                });
    }
}
 
源代码2 项目: youqu_master   文件: BookReviewsAdapter.java
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
    if (holder instanceof BookCommentHolder) {
        List<BookReviewBean> reviews = reviewsListResponse.getReviews();
        Glide.with(BaseApplication.getAppContext())
                .load(reviews.get(position).getAuthor().getAvatar())
                .asBitmap()
                .centerCrop()
                .into(new BitmapImageViewTarget(((BookCommentHolder) holder).iv_avatar) {
                    @Override
                    protected void setResource(Bitmap resource) {
                        RoundedBitmapDrawable circularBitmapDrawable =
                                RoundedBitmapDrawableFactory.create(BaseApplication.getAppContext().getResources(), resource);
                        circularBitmapDrawable.setCircular(true);
                        ((BookCommentHolder) holder).iv_avatar.setImageDrawable(circularBitmapDrawable);
                    }
                });
        ((BookCommentHolder) holder).tv_user_name.setText(reviews.get(position).getAuthor().getName());
        if (reviews.get(position).getRating() != null) {
            ((BookCommentHolder) holder).ratingBar_hots.setRating(Float.valueOf(reviews.get(position).getRating().getValue()));
        }
        ((BookCommentHolder) holder).tv_comment_content.setText(reviews.get(position).getSummary());
        ((BookCommentHolder) holder).tv_favorite_num.setText(reviews.get(position).getVotes() + "");
        ((BookCommentHolder) holder).tv_update_time.setText(reviews.get(position).getUpdated().split(" ")[0]);
    }
}
 
源代码3 项目: NoInternetDialog   文件: NoInternetDialog.java
private void initHalloweenTheme() {
    if (!isHalloween) {
        return;
    }

    Bitmap bmp = BitmapFactory.decodeResource(getContext().getResources(), R.drawable.ground);
    RoundedBitmapDrawable dr = RoundedBitmapDrawableFactory.create(getContext().getResources(), bmp);
    dr.setCornerRadius(dialogRadius);
    dr.setAntiAlias(true);

    ground.setBackgroundDrawable(dr);

    plane.setImageResource(R.drawable.witch);
    tomb.setImageResource(R.drawable.tomb_hw);
    moon.setVisibility(View.VISIBLE);
    ground.setVisibility(View.VISIBLE);
    pumpkin.setVisibility(View.VISIBLE);
    wifiOn.getBackground().mutate().setColorFilter(ContextCompat.getColor(getContext(), R.color.colorNoInternetGradCenterH), PorterDuff.Mode.SRC_IN);
    mobileOn.getBackground().mutate().setColorFilter(ContextCompat.getColor(getContext(), R.color.colorNoInternetGradCenterH), PorterDuff.Mode.SRC_IN);
    airplaneOff.getBackground().mutate().setColorFilter(ContextCompat.getColor(getContext(), R.color.colorNoInternetGradCenterH), PorterDuff.Mode.SRC_IN);
}
 
源代码4 项目: Password-Storage   文件: MainActivity.java
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) {

        Uri uri = data.getData();

        try {
            Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), uri);
            if(flag==1) {passwordDatabase.updatePic(bitmap); }
            else if(flag==0) {passwordDatabase.setPic(bitmap); flag=1; }

            profile.setImageBitmap(bitmap);
            //round image
            RoundedBitmapDrawable roundedImageDrawable = createRoundedBitmapImageDrawableWithBorder(bitmap);
            profile.setImageDrawable(roundedImageDrawable);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
 
源代码5 项目: MediaNotification   文件: CircleImageView.java
@Override
public void onDraw(Canvas canvas) {
    if (bitmap != null) {
        int size = Math.min(canvas.getWidth(), canvas.getHeight());
        if (size != this.size) {
            this.size = size;
            bitmap = ThumbnailUtils.extractThumbnail(bitmap, size, size);

            RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), bitmap);

            roundedBitmapDrawable.setCornerRadius(size / 2);
            roundedBitmapDrawable.setAntiAlias(true);

            bitmap = ImageUtils.drawableToBitmap(roundedBitmapDrawable);
        }

        canvas.drawBitmap(bitmap, 0, 0, paint);
    }
}
 
源代码6 项目: FakeWeather   文件: XianduAdapter.java
@Override
public void onBindViewHolder(final XianViewHolder holder, int position) {
    final XianduItem item = xiandus.get(position);
    holder.rootView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            WebUtils.openInternal(context, item.getUrl());
        }
    });
    holder.tv_name.setText(String.format("%s. %s", position + 1, item.getName()));
    holder.tv_info.setText(item.getUpdateTime() + " • " + item.getFrom());
    Glide.with(context).load(item.getIcon()).asBitmap().diskCacheStrategy(DiskCacheStrategy.ALL).fitCenter().into(new SimpleTarget<Bitmap>() {
        @Override
        public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
            RoundedBitmapDrawable circularBitmapDrawable =
                    RoundedBitmapDrawableFactory.create(context.getResources(), resource);
            circularBitmapDrawable.setCircular(true);
            holder.iv.setImageDrawable(circularBitmapDrawable);
        }
    });
}
 
源代码7 项目: YCVideoPlayer   文件: ImageUtil.java
/**
 * 加载带有圆角的矩形图片  用glide处理
 *
 * @param path   路径
 * @param round  圆角半径
 * @param resId  加载失败时的图片
 * @param target 控件
 */
public static void loadImgByPicassoWithRound(final Context activity, String path, final int round, int resId, final ImageView target) {
    if (path != null && path.length() > 0) {
        Glide.with(activity)
                .asBitmap()
                .load(path)
                .placeholder(resId)
                .error(resId)
                //设置缓存
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .into(new BitmapImageViewTarget(target) {
                    @Override
                    protected void setResource(Bitmap resource) {
                        super.setResource(resource);
                        RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(activity.getResources(), resource);
                        //设置圆角弧度
                        circularBitmapDrawable.setCornerRadius(round);
                        target.setImageDrawable(circularBitmapDrawable);
                    }
                });
    }
}
 
源代码8 项目: delion   文件: NewTabPageView.java
@Override
public void onLargeIconAvailable(Bitmap icon, int fallbackColor) {
    if (icon == null) {
        mIconGenerator.setBackgroundColor(fallbackColor);
        icon = mIconGenerator.generateIconForUrl(mItem.getUrl());
        mItemView.setIcon(new BitmapDrawable(getResources(), icon));
        mItem.setTileType(fallbackColor == ICON_BACKGROUND_COLOR
                ? MostVisitedTileType.ICON_DEFAULT : MostVisitedTileType.ICON_COLOR);
    } else {
        RoundedBitmapDrawable roundedIcon = RoundedBitmapDrawableFactory.create(
                getResources(), icon);
        int cornerRadius = Math.round(ICON_CORNER_RADIUS_DP
                * getResources().getDisplayMetrics().density * icon.getWidth()
                / mDesiredIconSize);
        roundedIcon.setCornerRadius(cornerRadius);
        roundedIcon.setAntiAlias(true);
        roundedIcon.setFilterBitmap(true);
        mItemView.setIcon(roundedIcon);
        mItem.setTileType(MostVisitedTileType.ICON_REAL);
    }
    mSnapshotMostVisitedChanged = true;
    if (mIsInitialLoad) loadTaskCompleted();
}
 
源代码9 项目: delion   文件: InterestsItemView.java
@Override
protected Drawable doInBackground(Void... voids) {
    // This is run on a background thread.
    try {
        // TODO(peconn): Replace this with something from the C++ Chrome stack.
        URL imageUrl = new URL(mUrl);
        InputStream in = imageUrl.openStream();

        Bitmap raw = BitmapFactory.decodeStream(in);
        int dimension = Math.min(raw.getHeight(), raw.getWidth());
        RoundedBitmapDrawable img = RoundedBitmapDrawableFactory.create(mResources,
                ThumbnailUtils.extractThumbnail(raw, dimension, dimension));
        img.setCircular(true);

        return img;
    } catch (IOException e) {
        Log.e(TAG, "Error downloading image: " + e.toString());
    }
    return null;
}
 
源代码10 项目: AndroidChromium   文件: NewTabPageView.java
@Override
public void onLargeIconAvailable(
        Bitmap icon, int fallbackColor, boolean isFallbackColorDefault) {
    if (icon == null) {
        mIconGenerator.setBackgroundColor(fallbackColor);
        icon = mIconGenerator.generateIconForUrl(mItem.getUrl());
        mItemView.setIcon(new BitmapDrawable(getResources(), icon));
        mItem.setTileType(isFallbackColorDefault ? MostVisitedTileType.ICON_DEFAULT
                                                 : MostVisitedTileType.ICON_COLOR);
    } else {
        RoundedBitmapDrawable roundedIcon = RoundedBitmapDrawableFactory.create(
                getResources(), icon);
        int cornerRadius = Math.round(ICON_CORNER_RADIUS_DP
                * getResources().getDisplayMetrics().density * icon.getWidth()
                / mDesiredIconSize);
        roundedIcon.setCornerRadius(cornerRadius);
        roundedIcon.setAntiAlias(true);
        roundedIcon.setFilterBitmap(true);
        mItemView.setIcon(roundedIcon);
        mItem.setTileType(MostVisitedTileType.ICON_REAL);
    }
    mSnapshotMostVisitedChanged = true;
    if (mIsInitialLoad) loadTaskCompleted();
}
 
源代码11 项目: leanback-showcase   文件: TextCardView.java
public void updateUi(Card card) {
    TextView extraText = (TextView) findViewById(R.id.extra_text);
    TextView primaryText = (TextView) findViewById(R.id.primary_text);
    final ImageView imageView = (ImageView) findViewById(R.id.main_image);

    extraText.setText(card.getExtraText());
    primaryText.setText(card.getTitle());

    // Create a rounded drawable.
    int resourceId = card.getLocalImageResourceId(getContext());
    Bitmap bitmap = BitmapFactory
            .decodeResource(getContext().getResources(), resourceId);
    RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(getContext().getResources(), bitmap);
    drawable.setAntiAlias(true);
    drawable.setCornerRadius(
            Math.max(bitmap.getWidth(), bitmap.getHeight()) / 2.0f);
    imageView.setImageDrawable(drawable);
}
 
源代码12 项目: MaterialHome   文件: EBookReviewsAdapter.java
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
    if (holder instanceof BookCommentHolder) {
        List<HotReview.Reviews> reviews = mHotView.getReviews();
        Glide.with(UIUtils.getContext())
                .load(EBookUtils.getImageUrl(reviews.get(position).getAuthor().getAvatar()))
                .asBitmap()
                .centerCrop()
                .into(new BitmapImageViewTarget(((BookCommentHolder) holder).iv_avatar) {
                    @Override
                    protected void setResource(Bitmap resource) {
                        RoundedBitmapDrawable circularBitmapDrawable =
                                RoundedBitmapDrawableFactory.create(UIUtils.getContext().getResources(), resource);
                        circularBitmapDrawable.setCircular(true);
                        ((BookCommentHolder) holder).iv_avatar.setImageDrawable(circularBitmapDrawable);
                    }
                });
        ((BookCommentHolder) holder).tv_user_name.setText(reviews.get(position).getAuthor().getNickname());
        ((BookCommentHolder) holder).ratingBar_hots.setRating((float) reviews.get(position).getRating());
        ((BookCommentHolder) holder).tv_comment_content.setText(reviews.get(position).getContent());
        ((BookCommentHolder) holder).tv_favorite_num.setText(reviews.get(position).getLikeCount() + "");
        ((BookCommentHolder) holder).tv_update_time.setText(reviews.get(position).getUpdated().split("T")[0]);
    }
}
 
源代码13 项目: MaterialHome   文件: BookReviewsAdapter.java
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
    if (holder instanceof BookCommentHolder) {
        List<BookReviewResponse> reviews = reviewsListResponse.getReviews();
        Glide.with(UIUtils.getContext())
                .load(reviews.get(position).getAuthor().getAvatar())
                .asBitmap()
                .centerCrop()
                .into(new BitmapImageViewTarget(((BookCommentHolder) holder).iv_avatar) {
                    @Override
                    protected void setResource(Bitmap resource) {
                        RoundedBitmapDrawable circularBitmapDrawable =
                                RoundedBitmapDrawableFactory.create(UIUtils.getContext().getResources(), resource);
                        circularBitmapDrawable.setCircular(true);
                        ((BookCommentHolder) holder).iv_avatar.setImageDrawable(circularBitmapDrawable);
                    }
                });
        ((BookCommentHolder) holder).tv_user_name.setText(reviews.get(position).getAuthor().getName());
        if (reviews.get(position).getRating() != null) {
            ((BookCommentHolder) holder).ratingBar_hots.setRating(Float.valueOf(reviews.get(position).getRating().getValue()));
        }
        ((BookCommentHolder) holder).tv_comment_content.setText(reviews.get(position).getSummary());
        ((BookCommentHolder) holder).tv_favorite_num.setText(reviews.get(position).getVotes() + "");
        ((BookCommentHolder) holder).tv_update_time.setText(reviews.get(position).getUpdated().split(" ")[0]);
    }
}
 
源代码14 项目: JianshuApp   文件: SubscriptionAdapter.java
private void showAddToDesktop(SubscriptionType type, String id, String imgUrl, String name) {
    Alerts.list(null, AppUtils.getContext().getString(R.string.add_to_desktop))
            .flatMap(it -> {
                return ImageUtils.loadImage(ImageUtils.parseUri(imgUrl), 128, 128)
                        .map(bitmap -> {
                            RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(AppUtils.getContext().getResources(), bitmap);
                            drawable.setCornerRadius(20);
                            return (Drawable)drawable;
                        })
                        .onErrorReturnItem(AppUtils.getContext().getResources().getDrawable(R.drawable.jianshu_icon))
                        .map(BitmapUtils::toBitmap);
            })
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(bitmap -> {
                ShortcutUtils.addShortcut(type, id, name, bitmap);
            }, err -> {
                LogUtils.e(err);
            });
}
 
源代码15 项目: FastAccess   文件: FloatingView.java
public void setupImageView() {
    if (imageView != null) {
        String path = PrefHelper.getString(PrefConstant.CUSTOM_ICON);
        if (!InputHelper.isEmpty(path)) {
            path = Uri.decode(PrefHelper.getString(PrefConstant.CUSTOM_ICON));
            boolean fileExists = new File(path).exists();
            if (fileExists) {
                imageView.setImageDrawable(null);
                Bitmap src = BitmapFactory.decodeFile(path);
                if (src == null) {
                    imageView.setImageResource(R.drawable.ic_app_drawer_icon);
                    onMoving(false);
                    return;
                }
                RoundedBitmapDrawable dr = RoundedBitmapDrawableFactory.create(getResources(), src);
                dr.setCornerRadius(Math.max(src.getWidth(), src.getHeight()) / 2.0f);
                imageView.setImageDrawable(dr);
                return;
            }
        }
        imageView.setImageResource(R.drawable.ic_app_drawer_icon);
        onMoving(false);
    }
}
 
@Override
public View getView(int position, View convertView, ViewGroup container) {
    if (convertView == null) {
        convertView = LayoutInflater.from(getActivity()).inflate(R.layout.list_item_article, container, false);
    }

    final DummyContent.DummyItem item = (DummyContent.DummyItem) getItem(position);
    ((TextView) convertView.findViewById(R.id.article_title)).setText(item.title);
    ((TextView) convertView.findViewById(R.id.article_subtitle)).setText(item.author);
    final ImageView img = (ImageView) convertView.findViewById(R.id.thumbnail);
    Glide.with(getActivity()).load(item.photoId).asBitmap().fitCenter().into(new BitmapImageViewTarget(img) {
        @Override
        protected void setResource(Bitmap resource) {
            RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(getActivity().getResources(), resource);
            circularBitmapDrawable.setCircular(true);
            img.setImageDrawable(circularBitmapDrawable);
        }
    });

    return convertView;
}
 
源代码17 项目: 365browser   文件: HistoryItemView.java
@Override
public void onLargeIconAvailable(Bitmap icon, int fallbackColor,
        boolean isFallbackColorDefault) {
    // TODO(twellington): move this somewhere that can be shared with bookmarks.
    if (icon == null) {
        mIconGenerator.setBackgroundColor(fallbackColor);
        icon = mIconGenerator.generateIconForUrl(getItem().getUrl());
        mIconImageView.setImageDrawable(new BitmapDrawable(getResources(), icon));
    } else {
        RoundedBitmapDrawable roundedIcon = RoundedBitmapDrawableFactory.create(
                getResources(),
                Bitmap.createScaledBitmap(icon, mDisplayedIconSize, mDisplayedIconSize, false));
        roundedIcon.setCornerRadius(mCornerRadius);
        mIconImageView.setImageDrawable(roundedIcon);
    }
}
 
源代码18 项目: Yuan-SxMusic   文件: DiscView.java
/**
 * 得到唱盘图片
 * 唱盘图片由空心圆盘及音乐专辑图片“合成”得到
 */
public Drawable getDiscDrawable(Bitmap bitmap) {
    int discSize = (int) (mScreenWidth * DisplayUtil.SCALE_DISC_SIZE);
    int musicPicSize = (int) (mScreenWidth * DisplayUtil.SCALE_MUSIC_PIC_SIZE);

    Bitmap bitmapDisc = Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), R
            .drawable.ic_disc), discSize, discSize, false);
    Bitmap bitmapMusicPic = Bitmap.createScaledBitmap(bitmap, musicPicSize, musicPicSize, true);
    BitmapDrawable discDrawable = new BitmapDrawable(bitmapDisc);
    RoundedBitmapDrawable roundMusicDrawable = RoundedBitmapDrawableFactory.create
            (getResources(), bitmapMusicPic);

    //抗锯齿
    discDrawable.setAntiAlias(true);
    roundMusicDrawable.setAntiAlias(true);

    Drawable[] drawables = new Drawable[2];
    drawables[0] = roundMusicDrawable;
    drawables[1] = discDrawable;

    LayerDrawable layerDrawable = new LayerDrawable(drawables);
    int musicPicMargin = (int) ((DisplayUtil.SCALE_DISC_SIZE - DisplayUtil
            .SCALE_MUSIC_PIC_SIZE) * mScreenWidth / 2);
    //调整专辑图片的四周边距,让其显示在正中
    layerDrawable.setLayerInset(0, musicPicMargin, musicPicMargin, musicPicMargin,
            musicPicMargin);

    return layerDrawable;
}
 
源代码19 项目: LaunchEnr   文件: RoundedContact.java
static RoundedBitmapDrawable get(Activity activity, Uri thumbnail) {

        RoundedBitmapDrawable dr = null;

        try {
            Bitmap bitmap = MediaStore.Images.Media.getBitmap(activity.getContentResolver(), thumbnail);
            dr = RoundedBitmapDrawableFactory.create(activity.getResources(), bitmap);
            dr.setCircular(true);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dr;
    }
 
源代码20 项目: Password-Storage   文件: MainActivity.java
private RoundedBitmapDrawable createRoundedBitmapImageDrawableWithBorder(Bitmap bitmap){
    int bitmapWidthImage = bitmap.getWidth();
    int bitmapHeightImage = bitmap.getHeight();
    int borderWidthHalfImage = 4;

    int bitmapRadiusImage = Math.min(bitmapWidthImage,bitmapHeightImage)/2;
    int bitmapSquareWidthImage = Math.min(bitmapWidthImage,bitmapHeightImage);
    int newBitmapSquareWidthImage = bitmapSquareWidthImage+borderWidthHalfImage;

    Bitmap roundedImageBitmap = Bitmap.createBitmap(newBitmapSquareWidthImage,newBitmapSquareWidthImage,Bitmap.Config.ARGB_8888);
    Canvas mcanvas = new Canvas(roundedImageBitmap);
    mcanvas.drawColor(Color.RED);
    int i = borderWidthHalfImage + bitmapSquareWidthImage - bitmapWidthImage;
    int j = borderWidthHalfImage + bitmapSquareWidthImage - bitmapHeightImage;

    mcanvas.drawBitmap(bitmap, i, j, null);

    Paint borderImagePaint = new Paint();
    borderImagePaint.setStyle(Paint.Style.STROKE);
    borderImagePaint.setStrokeWidth(borderWidthHalfImage*2);
    borderImagePaint.setColor(Color.GRAY);
    mcanvas.drawCircle(mcanvas.getWidth()/2, mcanvas.getWidth()/2, newBitmapSquareWidthImage/2, borderImagePaint);

    RoundedBitmapDrawable roundedImageBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(),roundedImageBitmap);
    roundedImageBitmapDrawable.setCornerRadius(bitmapRadiusImage);
    roundedImageBitmapDrawable.setAntiAlias(true);
    return roundedImageBitmapDrawable;
}
 
源代码21 项目: MediaNotification   文件: AppIconView.java
private Bitmap getRoundBitmap(@DrawableRes int drawable, int size) {
    Bitmap bitmap = ImageUtils.drawableToBitmap(ContextCompat.getDrawable(getContext(), drawable));
    bitmap = Bitmap.createBitmap(bitmap, bitmap.getWidth() / 6, bitmap.getHeight() / 6, (int) (0.666 * bitmap.getWidth()), (int) (0.666 * bitmap.getHeight()));
    bitmap = ThumbnailUtils.extractThumbnail(bitmap, size, size);

    RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), bitmap);

    roundedBitmapDrawable.setCornerRadius(size / 2);
    roundedBitmapDrawable.setAntiAlias(true);

    return ImageUtils.drawableToBitmap(roundedBitmapDrawable);
}
 
源代码22 项目: Hillffair17   文件: LeaderBoardAdapter.java
@Override
public void onBindViewHolder(LeaderBoardViewHolder holder, int position) {
    LeaderBoardActivity.LeaderBoardUserModel user=users.get(position);

    holder.username.setText(user.getName().toString());
    holder.score.setText("Score: "+Integer.toString(user.getSets().getScore()));
    Glide.with(context).load(user.getPhoto()).into(holder.photo);

    final ImageView imageView=holder.photo;

    Glide.with(context).load(user.getPhoto()).asBitmap().centerCrop().into(new BitmapImageViewTarget(imageView) {
        @Override
        protected void setResource(Bitmap resource) {
            RoundedBitmapDrawable circularBitmapDrawable =
                    RoundedBitmapDrawableFactory.create(context.getResources(), resource);
            circularBitmapDrawable.setCircular(true);
            imageView.setImageDrawable(circularBitmapDrawable);
        }
    });

    Integer prsnlscore = user.getSets().getScore();
    if(prsnlscore>=800) holder.useraward.setImageResource(R.drawable.trophy_gold);
    else if(prsnlscore>=600) holder.useraward.setImageResource(R.drawable.trophy_silver);
    else if(prsnlscore>=450) holder.useraward.setImageResource(R.drawable.trophy_bronze);
    else if(prsnlscore>=300) holder.useraward.setImageResource(R.drawable.trophy_goldbadge);
    else if(prsnlscore>=150) holder.useraward.setImageResource(R.drawable.trophy_silverbadge);
    else if(prsnlscore>0) holder.useraward.setImageResource(R.drawable.trophy_bronzebadge);
    else if(prsnlscore==0) holder.useraward.setImageResource(R.drawable.trophy_participation);
    holder.sets.setText("Sets: "+Integer.toString(user.getSets().getSets()));
}
 
源代码23 项目: Nimbus   文件: LeaderBoardAdapter.java
@Override
public void onBindViewHolder(LeaderBoardViewHolder holder, int position) {
    LeaderBoardActivity.LeaderBoardUserModel user=users.get(position);

    holder.username.setText(user.getName().toString());
    holder.score.setText("Score: "+Integer.toString(user.getSets().getScore()));
    Glide.with(context).load(user.getPhoto()).into(holder.photo);

    final ImageView imageView=holder.photo;

    Glide.with(context).load(user.getPhoto()).asBitmap().centerCrop().into(new BitmapImageViewTarget(imageView) {
        @Override
        protected void setResource(Bitmap resource) {
            RoundedBitmapDrawable circularBitmapDrawable =
                    RoundedBitmapDrawableFactory.create(context.getResources(), resource);
            circularBitmapDrawable.setCircular(true);
            imageView.setImageDrawable(circularBitmapDrawable);
        }
    });

    Integer prsnlscore = user.getSets().getScore();
    if(prsnlscore>=800) holder.useraward.setImageResource(R.drawable.trophy_gold);
    else if(prsnlscore>=600) holder.useraward.setImageResource(R.drawable.trophy_silver);
    else if(prsnlscore>=450) holder.useraward.setImageResource(R.drawable.trophy_bronze);
    else if(prsnlscore>=300) holder.useraward.setImageResource(R.drawable.trophy_goldbadge);
    else if(prsnlscore>=150) holder.useraward.setImageResource(R.drawable.trophy_silverbadge);
    else if(prsnlscore>0) holder.useraward.setImageResource(R.drawable.trophy_bronzebadge);
    else if(prsnlscore==0) holder.useraward.setImageResource(R.drawable.trophy_participation);
    holder.sets.setText("Sets: "+Integer.toString(user.getSets().getSets()));
}
 
源代码24 项目: android-topeka   文件: AvatarView.java
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);
}
 
源代码25 项目: Cleaner   文件: AppIconView.java
private Bitmap getRoundBitmap(@DrawableRes int drawable, int size) {
    Bitmap bitmap = ImageUtils.drawableToBitmap(ContextCompat.getDrawable(getContext(), drawable));
    bitmap = Bitmap.createBitmap(bitmap, bitmap.getWidth() / 6, bitmap.getHeight() / 6, (int) (0.666 * bitmap.getWidth()), (int) (0.666 * bitmap.getHeight()));
    bitmap = ThumbnailUtils.extractThumbnail(bitmap, size, size);

    RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), bitmap);

    roundedBitmapDrawable.setCornerRadius(size / 2);
    roundedBitmapDrawable.setAntiAlias(true);

    return ImageUtils.drawableToBitmap(roundedBitmapDrawable);
}
 
源代码26 项目: YalpStore   文件: LoadCircularImageTask.java
@Override
protected Drawable getDrawable(Bitmap bitmap) {
    if (cropCircle) {
        RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(imageView.getResources(), bitmap);
        roundedBitmapDrawable.setCircular(true);
        roundedBitmapDrawable.setAntiAlias(true);
        return roundedBitmapDrawable;
    } else {
        return super.getDrawable(bitmap);
    }
}
 
源代码27 项目: TouchNews   文件: ImageUtil.java
public static void displayCircularImage(final Context context, String url, final ImageView imageView) {
    Glide.with(context).load(url).asBitmap().centerCrop().into(new BitmapImageViewTarget(imageView) {
        @Override
        protected void setResource(Bitmap resource) {
            RoundedBitmapDrawable circularBitmapDrawable =
                RoundedBitmapDrawableFactory.create(context.getResources(), resource);
            circularBitmapDrawable.setCircular(true);
            imageView.setImageDrawable(circularBitmapDrawable);

        }
    });
}
 
源代码28 项目: delion   文件: BookmarkItemRow.java
@Override
public void onLargeIconAvailable(Bitmap icon, int fallbackColor) {
    if (icon == null) {
        mIconGenerator.setBackgroundColor(fallbackColor);
        icon = mIconGenerator.generateIconForUrl(mUrl);
        mIconImageView.setImageDrawable(new BitmapDrawable(getResources(), icon));
    } else {
        RoundedBitmapDrawable roundedIcon = RoundedBitmapDrawableFactory.create(
                getResources(),
                Bitmap.createScaledBitmap(icon, mDisplayedIconSize, mDisplayedIconSize, false));
        roundedIcon.setCornerRadius(mCornerRadius);
        mIconImageView.setImageDrawable(roundedIcon);
    }
}
 
private Drawable getFaviconDrawable(Bitmap icon, int fallbackColor, String url) {
    if (icon == null) {
        mIconGenerator.setBackgroundColor(fallbackColor);
        icon = mIconGenerator.generateIconForUrl(url);
        return new BitmapDrawable(getResources(), icon);
    } else {
        RoundedBitmapDrawable roundedIcon =
                RoundedBitmapDrawableFactory.create(getResources(),
                        Bitmap.createScaledBitmap(icon, mFaviconSize, mFaviconSize, false));
        roundedIcon.setCornerRadius(mCornerRadius);
        return roundedIcon;
    }
}
 
源代码30 项目: Pasta-Music   文件: CircleImageView.java
@Override
public void onDraw(Canvas canvas) {
    Bitmap image = ImageUtils.drawableToBitmap(getDrawable());
    if (image != null) {
        int size = Math.min(getWidth(), getHeight());
        image = ThumbnailUtils.extractThumbnail(image, size, size);

        RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), image);

        roundedBitmapDrawable.setCornerRadius(size / 2);
        roundedBitmapDrawable.setAntiAlias(true);

        canvas.drawBitmap(ImageUtils.drawableToBitmap(roundedBitmapDrawable), 0, 0, paint);
    }
}