Example usage for android.graphics Paint ANTI_ALIAS_FLAG

List of usage examples for android.graphics Paint ANTI_ALIAS_FLAG

Introduction

In this page you can find the example usage for android.graphics Paint ANTI_ALIAS_FLAG.

Prototype

int ANTI_ALIAS_FLAG

To view the source code for android.graphics Paint ANTI_ALIAS_FLAG.

Click Source Link

Document

Paint flag that enables antialiasing when drawing.

Usage

From source file:piuk.blockchain.android.ui.zxing.ViewfinderView.java

public ViewfinderView(Context context, AttributeSet attrs) {
    super(context, attrs);

    // Initialize these once for performance rather than calling them every time in onDraw().
    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    maskColor = ContextCompat.getColor(context, R.color.barcode_viewfinder_mask);
    resultColor = ContextCompat.getColor(context, R.color.barcode_result_view);
    laserColor = ContextCompat.getColor(context, R.color.barcode_viewfinder_laser);
    resultPointColor = ContextCompat.getColor(context, R.color.barcode_possible_result_points);
    scannerAlpha = 0;//from   w  ww  . j a  va2 s.c o m
    possibleResultPoints = new ArrayList<>(5);
    lastPossibleResultPoints = null;
}

From source file:com.Duo.music.player.Dialogs.CautionEditArtistsDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    parentActivity = getActivity();//from ww  w.  j a v  a2s. c o m
    dialogFragment = this;

    EDIT_TYPE = this.getArguments().getString("EDIT_TYPE");
    ARTIST = this.getArguments().getString("ARTIST");

    rootView = (View) parentActivity.getLayoutInflater().inflate(R.layout.fragment_caution_edit_artists, null);

    cautionText = (TextView) rootView.findViewById(R.id.caution_text);
    cautionText.setText(R.string.caution_artists_text);
    cautionText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    cautionText.setPaintFlags(cautionText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    sharedPreferences = getActivity().getSharedPreferences("com.jams.music.player", Context.MODE_PRIVATE);
    sharedPreferences.edit().putBoolean("SHOW_ARTIST_EDIT_CAUTION", false).commit();

    dontShowAgainText = (TextView) rootView.findViewById(R.id.dont_show_again_text);
    dontShowAgainText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    dontShowAgainText.setPaintFlags(
            dontShowAgainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    dontShowAgainCheckbox = (CheckBox) rootView.findViewById(R.id.dont_show_again_checkbox);
    dontShowAgainCheckbox.setChecked(true);

    dontShowAgainCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton arg0, boolean isChecked) {

            if (isChecked == true) {
                sharedPreferences.edit().putBoolean("SHOW_ARTIST_EDIT_CAUTION", false).commit();
            } else {
                sharedPreferences.edit().putBoolean("SHOW_ARTIST_EDIT_CAUTION", true).commit();
            }

        }

    });

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    //Set the dialog title.
    builder.setTitle(R.string.caution);
    builder.setView(rootView);
    builder.setNegativeButton(R.string.no, new OnClickListener() {

        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            dialogFragment.dismiss();

        }

    });

    builder.setPositiveButton(R.string.yes, new OnClickListener() {

        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            dialogFragment.dismiss();

            FragmentTransaction ft = getFragmentManager().beginTransaction();
            Bundle bundle = new Bundle();
            bundle.putString("EDIT_TYPE", EDIT_TYPE);
            bundle.putString("ARTIST", ARTIST);
            ID3sArtistEditorDialog dialog = new ID3sArtistEditorDialog();
            dialog.setArguments(bundle);
            dialog.show(ft, "id3ArtistEditorDialog");

        }

    });

    return builder.create();
}

