Example usage for android.text Spanned SPAN_EXCLUSIVE_EXCLUSIVE

List of usage examples for android.text Spanned SPAN_EXCLUSIVE_EXCLUSIVE

Introduction

In this page you can find the example usage for android.text Spanned SPAN_EXCLUSIVE_EXCLUSIVE.

Prototype

int SPAN_EXCLUSIVE_EXCLUSIVE

To view the source code for android.text Spanned SPAN_EXCLUSIVE_EXCLUSIVE.

Click Source Link

Document

Spans of type SPAN_EXCLUSIVE_EXCLUSIVE do not expand to include text inserted at either their starting or ending point.

Usage

From source file:com.irccloud.android.fragment.TextListFragment.java

private void setText(String text) {
    SpannableStringBuilder sb = new SpannableStringBuilder(text);
    for (int i = 0; i < 100; i++)
        sb.setSpan(new TabStopSpan.Standard(i * 300), 0, sb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    textView.setText(sb, TextView.BufferType.SPANNABLE);
}

From source file:cw.kop.autobackground.tutorial.FinishFragment.java

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

    View view = inflater.inflate(R.layout.tutorial_finish_fragment, container, false);
    int colorFilterInt = AppSettings.getColorFilterInt(appContext);

    TextView titleText = (TextView) view.findViewById(R.id.title_text);
    titleText.setTextColor(colorFilterInt);
    titleText.setText("That's it.");

    TextView tutorialText = (TextView) view.findViewById(R.id.tutorial_text);
    tutorialText.setTextColor(colorFilterInt);
    tutorialText.setText("Now you're ready to use AutoBackground. I'd suggest adding a new source first "
            + "and then hitting download." + "\n" + "\n"
            + "If you have any questions, concerns, suggestions, or whatever else, feel free to "
            + "email me at ");
    SpannableString emailString = new SpannableString("chiuwinson@gmail.com");
    ClickableSpan clickableSpan = new ClickableSpan() {
        @Override/* w  w w. jav a  2s  .c o m*/
        public void onClick(View widget) {
            Log.i(TAG, "Clicked");
            Intent emailIntent = new Intent(Intent.ACTION_SENDTO,
                    Uri.fromParts("mailto", "chiuwinson@gmail.com", null));
            emailIntent.putExtra(Intent.EXTRA_SUBJECT, "AutoBackground Feedback");
            startActivity(Intent.createChooser(emailIntent, "Send email"));
        }
    };
    emailString.setSpan(clickableSpan, 0, emailString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    tutorialText.append(emailString);
    tutorialText.append(".");
    tutorialText.setMovementMethod(LinkMovementMethod.getInstance());

    return view;
}

From source file:com.oasisfeng.nevo.decorators.StackDecorator.java

@Override
public void apply(final StatusBarNotificationEvo evolved) throws RemoteException {
    final Collection<StatusBarNotificationEvo> history = getArchivedNotifications(evolved.getKey(),
            KMaxNumLines);/*from ww  w  .j a v a2 s  .  com*/
    if (history.size() <= 1)
        return;
    final INotification evolved_n = evolved.notification();
    final IBundle evolved_extras = evolved_n.extras();
    if (evolved_extras.containsKey(EXTRA_TEXT_LINES))
        return; // Never stack already inbox-styled notification.

    final Calendar calendar = Calendar.getInstance();
    final List<CharSequence> lines = new ArrayList<>(KMaxNumLines);
    long previous_when = 0;
    final long latest_when = evolved_n.getWhen();
    for (final StatusBarNotificationEvo sbn : history) {
        final INotification n = sbn.notification();
        final CharSequence text = n.extras().getCharSequence(NotificationCompat.EXTRA_TEXT);
        if (text == null)
            continue;

        final long when = n.getWhen();
        if (when == latest_when || Math.abs(when - previous_when) <= KMinIntervalToShowTimestamp)
            lines.add(text);
        else { // Add time-stamp
            final SpannableStringBuilder line = new SpannableStringBuilder();
            calendar.setTimeInMillis(when);
            final String time_text = String.format((Locale) null, "%1$02d:%2$02d ", calendar.get(HOUR_OF_DAY),
                    calendar.get(MINUTE));
            line.append(time_text);
            line.append(text);
            line.setSpan(new StyleSpan(Typeface.BOLD), 0, 5, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            lines.add(line);
        }
        previous_when = when;
    }
    if (lines.isEmpty())
        return;
    Collections.reverse(lines); // Latest first, since earliest lines will be trimmed by InboxStyle.

    final CharSequence title = evolved_extras.getCharSequence(NotificationCompat.EXTRA_TITLE);
    evolved_extras.putCharSequence(NotificationCompat.EXTRA_TITLE_BIG, title);
    evolved_extras.putCharSequenceArray(EXTRA_TEXT_LINES, lines);

    evolved_n.setBigContentView(buildBigContentView(evolved.getPackageName(), title, lines));
}

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

public void setText(String text) {
    if (text == null || text.length() == 0) {
        setVisibility(GONE);/*from w  w w.j  a  v a 2s .  com*/
        return;
    }
    if (text != null && oldText != null && text.equals(oldText)) {
        return;
    }
    oldText = text;
    setVisibility(VISIBLE);
    if (AndroidUtilities.isTablet()) {
        width = (int) (AndroidUtilities.getMinTabletSide() * 0.7f);
    } else {
        width = (int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.7f);
    }
    SpannableStringBuilder stringBuilder = new SpannableStringBuilder();
    String help = LocaleController.getString("BotInfoTitle", R.string.BotInfoTitle);
    stringBuilder.append(help);
    stringBuilder.append("\n\n");
    stringBuilder.append(text);
    MessageObject.addLinks(stringBuilder);
    stringBuilder.setSpan(new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf")), 0, help.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    Emoji.replaceEmoji(stringBuilder, textPaint.getFontMetricsInt(), AndroidUtilities.dp(20), false);
    try {
        textLayout = new StaticLayout(stringBuilder, textPaint, width, Layout.Alignment.ALIGN_NORMAL, 1.0f,
                0.0f, false);
        width = 0;
        height = textLayout.getHeight() + AndroidUtilities.dp(4 + 18);
        int count = textLayout.getLineCount();
        for (int a = 0; a < count; a++) {
            width = (int) Math.ceil(Math.max(width, textLayout.getLineWidth(a) + textLayout.getLineLeft(a)));
        }
    } catch (Exception e) {
        FileLog.e("tmessage", e);
    }
    width += AndroidUtilities.dp(4 + 18);
}

From source file:org.kontalk.ui.view.ContactsListItem.java

public final void bind(Context context, final Contact contact, String prependStatus,
        CharacterStyle prependStyle, boolean subscribed) {
    mContact = contact;//from   ww  w. j av a2s  . c o m

    setChecked(false);

    loadAvatar(contact);

    mText1.setText(contact.getDisplayName());

    CharSequence text2 = contact.getStatus();
    if (text2 == null) {
        text2 = contact.getNumber();
        mText2.setTextColor(ContextCompat.getColor(context, R.color.grayed_out));
    } else {
        int color = ContextCompat.getColor(context,
                SystemUtils.getThemedResource(getContext(), android.R.attr.textColorSecondary));
        mText2.setTextColor(color);
    }
    if (prependStatus != null) {
        if (prependStyle != null) {
            text2 = new SpannableString(prependStatus + " " + text2);
            ((SpannableString) text2).setSpan(prependStyle, 0, prependStatus.length(),
                    Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        } else {
            text2 = prependStatus + " " + text2;
        }
    }
    mText2.setText(text2);

    if (mTrustStatus != null) {
        int resId;

        if (!subscribed) {
            resId = R.drawable.ic_denied;
        } else if (contact.isKeyChanged()) {
            // the key has changed and was not trusted yet
            resId = R.drawable.ic_trust_unknown;
        } else {
            switch (contact.getTrustedLevel()) {
            case MyUsers.Keys.TRUST_UNKNOWN:
                resId = R.drawable.ic_trust_unknown;
                break;
            case MyUsers.Keys.TRUST_IGNORED:
                resId = R.drawable.ic_trust_ignored;
                break;
            case MyUsers.Keys.TRUST_VERIFIED:
                resId = R.drawable.ic_trust_verified;
                break;
            default:
                resId = -1;
            }
        }

        if (resId > 0) {
            mTrustStatus.setImageResource(resId);
        } else {
            mTrustStatus.setImageDrawable(null);
        }
    }

}

From source file:com.inter.trade.ui.fragment.smsreceivepayment.SmsSuccessFragment.java

private void initView(View view) {
    if (requsetData != null) {
        TextView tv_content = (TextView) view.findViewById(R.id.tv_content);
        String s1 = "????";
        String s2 = requsetData.getValue("fumobile");
        String s3 = "??";
        String s4 = "" + requsetData.getValue("money");
        String s5 = ",??1";
        String content = s1 + s2 + s3 + s4 + s5;
        int len = 0;
        /**/*from   w  w w.j  a  v a 2  s  .c  o  m*/
         * ?TEXTVIEW??
         */
        SpannableString ss = new SpannableString(content);
        ss.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.agent_apply_yellow)),
                len = s1.length() + s2.length() + s3.length(), len + s4.length(),
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        tv_content.setText(ss);
        tv_content.setMovementMethod(LinkMovementMethod.getInstance());

        //         String content = "????"
        //               +requsetData.getValue("fumobile")
        //               +"??"
        //               +requsetData.getValue("money")
        //               +",??1";
        //         tv_content.setText(content);

        TextView tv_shou_bank = (TextView) view.findViewById(R.id.tv_shou_bank);
        String shou_bank = "" + requsetData.getValue("shoucardbank");
        tv_shou_bank.setText(shou_bank);

        TextView tv_shou_card = (TextView) view.findViewById(R.id.tv_shou_card);
        String shou_card = "?" + requsetData.getValue("shoucardno");
        tv_shou_card.setText(shou_card);
    }

    Button see_history = (Button) view.findViewById(R.id.see_history);
    see_history.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            getActivity().setResult(Constants.ACTIVITY_FINISH);
            getActivity().finish();
        }
    });

    Button btnAgain = (Button) view.findViewById(R.id.btn_again);
    btnAgain.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            /**
             * ??
             */
            SmsReceivePaymentMainFragment.isComeBackFromPaySuccess = true;
            Intent intent = new Intent(getActivity(), IndexActivity.class);
            intent.putExtra(FragmentFactory.INDEX_KEY, FuncMap.SMSRECEIPT_INDEX_FUNC);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);
        }
    });

}

