Example usage for android.graphics Typeface BOLD

List of usage examples for android.graphics Typeface BOLD

Introduction

In this page you can find the example usage for android.graphics Typeface BOLD.

Prototype

int BOLD

To view the source code for android.graphics Typeface BOLD.

Click Source Link

Usage

From source file:com.layer_net.stepindicator.StepIndicator.java

private void init(Context context, AttributeSet attributeSet) {

    initAttributes(context, attributeSet);

    paint = new Paint();
    pStoke = new Paint();
    pText = new Paint();
    paint.setColor(stepColor);// w ww. ja  v a2s. c o m
    paint.setFlags(Paint.ANTI_ALIAS_FLAG);
    paint.setStrokeWidth(lineWidth);
    pStoke.setColor(stepColor);
    pStoke.setStrokeWidth(strokeWidth);
    pStoke.setStyle(Paint.Style.STROKE);
    pStoke.setFlags(Paint.ANTI_ALIAS_FLAG);
    pText.setColor(textColor);
    pText.setTextSize(radius);
    pText.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
    pText.setTextAlign(Paint.Align.CENTER);
    pText.setFlags(Paint.ANTI_ALIAS_FLAG);
    setMinimumHeight(radius * 3);
    Color.colorToHSV(currentColor, hsvCurrent);
    Color.colorToHSV(backgroundColor, hsvBG);
    Color.colorToHSV(stepColor, hsvProgress);
    invalidate();
}

From source file:eu.power_switch.widget.provider.ReceiverWidgetProvider.java

@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    Log.d("Updating Receiver Widgets...");
    // Perform this loop procedure for each App Widget that belongs to this provider
    for (int i = 0; i < appWidgetIds.length; i++) {
        int appWidgetId = appWidgetIds[i];
        RemoteViews remoteViews = new RemoteViews(
                context.getResources().getString(eu.power_switch.shared.R.string.PACKAGE_NAME),
                R.layout.widget_receiver);

        try {//www  . ja  va 2  s .c  om
            ReceiverWidget receiverWidget = DatabaseHandler.getReceiverWidget(appWidgetId);
            Room room = DatabaseHandler.getRoom(receiverWidget.getRoomId());
            if (room != null) {
                Receiver receiver = DatabaseHandler.getReceiver(receiverWidget.getReceiverId());

                if (receiver != null) {
                    Apartment apartment = DatabaseHandler.getApartment(room.getApartmentId());
                    // update UI
                    remoteViews.setTextViewText(R.id.textView_receiver_widget_name,
                            apartment.getName() + ": " + room.getName() + ": " + receiver.getName());

                    LinkedList<Button> buttons = receiver.getButtons();

                    // remove all previous buttons
                    remoteViews.removeAllViews(R.id.linearlayout_receiver_widget);

                    // add buttons from database
                    int buttonOffset = 0;
                    for (Button button : buttons) {
                        // set button action
                        RemoteViews buttonView = new RemoteViews(
                                context.getResources().getString(eu.power_switch.shared.R.string.PACKAGE_NAME),
                                R.layout.widget_receiver_button_layout);
                        SpannableString s = new SpannableString(button.getName());
                        s.setSpan(new StyleSpan(Typeface.BOLD), 0, button.getName().length(), 0);
                        buttonView.setTextViewText(R.id.button_widget_universal, s);
                        if (SmartphonePreferencesHandler.getHighlightLastActivatedButton()
                                && receiver.getLastActivatedButtonId().equals(button.getId())) {
                            buttonView.setTextColor(R.id.button_widget_universal,
                                    ContextCompat.getColor(context, R.color.color_light_blue_a700));
                        }

                        PendingIntent intent = WidgetIntentReceiver.buildReceiverWidgetActionPendingIntent(
                                context, apartment, room, receiver, button, appWidgetId * 15 + buttonOffset);
                        buttonView.setOnClickPendingIntent(R.id.button_widget_universal, intent);

                        remoteViews.addView(R.id.linearlayout_receiver_widget, buttonView);
                        buttonOffset++;
                    }
                    remoteViews.setViewVisibility(R.id.linearlayout_receiver_widget, View.VISIBLE);
                } else {
                    remoteViews.setTextViewText(R.id.textView_receiver_widget_name,
                            context.getString(R.string.receiver_not_found));
                    remoteViews.removeAllViews(R.id.linearlayout_receiver_widget);
                    remoteViews.setViewVisibility(R.id.linearlayout_receiver_widget, View.GONE);
                }
            } else {
                remoteViews.setTextViewText(R.id.textView_receiver_widget_name,
                        context.getString(R.string.room_not_found));
                remoteViews.removeAllViews(R.id.linearlayout_receiver_widget);
                remoteViews.setViewVisibility(R.id.linearlayout_receiver_widget, View.GONE);
            }
        } catch (Exception e) {
            Log.e(e);
            remoteViews.setTextViewText(R.id.textView_receiver_widget_name,
                    context.getString(R.string.unknown_error));
            remoteViews.removeAllViews(R.id.linearlayout_receiver_widget);
            remoteViews.setViewVisibility(R.id.linearlayout_receiver_widget, View.GONE);
        }
        appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
    }
    super.onUpdate(context, appWidgetManager, appWidgetIds);
}