From source file:com.adityarathi.muo.ui.fragments.BuildingLibraryProgressFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    mContext = getActivity().getApplicationContext();
    mApp = (Common) mContext;//from w ww .j  a  v  a2 s.c  o m
    mRootView = (View) getActivity().getLayoutInflater().inflate(R.layout.fragment_building_library_progress,
            null);

    mProgressElementsContainer = (RelativeLayout) mRootView.findViewById(R.id.progress_elements_container);
    mProgressElementsContainer.setVisibility(View.INVISIBLE);

    mCurrentTaskText = (TextView) mRootView.findViewById(R.id.building_library_task);
    mCurrentTaskText
            .setPaintFlags(mCurrentTaskText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    mProgressBar = (ProgressBar) mRootView.findViewById(R.id.building_library_progress);
    mProgressBar.setMax(1000000);

    mFadeInAnimation = AnimationUtils.loadAnimation(mContext, R.anim.fade_in);
    mFadeInAnimation.setAnimationListener(fadeInListener);
    mFadeInAnimation.setDuration(700);

    return mRootView;
}

From source file:com.jelly.music.player.Dialogs.CautionEditArtistsDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    parentActivity = getActivity();//from  w w w .  j a  v  a  2 s. co  m
    dialogFragment = this;

    EDIT_TYPE = this.getArguments().getString("EDIT_TYPE");
    ARTIST = this.getArguments().getString("ARTIST");

    rootView = (View) parentActivity.getLayoutInflater().inflate(R.layout.fragment_caution_edit_artists, null);

    cautionText = (TextView) rootView.findViewById(R.id.caution_text);
    cautionText.setText(R.string.caution_artists_text);
    cautionText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    cautionText.setPaintFlags(cautionText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    sharedPreferences = getActivity().getSharedPreferences("com.jelly.music.player", Context.MODE_PRIVATE);
    sharedPreferences.edit().putBoolean("SHOW_ARTIST_EDIT_CAUTION", false).commit();

    dontShowAgainText = (TextView) rootView.findViewById(R.id.dont_show_again_text);
    dontShowAgainText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    dontShowAgainText.setPaintFlags(
            dontShowAgainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    dontShowAgainCheckbox = (CheckBox) rootView.findViewById(R.id.dont_show_again_checkbox);
    dontShowAgainCheckbox.setChecked(true);

    dontShowAgainCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton arg0, boolean isChecked) {

            if (isChecked == true) {
                sharedPreferences.edit().putBoolean("SHOW_ARTIST_EDIT_CAUTION", false).commit();
            } else {
                sharedPreferences.edit().putBoolean("SHOW_ARTIST_EDIT_CAUTION", true).commit();
            }

        }

    });

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    //Set the dialog title.
    builder.setTitle(R.string.caution);
    builder.setView(rootView);
    builder.setNegativeButton(R.string.no, new OnClickListener() {

        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            dialogFragment.dismiss();

        }

    });

    builder.setPositiveButton(R.string.yes, new OnClickListener() {

        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            dialogFragment.dismiss();

            FragmentTransaction ft = getFragmentManager().beginTransaction();
            Bundle bundle = new Bundle();
            bundle.putString("EDIT_TYPE", EDIT_TYPE);
            bundle.putString("ARTIST", ARTIST);
            ID3sArtistEditorDialog dialog = new ID3sArtistEditorDialog();
            dialog.setArguments(bundle);
            dialog.show(ft, "id3ArtistEditorDialog");

        }

    });

    return builder.create();
}

From source file:com.mwm.loyal.libs.zxing.ViewfinderView.java

public ViewfinderView(Context context, AttributeSet attrs) {
    super(context, attrs);

    // Initialize these once for performance rather than calling them every time in onDraw().
    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    maskColor = ContextCompat.getColor(getContext(), R.color.viewfinder_mask);
    resultColor = ContextCompat.getColor(getContext(), R.color.result_view);
    laserColor = ContextCompat.getColor(getContext(), R.color.viewfinder_laser);
    resultPointColor = ContextCompat.getColor(getContext(), R.color.possible_result_points);
    scannerAlpha = 0;/*  w w w.ja  va 2 s  .  co m*/
    possibleResultPoints = new ArrayList<>(5);
    lastPossibleResultPoints = null;
}