From source file:codepath.watsiapp.utils.Util.java

/**
 * Sets a hyperlink style to the textview.
 *///from  ww w .  ja  v a 2 s . com
public static void makeTextViewHyperlink(TextView tv) {
    SpannableStringBuilder ssb = new SpannableStringBuilder();
    ssb.append(tv.getText());
    ssb.setSpan(new URLSpan("#"), 0, ssb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    tv.setText(ssb, TextView.BufferType.SPANNABLE);
}

From source file:de.vanita5.twittnuker.activity.support.ThemedFragmentActivity.java

@Override
protected void onTitleChanged(CharSequence title, int color) {
    final SpannableStringBuilder builder = new SpannableStringBuilder(title);
    final int themeResId = getCurrentThemeResourceId();
    final int themeColor = getThemeColor(), contrastColor = ColorUtils.getContrastYIQ(themeColor, 192);
    if (!ThemeUtils.isDarkTheme(themeResId)) {
        builder.setSpan(new ForegroundColorSpan(contrastColor), 0, builder.length(),
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    }/*  w w  w.j  a va2s .  c o  m*/
    super.onTitleChanged(title, color);
}

From source file:com.ymt.demo1.main.sign.SignUpFragment.java

/**
 * ???//from  w w w . ja  v a  2  s .  com
 * ?????????
 */
protected void initView(View view) {
    /*
    
     */
    //?
    final EditText phoneTxt = (EditText) view.findViewById(R.id.input_phone_num);
    final EditText accountTxt = (EditText) view.findViewById(R.id.input_account);
    final EditText pswTxt = (EditText) view.findViewById(R.id.input_psw);
    final EditText rePswTxt = (EditText) view.findViewById(R.id.re_input_psw);
    final TextView licenseTxt = (TextView) view.findViewById(R.id.licence_txt);
    /*???? ??
     */
    final TextView getCheckNums = (TextView) view.findViewById(R.id.get_check_nums);
    final EditText inputCheckNums = (EditText) view.findViewById(R.id.input_check_nums);
    getCheckNums.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //todo ????

        }
    });

    /**
     *  todo spannableString 
     *   ?
     */
    SpannableString spannableString = new SpannableString(getString(R.string.license));
    ForegroundColorSpan span = new ForegroundColorSpan(getResources().getColor(R.color.material_blue_grey_800));
    spannableString.setSpan(span, 0, 7, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    licenseTxt.setText(spannableString);
    //switch(??)
    myCheckView = (MyCheckView) view.findViewById(R.id.switch_liscense);
    //
    Button signUpBtn = (Button) view.findViewById(R.id.do_sign_btn);
    signUpBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            //
            String phoneNum = phoneTxt.getText().toString();
            String account = accountTxt.getText().toString();
            String psw = pswTxt.getText().toString();
            String rePsw = rePswTxt.getText().toString();
            //??
            String checkNums = inputCheckNums.getText().toString();
            //todo if(){}else{} ??

            if (!TextUtils.isEmpty(phoneNum) && !TextUtils.isEmpty(account) && !TextUtils.isEmpty(psw)
                    && psw.equals(rePsw)) {
                //?
                if (myCheckView.isChecked()) {
                    queue.add(signUpRequest(account, psw, phoneNum, NORMAL_USER));
                } else {
                    Toast.makeText(getActivity(), "?????",
                            Toast.LENGTH_SHORT).show();
                }

            } else if (TextUtils.isEmpty(phoneNum)) {
                //???
                Toast.makeText(getActivity(), "???", Toast.LENGTH_SHORT).show();
            } else if (TextUtils.isEmpty(account)) {
                //???
                Toast.makeText(getActivity(), "???", Toast.LENGTH_SHORT).show();
            } else {
                //???
                Toast.makeText(getActivity(), "???", Toast.LENGTH_SHORT)
                        .show();
            }
        }
    });

    LinearLayout licence = (LinearLayout) view.findViewById(R.id.liscense_layout);
    licence.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            myCheckView.callOnClick();
        }
    });
}