From source file:com.thatkawaiiguy.meleehandbook.adapter.SearchAdapter.java

private void highlightAndCut(String search, String originalText, TextView textView) {
    int startPos = originalText.toLowerCase().indexOf(search);
    int endPos = startPos + search.length();

    int wholeStart = originalText.toLowerCase().indexOf(" ", startPos - 100);
    if (wholeStart == -1)
        wholeStart = 0;/*from   w  w w  .  ja  v  a  2s. c  o  m*/

    if (originalText.substring(wholeStart, wholeStart + 1).equals(","))
        wholeStart += 1;

    int wholeEnd = originalText.toLowerCase().indexOf(" ",
            endPos + 100 < originalText.length() - 1 ? endPos + 100 : endPos - search.length() - 1);

    if (wholeEnd == -1)
        wholeEnd = endPos;

    originalText = originalText.substring(wholeStart, wholeEnd).trim() + " (Click for more)";

    startPos = originalText.toLowerCase().indexOf(search);
    endPos = startPos + search.length();
    // This should always be true, just a sanity check
    if (startPos != -1) {
        Spannable spannable = new SpannableString(originalText);
        ColorStateList yellowColor = new ColorStateList(new int[][] { new int[] {} },
                new int[] { ContextCompat.getColor(mContext, R.color.overscroll_color) });
        TextAppearanceSpan highlightSpan = new TextAppearanceSpan(null, Typeface.BOLD, -1, yellowColor, null);

        spannable.setSpan(highlightSpan, startPos, endPos, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        textView.setText(spannable);
    } else
        textView.setText(originalText);
}

From source file:eu.geopaparazzi.mapsforge.sourcesview.SourcesExpandableListAdapter.java

public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
    String folder = (String) getGroup(groupPosition);
    if (convertView == null) {
        LayoutInflater infalInflater = (LayoutInflater) this.activity
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = infalInflater.inflate(R.layout.sources_list_header, null);
    }//  w  w w . j  a  va2s .  c  o  m

    TextView folderName = (TextView) convertView.findViewById(R.id.sources_header_descriptiontext);
    folderName.setTypeface(null, Typeface.BOLD);
    folderName.setText(folder);
    return convertView;
}