From source file:com.android.deskclock.timer.TimerView.java

/**
 * Measure the text and add a start padding to the view
 * @param textView view to measure and onb to which add start padding
 *///from   ww w.  ja  va  2 s .c o  m
private void addStartPadding(TextView textView) {
    final float gapPadding = 0.45f;
    // allDigits will contain ten digits: "0123456789" in the default locale
    String allDigits = String.format(Locale.getDefault(), "%010d", 123456789);
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setTextSize(textView.getTextSize());
    paint.setTypeface(textView.getTypeface());

    float widths[] = new float[allDigits.length()];
    int ll = paint.getTextWidths(allDigits, widths);
    int largest = 0;
    for (int ii = 1; ii < ll; ii++) {
        if (widths[ii] > widths[largest]) {
            largest = ii;
        }
    }
    // Add left padding to the view - Note: layout inherits LTR
    textView.setPadding((int) (gapPadding * widths[largest]), 0, 0, 0);
}

From source file:com.aniruddhc.acemusic.player.Dialogs.CautionEditArtistsDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    parentActivity = getActivity();//from   ww  w. j av  a2  s.c o m
    dialogFragment = this;

    EDIT_TYPE = this.getArguments().getString("EDIT_TYPE");
    ARTIST = this.getArguments().getString("ARTIST");

    rootView = (View) parentActivity.getLayoutInflater().inflate(R.layout.fragment_caution_edit_artists, null);

    cautionText = (TextView) rootView.findViewById(R.id.caution_text);
    cautionText.setText(R.string.caution_artists_text);
    cautionText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    cautionText.setPaintFlags(cautionText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    sharedPreferences = getActivity().getSharedPreferences("com.aniruddhc.acemusic.player",
            Context.MODE_PRIVATE);
    sharedPreferences.edit().putBoolean("SHOW_ARTIST_EDIT_CAUTION", false).commit();

    dontShowAgainText = (TextView) rootView.findViewById(R.id.dont_show_again_text);
    dontShowAgainText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    dontShowAgainText.setPaintFlags(
            dontShowAgainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    dontShowAgainCheckbox = (CheckBox) rootView.findViewById(R.id.dont_show_again_checkbox);
    dontShowAgainCheckbox.setChecked(true);

    dontShowAgainCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton arg0, boolean isChecked) {

            if (isChecked == true) {
                sharedPreferences.edit().putBoolean("SHOW_ARTIST_EDIT_CAUTION", false).commit();
            } else {
                sharedPreferences.edit().putBoolean("SHOW_ARTIST_EDIT_CAUTION", true).commit();
            }

        }

    });

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    //Set the dialog title.
    builder.setTitle(R.string.caution);
    builder.setView(rootView);
    builder.setNegativeButton(R.string.no, new OnClickListener() {

        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            dialogFragment.dismiss();

        }

    });

    builder.setPositiveButton(R.string.yes, new OnClickListener() {

        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            dialogFragment.dismiss();

            FragmentTransaction ft = getFragmentManager().beginTransaction();
            Bundle bundle = new Bundle();
            bundle.putString("EDIT_TYPE", EDIT_TYPE);
            bundle.putString("ARTIST", ARTIST);
            ID3sArtistEditorDialog dialog = new ID3sArtistEditorDialog();
            dialog.setArguments(bundle);
            dialog.show(ft, "id3ArtistEditorDialog");

        }

    });

    return builder.create();
}

From source file:com.mlxing.mlguide.adapter.base.recyclerview.DividerItemDecoration.java

/**
 * /*from w  ww . j a va 2 s .c  o m*/
 *
 * @param context
 * @param orientation   ?
 * @param dividerHeight 
 * @param dividerColor  
 */
public DividerItemDecoration(Context context, int orientation, int dividerHeight, int dividerColor) {
    this(context, orientation);
    mDividerHeight = dividerHeight;
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setColor(dividerColor);
    mPaint.setStyle(Paint.Style.FILL);
}