From source file:ayushi.view.adapter.ShoppingListAdapter.java

@Override
public void onBindViewHolder(final ItemViewHolder holder, final int position) {
    holder.itemName.setText(productList.get(position).getItemName());

    holder.itemDesc.setText(productList.get(position).getItemShortDesc());

    String sellCostString = Money
            .rupees(BigDecimal.valueOf(Long.valueOf(productList.get(position).getSellMRP()))).toString() + "  ";

    String buyMRP = Money.rupees(BigDecimal.valueOf(Long.valueOf(productList.get(position).getMRP())))
            .toString();//from www.jav a2 s .  c  o  m

    String costString = sellCostString + buyMRP;

    holder.itemCost.setText(costString, BufferType.SPANNABLE);

    Spannable spannable = (Spannable) holder.itemCost.getText();

    spannable.setSpan(new StrikethroughSpan(), sellCostString.length(), costString.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    mDrawableBuilder = TextDrawable.builder().beginConfig().withBorder(4).endConfig().roundRect(10);

    drawable = mDrawableBuilder.build(String.valueOf(productList.get(position).getItemName().charAt(0)),
            mColorGenerator.getColor(productList.get(position).getItemName()));

    ImageUrl = productList.get(position).getImageURL();

    holder.quanitity
            .setText(GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(position).getQuantity());

    Glide.with(context).load(ImageUrl).placeholder(drawable).error(drawable).animate(R.anim.base_slide_right_in)
            .centerCrop().into(holder.imagView);

    // Start a drag whenever the handle view it touched
    holder.imagView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) {
                mDragStartListener.onStartDrag(holder);
            }
            return false;
        }
    });

    holder.addItem.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(position).setQuantity(String.valueOf(

                    Integer.valueOf(
                            GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(position).getQuantity())
                            + 1));

            holder.quanitity.setText(
                    GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(position).getQuantity());

            Utils.vibrate(context);

            ((ECartHomeActivity) context).updateCheckOutAmount(
                    BigDecimal.valueOf(Long.valueOf(
                            GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(position).getSellMRP())),
                    true);

        }
    });

    holder.removeItem.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            if (Integer.valueOf(
                    GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(position).getQuantity()) > 2) {

                GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(position).setQuantity(String.valueOf(

                        Integer.valueOf(GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(position)
                                .getQuantity()) - 1));

                holder.quanitity.setText(
                        GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(position).getQuantity());

                ((ECartHomeActivity) context).updateCheckOutAmount(BigDecimal.valueOf(Long.valueOf(
                        GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(position).getSellMRP())),
                        false);

                Utils.vibrate(context);
            }

            else if (Integer.valueOf(
                    GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(position).getQuantity()) == 1) {
                ((ECartHomeActivity) context).updateItemCount(false);

                ((ECartHomeActivity) context).updateCheckOutAmount(BigDecimal.valueOf(Long.valueOf(
                        GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(position).getSellMRP())),
                        false);

                GlobaDataHolder.getGlobaDataHolder().getShoppingList().remove(position);

                if (Integer.valueOf(((ECartHomeActivity) context).getItemCount()) == 0) {

                    MyCartFragment.updateMyCartFragment(false);

                }

                Utils.vibrate(context);

            }

        }
    });
}