Example usage for android.support.v4.graphics.drawable RoundedBitmapDrawable setAntiAlias

List of usage examples for android.support.v4.graphics.drawable RoundedBitmapDrawable setAntiAlias

Introduction

In this page you can find the example usage for android.support.v4.graphics.drawable RoundedBitmapDrawable setAntiAlias.

Prototype

public void setAntiAlias(boolean z) 

Source Link

Usage

From source file:io.nuclei.cyto.ui.view.GlideImageView.java

@Override
public void setImageDrawable(Drawable drawable) {
    if (mCircle && drawable instanceof BitmapDrawable) {
        Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
        RoundedBitmapDrawable d = RoundedBitmapDrawableFactory.create(getResources(), bitmap);
        d.setCornerRadius(d.getIntrinsicWidth() / 2);
        d.setAntiAlias(true);
        drawable = d;/*  w  w w.  j  av  a 2  s . co m*/
    }
    super.setImageDrawable(drawable);
    if (mListener != null)
        mListener.onDrawable(drawable);
}

From source file:com.android.contacts.common.list.ShortcutIntentBuilder.java

private Bitmap generateQuickContactIcon(Drawable photo) {

    // Setup the drawing classes
    Bitmap bitmap = Bitmap.createBitmap(mIconSize, mIconSize, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);

    // Copy in the photo
    Rect dst = new Rect(0, 0, mIconSize, mIconSize);
    photo.setBounds(dst);/*from   ww  w  .j  ava  2s. c om*/
    photo.draw(canvas);

    // Draw the icon with a rounded border
    RoundedBitmapDrawable roundedDrawable = RoundedBitmapDrawableFactory.create(mResources, bitmap);
    roundedDrawable.setAntiAlias(true);
    roundedDrawable.setCornerRadius(mIconSize / 2);
    Bitmap roundedBitmap = Bitmap.createBitmap(mIconSize, mIconSize, Bitmap.Config.ARGB_8888);
    canvas.setBitmap(roundedBitmap);
    roundedDrawable.setBounds(dst);
    roundedDrawable.draw(canvas);
    canvas.setBitmap(null);

    return roundedBitmap;
}

From source file:com.android.contacts.ShortcutIntentBuilder.java

private Bitmap generateQuickContactIcon(Drawable photo) {
    // Setup the drawing classes
    Bitmap bitmap = Bitmap.createBitmap(mIconSize, mIconSize, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);

    // Copy in the photo
    Rect dst = new Rect(0, 0, mIconSize, mIconSize);
    photo.setBounds(dst);/*from w ww  .  j  a v a2 s . com*/
    photo.draw(canvas);

    // Don't put a rounded border on an icon for O
    if (BuildCompat.isAtLeastO()) {
        return bitmap;
    }

    // Draw the icon with a rounded border
    RoundedBitmapDrawable roundedDrawable = RoundedBitmapDrawableFactory.create(mResources, bitmap);
    roundedDrawable.setAntiAlias(true);
    roundedDrawable.setCornerRadius(mIconSize / 2);
    Bitmap roundedBitmap = Bitmap.createBitmap(mIconSize, mIconSize, Bitmap.Config.ARGB_8888);
    canvas.setBitmap(roundedBitmap);
    roundedDrawable.setBounds(dst);
    roundedDrawable.draw(canvas);
    canvas.setBitmap(null);

    return roundedBitmap;
}

From source file:arun.com.chromer.fragments.AboutFragment.java