From source file:com.openerp.addons.idea.product.java

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    setHasOptionsMenu(true);//from  w  ww . j av a 2  s  .c om

    View rootView = inflater.inflate(R.layout.fragment_productlist, container, false);

    getActivity().setTitle(R.string.label_product);

    if (db().isEmptyTable()) {
        IdeaDemoRecords rec = new IdeaDemoRecords(getActivity());
        rec.createDemoRecords();
    }
    //INTERNAL 
    MainActivity.global = 2;
    OEHelper.check_for_product_from_where = 0;
    TextView txv4 = (TextView) rootView.findViewById(R.id.textView1);
    Typeface font = Typeface.createFromAsset(getActivity().getAssets(), "fonts/Georgia.ttf");
    txv4.setTypeface(font, Typeface.BOLD);
    mListView = (ListView) rootView.findViewById(R.id.listview);

    oehelper = new OEHelper(getActivity());

    btn = (Button) rootView.findViewById(R.id.barcode);

    List<String> k = oehelper.product_name();

    //   oehelper.releted_selected_stock_location_id();

    mListView.setAdapter(new ArrayAdapter<String>(getActivity(), R.layout.fragment_product_bind_item,
            OEHelper.datatemplate) {

        public View getView(int position, View convertView, ViewGroup parent) {
            View mView = convertView;

            if (mView == null)
                mView = getActivity().getLayoutInflater().inflate(R.layout.fragment_product_bind_item, parent,
                        false);
            TextView txv = (TextView) mView.findViewById(R.id.tx_productname);
            TextView txv4 = (TextView) mView.findViewById(R.id.textView1);
            TextView txv5 = (TextView) mView.findViewById(R.id.textView2);
            txv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
            Typeface font = Typeface.createFromAsset(getActivity().getAssets(), "fonts/Georgia.ttf");
            txv.setTypeface(font, Typeface.BOLD);
            txv4.setTypeface(font, Typeface.BOLD);
            txv5.setTypeface(font);
            //   txv.setTextColor(Color.rgb(84, 84, 84));
            txv.setText(":" + OEHelper.datatemplate.get(position));
            // txv.setText(""+OEHelper.product_pty_stock_move);
            //            txv.setTextAppearance(getActivity(),
            //                  android.R.attr.textAppearance);
            TextView txv1 = (TextView) mView.findViewById(R.id.tx_reference);
            txv1.setTextSize(TypedValue.COMPLEX_UNIT_SP, 11);

            txv1.setTypeface(font);
            //   txv1.setTextColor(Color.rgb(84, 84, 84));
            txv1.setText(":" + OEHelper.default_code_of_product_product.get(position));
            //            txv1.setTextAppearance(getActivity(),
            //                  android.R.attr.textAppearance);
            // txv.setText("Product");
            Log.d("row***************" + OEHelper.data, "*************");
            return mView;
        }
    });
    btn.setOnClickListener(new OnClickListener() {

        public void onClick(View arg0) {

            OEHelper oehelper1 = new OEHelper(getActivity());
            List<String> p = oehelper1.readproducttempalate();
            checkqtycallornot = 0;
            productQR_scan_from_scandit detail = new productQR_scan_from_scandit();
            FragmentListener frag = (FragmentListener) getActivity();
            frag.startDetailFragment(detail);

            // barcoderead.EAN13_code=("2100002000003");
            // String selected=barcoderead.EAN13_code;
            // int
            // indexofbarcodeproduct=OEHelper.ean13_of_product_product.indexOf(selected);
            // //String
            // idofproduct=MainActivity.idofproduct_product.get(indexofbarcodeproduct);
            //
            // String
            // sale_price_of_product_template=OEHelper.list_price_of_product_template.get(indexofbarcodeproduct);
            // String
            // cost_price_of_product_template=OEHelper.standard_price_of_product_template.get(indexofbarcodeproduct);
            // String
            // ean13_of_product_product1=OEHelper.ean13_of_product_product.get(indexofbarcodeproduct);
            // String
            // reference_of_product_product1=OEHelper.default_code_of_product_product.get(indexofbarcodeproduct);
            // String
            // type_Of_product_template=OEHelper.type_of_product_template.get(indexofbarcodeproduct);
            // String
            // supply_method_product_template1=OEHelper.supply_method_product_template.get(indexofbarcodeproduct);
            // String
            // procure_method_product_template1=OEHelper.procure_method_product_template.get(indexofbarcodeproduct);
            // image_of_produc1t=OEHelper.image_of_product.get(indexofbarcodeproduct);
            //
            // oeh.menufecturingData();
            // // Toast.makeText(getActivity(),
            // ""+MainActivity.getidfrom_product_product, 60).show();
            // Product_Detail detail =new Product_Detail();
            // Bundle args = new Bundle();
            // // args.putParcelable("BundleIcon", image_of_produc1t);
            // args.putString("name",
            // MainActivity.data.get(indexofbarcodeproduct));
            // args.putString("saleprice", sale_price_of_product_template);
            // args.putString("type", type_Of_product_template);
            // args.putString("reference", reference_of_product_product1);
            // args.putString("costprice", cost_price_of_product_template);
            // args.putString("supplymethod",
            // supply_method_product_template1);
            // args.putString("procuremethod",
            // procure_method_product_template1);
            // args.putString("ean13", ean13_of_product_product1);
            //
            //
            // detail.setArguments(args);
            // FragmentListener frag = (FragmentListener) getActivity();
            // frag.startDetailFragment(detail);

        }
    });

    mListView.setOnItemClickListener(this);
    return rootView;
}

From source file:io.github.marktony.espresso.mvp.companydetails.CompanyDetailFragment.java