From source file:com.androidmapsextensions.DefaultClusterOptionsProvider.java

private Paint createCirclePaint(Resources resources) {
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    blurRadius = resources.getDimension(R.dimen.ame_default_cluster_circle_blur_radius);
    if (blurRadius > 0.0f) {
        BlurMaskFilter maskFilter = new BlurMaskFilter(blurRadius, BlurMaskFilter.Blur.SOLID);
        paint.setMaskFilter(maskFilter);
    }// w  w  w.  j  a v a 2  s.  co m
    return paint;
}

From source file:org.telegram.ui.Cells.FeaturedStickerSetInfoCell.java

public FeaturedStickerSetInfoCell(Context context, int left) {
    super(context);

    if (botProgressPaint == null) {
        botProgressPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        botProgressPaint.setColor(0xffffffff);
        botProgressPaint.setStrokeCap(Paint.Cap.ROUND);
        botProgressPaint.setStyle(Paint.Style.STROKE);
    }/*from   w  w w  .ja v a 2  s . c o m*/
    botProgressPaint.setStrokeWidth(AndroidUtilities.dp(2));

    nameTextView = new TextView(context);
    // TODO
    nameTextView.setTextColor(ContextCompat.getColor(context, R.color.primary_text) /*0xff333333*/);
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17);
    nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    nameTextView.setEllipsize(TextUtils.TruncateAt.END);
    nameTextView.setSingleLine(true);
    addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT,
            Gravity.TOP | Gravity.LEFT, left, 8, 100, 0));

    infoTextView = new TextView(context);
    infoTextView.setTextColor(0xff8a8a8a);
    infoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    infoTextView.setEllipsize(TextUtils.TruncateAt.END);
    infoTextView.setSingleLine(true);
    addView(infoTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT,
            Gravity.TOP | Gravity.LEFT, left, 30, 100, 0));

    addButton = new TextView(context) {
        @Override
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);
            if (drawProgress || !drawProgress && progressAlpha != 0) {
                botProgressPaint.setAlpha(Math.min(255, (int) (progressAlpha * 255)));
                int x = getMeasuredWidth() - AndroidUtilities.dp(11);
                rect.set(x, AndroidUtilities.dp(3), x + AndroidUtilities.dp(8), AndroidUtilities.dp(8 + 3));
                canvas.drawArc(rect, angle, 220, false, botProgressPaint);
                invalidate((int) rect.left - AndroidUtilities.dp(2), (int) rect.top - AndroidUtilities.dp(2),
                        (int) rect.right + AndroidUtilities.dp(2), (int) rect.bottom + AndroidUtilities.dp(2));
                long newTime = System.currentTimeMillis();
                if (Math.abs(lastUpdateTime - System.currentTimeMillis()) < 1000) {
                    long delta = (newTime - lastUpdateTime);
                    float dt = 360 * delta / 2000.0f;
                    angle += dt;
                    angle -= 360 * (angle / 360);
                    if (drawProgress) {
                        if (progressAlpha < 1.0f) {
                            progressAlpha += delta / 200.0f;
                            if (progressAlpha > 1.0f) {
                                progressAlpha = 1.0f;
                            }
                        }
                    } else {
                        if (progressAlpha > 0.0f) {
                            progressAlpha -= delta / 200.0f;
                            if (progressAlpha < 0.0f) {
                                progressAlpha = 0.0f;
                            }
                        }
                    }
                }
                lastUpdateTime = newTime;
                invalidate();
            }
        }
    };
    addButton.setPadding(AndroidUtilities.dp(17), 0, AndroidUtilities.dp(17), 0);
    addButton.setGravity(Gravity.CENTER);
    addButton.setTextColor(0xffffffff);
    addButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    addButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    addView(addButton,
            LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, 28, Gravity.TOP | Gravity.RIGHT, 0, 16, 14, 0));
}