private void populateData(View rootView) {
    ListView chromerList = (ListView) rootView.findViewById(R.id.about_app_version_list);
    ListView authorList = (ListView) rootView.findViewById(R.id.about_author_version_list);

    View daniel = rootView.findViewById(R.id.daniel);
    daniel.setOnClickListener(new View.OnClickListener() {
        @Override//ww w . j  a v  a  2  s. c o m
        public void onClick(View v) {
            Intent googleIntent = new Intent(Intent.ACTION_VIEW,
                    Uri.parse("https://plus.google.com/u/0/+DanielCiao/about"));
            getActivity().startActivity(googleIntent);
        }
    });

    // Loading the header
    chromerList.setAdapter(new ExtendedBaseAdapter() {
        final Context context = getActivity().getApplicationContext();

        @Override
        public int getCount() {
            return 4;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            LayoutInflater mInflater = (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            ViewHolder holder;
            if (convertView == null) {
                holder = new ViewHolder();
                convertView = mInflater.inflate(R.layout.fragment_about_listview_template, parent, false);
                holder.imageView = (ImageView) convertView.findViewById(R.id.about_row_item_image);
                holder.subtitle = (TextView) convertView.findViewById(R.id.about_app_subtitle);
                holder.title = (TextView) convertView.findViewById(R.id.about_app_title);
                convertView.setTag(holder);
            } else {
                holder = (ViewHolder) convertView.getTag();
            }
            int materialdarkColor = ContextCompat.getColor(context, R.color.accent);
            holder.subtitle.setVisibility(View.VISIBLE);
            switch (position) {
            case 0:
                holder.title.setText(R.string.version);
                holder.subtitle.setText(Util.getPackageVersion(context));
                holder.imageView.setBackground(new IconicsDrawable(context)
                        .icon(GoogleMaterial.Icon.gmd_info_outline).color(materialdarkColor).sizeDp(24));
                break;
            case 1:
                holder.title.setText(R.string.changelog);
                holder.subtitle.setVisibility(View.GONE);
                holder.imageView.setBackground(new IconicsDrawable(context)
                        .icon(GoogleMaterial.Icon.gmd_track_changes).color(materialdarkColor).sizeDp(24));
                break;
            case 2:
                holder.title.setText(R.string.join_google_plus);
                holder.subtitle.setText(R.string.share_ideas);
                holder.imageView.setBackground(
                        new IconicsDrawable(context).icon(CommunityMaterial.Icon.cmd_google_circles_communities)
                                .color(materialdarkColor).sizeDp(24));
                break;
            case 3:
                holder.title.setText(R.string.licenses);
                holder.subtitle.setVisibility(View.GONE);
                holder.imageView.setBackground(new IconicsDrawable(context)
                        .icon(GoogleMaterial.Icon.gmd_card_membership).color(materialdarkColor).sizeDp(24));
                break;
            }
            return convertView;
        }
    });

    authorList.setAdapter(new ExtendedBaseAdapter() {
        final Context context = getActivity().getApplicationContext();

        @Override
        public int getCount() {
            return 5;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            LayoutInflater mInflater = (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            final ViewHolder holder;
            if (convertView == null) {
                holder = new ViewHolder();
                convertView = mInflater.inflate(R.layout.fragment_about_listview_template, parent, false);
                holder.imageView = (ImageView) convertView.findViewById(R.id.about_row_item_image);
                holder.subtitle = (TextView) convertView.findViewById(R.id.about_app_subtitle);
                holder.title = (TextView) convertView.findViewById(R.id.about_app_title);
                convertView.setTag(holder);
            } else {
                holder = (ViewHolder) convertView.getTag();
            }
            switch (position) {
            case 0:
                holder.title.setText(StringConstants.ME);
                holder.subtitle.setText(StringConstants.LOCATION);
                holder.imageView.getLayoutParams().height = (int) getResources()
                        .getDimension(R.dimen.arun_height);
                holder.imageView.getLayoutParams().width = (int) getResources()
                        .getDimension(R.dimen.arun_width);
                Bitmap imageBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.arun);
                RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory
                        .create(getResources(), imageBitmap);
                roundedBitmapDrawable.setAntiAlias(true);
                roundedBitmapDrawable.setCircular(true);
                holder.imageView.setImageDrawable(roundedBitmapDrawable);
                break;
            case 1:
                holder.title.setText(R.string.add_to_circles);
                holder.subtitle.setVisibility(View.GONE);
                holder.imageView.setBackground(
                        new IconicsDrawable(context).icon(CommunityMaterial.Icon.cmd_google_circles)
                                .color(ContextCompat.getColor(getActivity(), R.color.google_plus)).sizeDp(24));
                break;
            case 2:
                holder.title.setText(R.string.follow_twitter);
                holder.subtitle.setVisibility(View.GONE);
                holder.imageView
                        .setBackground(new IconicsDrawable(context).icon(CommunityMaterial.Icon.cmd_twitter)
                                .color(ContextCompat.getColor(getActivity(), R.color.twitter)).sizeDp(24));
                break;
            case 3:
                holder.title.setText(R.string.connect_linkedIn);
                holder.subtitle.setVisibility(View.GONE);
                holder.imageView.setBackground(
                        new IconicsDrawable(context).icon(CommunityMaterial.Icon.cmd_linkedin_box)
                                .color(ContextCompat.getColor(getActivity(), R.color.linkedin)).sizeDp(24));
                break;
            case 4:
                holder.title.setText(R.string.more_apps);
                holder.subtitle.setVisibility(View.GONE);
                holder.imageView.setBackground(new IconicsDrawable(context)
                        .icon(CommunityMaterial.Icon.cmd_google_play)
                        .color(ContextCompat.getColor(getActivity(), R.color.playstore_green)).sizeDp(24));
                break;
            }
            return convertView;
        }
    });

    chromerList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
            case 0:
                return;
            case 1:
                ChangelogUtil.showChangelogDialog(getActivity());
                break;
            case 2:
                Intent googleIntent = new Intent(Intent.ACTION_VIEW,
                        Uri.parse("https://plus.google.com/communities/109754631011301174504"));
                getActivity().startActivity(googleIntent);
                break;
            case 3:
                new LicensesDialog.Builder(getActivity()).setNotices(Licenses.getNotices())
                        .setTitle(R.string.licenses).build().showAppCompat();
                break;
            }
        }
    });

    authorList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
            case 0:
                return;
            case 1:
                Intent googleIntent = new Intent(Intent.ACTION_VIEW,
                        Uri.parse("http://google.com/+arunkumar5592"));
                getActivity().startActivity(googleIntent);
                break;
            case 2:
                Intent twitterIntent = new Intent(Intent.ACTION_VIEW,
                        Uri.parse("https://twitter.com/arunkumar_9t2"));
                getActivity().startActivity(twitterIntent);
                break;
            case 3:
                Intent linkedinIntent = new Intent(Intent.ACTION_VIEW,
                        Uri.parse("http://in.linkedin.com/in/arunkumar9t2"));
                getActivity().startActivity(linkedinIntent);
                break;
            case 4:
                try {
                    getActivity().startActivity(
                            new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pub:Arunkumar")));
                } catch (android.content.ActivityNotFoundException anfe) {
                    getActivity().startActivity(new Intent(Intent.ACTION_VIEW,
                            Uri.parse("http://play.google.com/store/search?q=pub:Arunkumar")));
                }
                break;
            }
        }
    });

}