@Override
public void setCompanyName(String name) {
    String companyName = getString(R.string.company_name) + "\n" + name;
    Spannable spannable = new SpannableStringBuilder(companyName);
    spannable.setSpan(new StyleSpan(Typeface.BOLD), 0, companyName.length() - name.length() - 1,
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    spannable.setSpan(new StyleSpan(Typeface.NORMAL), companyName.length() - name.length(),
            companyName.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    textViewCompanyName.setText(spannable);
}

From source file:com.owncloud.android.ui.adapter.NotificationListAdapter.java

@Override
public void onBindViewHolder(@NonNull NotificationViewHolder holder, int position) {
    Notification notification = notificationsList.get(position);
    holder.dateTime.setText(// www  . ja v a 2s  .  c om
            DisplayUtils.getRelativeTimestamp(notificationsActivity, notification.getDatetime().getTime()));

    String subject = notification.getSubject();
    if (!TextUtils.isEmpty(notification.getLink())) {
        subject = subject + " ";
        holder.subject.setTypeface(holder.subject.getTypeface(), Typeface.BOLD);
        holder.subject.setOnClickListener(v -> openLink(notification.getLink()));
        holder.subject.setText(subject);
    } else {
        if (!TextUtils.isEmpty(notification.subjectRich)) {
            holder.subject.setText(makeSpecialPartsBold(notification));
        } else {
            holder.subject.setText(subject);
        }
    }

    holder.message.setText(notification.getMessage());

    // Todo set proper action icon (to be clarified how to pick)
    if (!TextUtils.isEmpty(notification.getIcon())) {
        downloadIcon(notification.getIcon(), holder.icon);
    }

    // add action buttons
    holder.buttons.removeAllViews();
    Button button;
    ExecuteActionTask executeActionTask = new ExecuteActionTask(holder);

    for (Action action : notification.getActions()) {
        button = new Button(notificationsActivity);
        button.setText(action.label);
        if (action.primary) {
            button.getBackground().setColorFilter(ThemeUtils.primaryColor(notificationsActivity, true),
                    PorterDuff.Mode.SRC_ATOP);
            button.setTextColor(ThemeUtils.fontColor(notificationsActivity));
        }

        button.setOnClickListener(v -> executeActionTask.execute(action));

        holder.buttons.addView(button);
    }
}

From source file:com.liferay.mobile.screens.viewsets.westeros.auth.signup.SignUpView.java

private void initClickableTermsAndConditions() {
    TextView textView = (TextView) findViewById(R.id.terms);
    textView.setMovementMethod(LinkMovementMethod.getInstance());

    SpannableStringBuilder ssb = new SpannableStringBuilder("I accept the terms and conditions");

    ssb.setSpan(new ClickableSpan() {
        @Override/*w w w.  ja  v a  2  s.c  o m*/
        public void onClick(View widget) {
            SignUpScreenlet signUpScreenlet = getSignUpScreenlet();
            signUpScreenlet.performUserAction(SignUpScreenlet.TERMS_AND_CONDITIONS);
        }
    }, 13, ssb.length(), 0);

    ssb.setSpan(new StyleSpan(Typeface.BOLD), 13, ssb.length(), 0);
    ssb.setSpan(new ForegroundColorSpan(ContextCompat.getColor(getContext(), android.R.color.white)), 13,
            ssb.length(), 0);

    textView.setText(ssb, TextView.BufferType.SPANNABLE);
}

From source file:com.liberorignanese.android.stepindicatorview.Step.java

public void setUpView(View stepView, Step previous, Step next, int orientation, boolean useSecondaryStepColor) {
    ImageView iconView = (ImageView) stepView.findViewById(R.id.icon_step_layout);
    ImageView lineStartView = (ImageView) stepView.findViewById(R.id.linestart_step_layout);
    ImageView lineEndView = (ImageView) stepView.findViewById(R.id.lineend_step_layout);
    TextView textView = (TextView) stepView.findViewById(R.id.text_step_layout);

    int line_completed = orientation == LinearLayout.HORIZONTAL
            ? (useSecondaryStepColor ? R.drawable.line_completed_horizontal_secondary
                    : R.drawable.line_completed_horizontal)
            : (useSecondaryStepColor ? R.drawable.line_completed_vertical_secondary
                    : R.drawable.line_completed_vertical);
    int line_uncompleted = orientation == LinearLayout.HORIZONTAL
            ? (useSecondaryStepColor ? R.drawable.line_uncompleted_horizontal_secondary
                    : R.drawable.line_uncompleted_horizontal)
            : (useSecondaryStepColor ? R.drawable.line_uncompleted_vertical_secondary
                    : R.drawable.line_uncompleted_vertical);
    int icon_completed = useSecondaryStepColor ? R.drawable.icon_check_secondary : R.drawable.icon_check;
    int icon_uncompleted = useSecondaryStepColor ? R.drawable.icon_circle_secondary : R.drawable.icon_circle;
    int icon_completed_current = useSecondaryStepColor ? R.drawable.icon_check_secondary_current
            : R.drawable.icon_check_current;
    int step_backgroundcolor = Color.TRANSPARENT;
    int step_textcolor = useSecondaryStepColor ? R.color.stepviewindicator_maincolor_secondary
            : R.color.stepviewindicator_maincolor;
    int step_iscurrent_backgroundcolor = useSecondaryStepColor ? R.color.stepviewindicator_maincolor_secondary
            : R.color.stepviewindicator_maincolor;
    int step_iscurrent_textcolor = useSecondaryStepColor ? R.color.stepviewindicator_checkcolor_secondary
            : R.color.stepviewindicator_checkcolor;

    /*//  w ww .  j av a  2  s .  c  om
            if(useSecondaryStepColor){
            
            }
    */

    if (previous == null) {
        lineStartView.setVisibility(View.INVISIBLE);
    } else {
        lineStartView.setVisibility(View.VISIBLE);
        if (previous.isCompleted()) {
            lineStartView.setImageResource(line_completed);
            lineStartView.setImageAlpha(255);
        } else {
            lineStartView.setImageResource(line_uncompleted);
            lineStartView.setImageAlpha(alpha);
        }
    }
    if (next == null) {
        lineEndView.setVisibility(View.INVISIBLE);
    } else {
        lineEndView.setVisibility(View.VISIBLE);
        if (isCompleted()) {
            lineEndView.setImageResource(line_completed);
            lineEndView.setImageAlpha(255);
        } else {
            lineEndView.setImageResource(line_uncompleted);
            lineEndView.setImageAlpha(alpha);
        }
    }
    textView.setText(getText());
    if (isCompleted()) {
        iconView.setImageResource(current ? icon_completed_current : icon_completed);
        iconView.setImageAlpha(255);
    } else {
        iconView.setImageResource(icon_uncompleted);
        if (isCurrent()) {
            iconView.setImageAlpha(255);
        } else {
            iconView.setImageAlpha(alpha);
        }
    }

    if (isCurrent()) {
        textView.setTypeface(null, Typeface.BOLD);
        textView.setTextColor(ContextCompat.getColor(stepView.getContext(), step_iscurrent_textcolor));
        textView.setBackgroundColor(
                ContextCompat.getColor(stepView.getContext(), step_iscurrent_backgroundcolor));
    } else {
        textView.setTypeface(null, Typeface.NORMAL);
        textView.setTextColor(ContextCompat.getColor(stepView.getContext(), step_textcolor));
        textView.setBackgroundColor(step_backgroundcolor);
    }
    /*
            if(useSecondaryStepColor){
    textView.setTextColor(ContextCompat.getColor(stepView.getContext(), R.color.stepviewindicator_maincolor_secondary));
            }else{
    textView.setTextColor(ContextCompat.getColor(stepView.getContext(), R.color.stepviewindicator_maincolor));
            }
    */
    stepView.setOnClickListener(onClickListener);

}

From source file:com.grarak.kerneladiutor.elements.SplashView.java

private void draw(Canvas canvas, int x, int y, int radius) {
    if (radius > 0)
        canvas.drawCircle(x / 2, y / 2, radius, mPaintCircle);
    matrix.postRotate(rotate);/*  w w  w  .  j av  a 2  s.c  o  m*/
    Bitmap iconRotate = Bitmap.createBitmap(icon, 0, 0, icon.getWidth(), icon.getHeight(), matrix, false);
    canvas.drawBitmap(iconRotate, x / 2 - iconRotate.getWidth() / 2, y / 2 - iconRotate.getHeight() / 2,
            mPaintCircle);

    TextPaint textPaint = new TextPaint();
    textPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
    textPaint.setColor(textColor);
    textPaint.setAntiAlias(true);
    textPaint.setTextAlign(Paint.Align.CENTER);
    textPaint.setTextSize(textSize);
    float textHeight = textPaint.descent() - textPaint.ascent();
    float textOffset = (textHeight / 2) - textPaint.descent();

    canvas.drawText(getResources().getString(R.string.root_waiting), x / 2, y - textOffset - y / 4, textPaint);
}