From source file:com.android.incallui.CallCardFragment.java

/**
 * Set all the ImageViews to the same photo. Currently there are 2 photo views: the large one
 * (which fills about the bottom half of the screen) and the small one, which displays as a
 * circle next to the primary contact info. This method does not handle whether the ImageView
 * is shown or not.//from w  ww  .j a v  a 2s .  c o  m
 *
 * @param photo The photo to set for the image views.
 */
private void setDrawableToImageViews(Drawable photo) {
    if (photo == null) {
        photo = ContactInfoCache.getInstance(getView().getContext()).getDefaultContactPhotoDrawable();
    }

    if (mPrimaryPhotoDrawable == photo) {
        return;
    }
    mPrimaryPhotoDrawable = photo;

    mPhotoLarge.setImageDrawable(photo);

    // Modify the drawable to be round for the smaller ImageView.
    Bitmap bitmap = drawableToBitmap(photo);
    if (bitmap != null) {
        final RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(getResources(), bitmap);
        drawable.setAntiAlias(true);
        drawable.setCornerRadius(bitmap.getHeight() / 2);
        photo = drawable;
    }
    mPhotoSmall.setImageDrawable(photo);
}

From source file:com.android.contacts.common.ContactPhotoManager.java

/**
 * Given a bitmap, returns a drawable that is configured to display the bitmap based on the
 * specified request.//from  www .j a va  2 s .co m
 */
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);
    }
}