List of usage examples for android.text Spanned SPAN_EXCLUSIVE_EXCLUSIVE
int SPAN_EXCLUSIVE_EXCLUSIVE
To view the source code for android.text Spanned SPAN_EXCLUSIVE_EXCLUSIVE.
Click Source Link
From source file:cw.kop.autobackground.tutorial.CardFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { final View view = AppSettings.getTheme().equals(AppSettings.APP_LIGHT_THEME) ? inflater.inflate(R.layout.tutorial_card_fragment, container, false) : inflater.inflate(R.layout.tutorial_card_fragment_dark, container, false); View sourceCard = view.findViewById(R.id.source_card); sourceCard.setOnClickListener(this); int colorFilterInt = AppSettings.getColorFilterInt(appContext); TextView sourceTitle = (TextView) view.findViewById(R.id.source_title); sourceTitle.setOnClickListener(new View.OnClickListener() { @Override/*from ww w .ja v a 2s . co m*/ public void onClick(View v) { CardFragment.this.onClick(view); } }); ImageView deleteButton = (ImageView) view.findViewById(R.id.source_delete_button); ImageView viewButton = (ImageView) view.findViewById(R.id.source_view_image_button); ImageView editButton = (ImageView) view.findViewById(R.id.source_edit_button); Drawable deleteDrawable = getResources().getDrawable(R.drawable.ic_delete_white_24dp); Drawable viewDrawable = getResources().getDrawable(R.drawable.ic_photo_white_24dp); Drawable editDrawable = getResources().getDrawable(R.drawable.ic_edit_white_24dp); deleteDrawable.setColorFilter(colorFilterInt, PorterDuff.Mode.MULTIPLY); viewDrawable.setColorFilter(colorFilterInt, PorterDuff.Mode.MULTIPLY); editDrawable.setColorFilter(colorFilterInt, PorterDuff.Mode.MULTIPLY); deleteButton.setImageDrawable(deleteDrawable); viewButton.setImageDrawable(viewDrawable); editButton.setImageDrawable(editDrawable); deleteButton.setOnClickListener(null); viewButton.setOnClickListener(null); editButton.setOnClickListener(null); TextView sourceType = (TextView) view.findViewById(R.id.source_type); TextView sourceData = (TextView) view.findViewById(R.id.source_data); TextView sourceNum = (TextView) view.findViewById(R.id.source_num); TextView sourceTime = (TextView) view.findViewById(R.id.source_time); int colorPrimary = getResources().getColor(R.color.BLUE_OPAQUE); SpannableString typePrefix = new SpannableString("Type: "); typePrefix.setSpan(new ForegroundColorSpan(colorPrimary), 0, typePrefix.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); SpannableString dataPrefix = new SpannableString("Data: "); dataPrefix.setSpan(new ForegroundColorSpan(colorPrimary), 0, dataPrefix.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); SpannableString numPrefix = new SpannableString("Number of Images: "); numPrefix.setSpan(new ForegroundColorSpan(colorPrimary), 0, numPrefix.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); SpannableString timePrefix = new SpannableString("Active Time: "); timePrefix.setSpan(new ForegroundColorSpan(colorPrimary), 0, timePrefix.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); sourceType.setText(typePrefix); sourceData.setText(dataPrefix); sourceNum.setText(numPrefix); sourceTime.setText(timePrefix); ImageView image = (ImageView) view.findViewById(R.id.source_image); Picasso.with(appContext).load(R.drawable.preview_image_0).fit().centerCrop().into(image); TextView titleText = (TextView) view.findViewById(R.id.title_text); titleText.setTextColor(colorFilterInt); titleText.setText("Sources"); TextView tutorialText = (TextView) view.findViewById(R.id.tutorial_text); tutorialText.setTextColor(colorFilterInt); tutorialText.setText("These are the parts that make up your wallpaper. " + "Each represents an image source like an album from Imgur or " + "a subreddit. Note that not all websites or entries can work " + "with AutoBackground."); return view; }
From source file:org.mariotaku.twidere.view.NameView.java
public void updateText(@Nullable BidiFormatter formatter) { final SpannableStringBuilder sb = new SpannableStringBuilder(); final String primaryText = mNameFirst ? mName : mScreenName; final String secondaryText = mNameFirst ? mScreenName : mName; if (primaryText != null) { int start = sb.length(); if (formatter != null && !isInEditMode()) { sb.append(formatter.unicodeWrap(primaryText)); } else {//from w ww . ja v a 2 s. com sb.append(primaryText); } int end = sb.length(); sb.setSpan(mPrimaryTextColor, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); sb.setSpan(mPrimaryTextStyle, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); sb.setSpan(mPrimaryTextSize, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } sb.append(mTwoLine ? '\n' : ' '); if (secondaryText != null) { int start = sb.length(); if (formatter != null && !isInEditMode()) { sb.append(formatter.unicodeWrap(secondaryText)); } else { sb.append(secondaryText); } int end = sb.length(); sb.setSpan(mSecondaryTextColor, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); sb.setSpan(mSecondaryTextStyle, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); sb.setSpan(mSecondaryTextSize, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } setText(sb); }
From source file:com.woodblockwithoutco.beretainedexample.MainActivity.java
protected CharSequence[] getItems() { //filling list with entries like "fieldName 0xfieldHash" String[] fieldNames = new String[] { "mIntArray", "mObject", "mMap", }; String[] fieldHashcodes = new String[] { "0x" + Integer.toHexString(System.identityHashCode(mIntArray)), "0x" + Integer.toHexString(System.identityHashCode(mObject)), "0x" + Integer.toHexString(System.identityHashCode(mMap)) }; if (fieldHashcodes.length != fieldNames.length) { throw new IllegalStateException("Did you forget to add something?"); }/*from w w w .j a v a 2 s. co m*/ int length = fieldHashcodes.length; CharSequence[] items = new CharSequence[length]; for (int i = 0; i < length; i++) { SpannableStringBuilder description = new SpannableStringBuilder(); description.append(fieldNames[i]); description.setSpan(new TypefaceSpan("bold"), 0, description.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); description.append(" ").append(fieldHashcodes[i]); items[i] = description; } return items; }
From source file:com.frostwire.android.gui.views.KeywordTagView.java
private void updateComponents() { SpannableStringBuilder sb = new SpannableStringBuilder(); sb = append(sb, keywordFilter.getKeyword(), keywordSpan, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); if (count != -1) { sb = append(sb, " (" + String.valueOf(count) + ")", countSpan, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); }/*from ww w . j av a 2 s. c o m*/ setText(sb, TextView.BufferType.NORMAL); if (dismissible) { setBackgroundResource(R.drawable.keyword_tag_background_active); int drawableResId = keywordFilter.isInclusive() ? R.drawable.keyword_tag_filter_add : R.drawable.keyword_tag_filter_minus; setCompoundDrawablesWithIntrinsicBounds(drawableResId, 0, R.drawable.keyword_tag_close_clear_cancel_full, 0); setTextColor(ContextCompat.getColor(getContext(), R.color.app_text_white)); } else { setBackgroundResource(R.drawable.keyword_tag_background); setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); setTextColor(ContextCompat.getColor(getContext(), R.color.app_text_primary)); } setOnClickListener(v -> onTouched()); if (dismissible) { setOnTouchListener((v, event) -> { if (event.getAction() != MotionEvent.ACTION_UP) { return false; } TextView tv = (TextView) v; if (event.getX() >= tv.getWidth() - tv.getTotalPaddingRight()) { onDismissed(); return true; } return false; }); } }
From source file:com.hitesh_sahu.retailapp.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 w w w .ja va 2 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(CenterRepository.getCenterRepository().getListOfProductsInShoppingList() .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) { CenterRepository.getCenterRepository().getListOfProductsInShoppingList().get(position) .setQuantity(String.valueOf( Integer.valueOf(CenterRepository.getCenterRepository() .getListOfProductsInShoppingList().get(position).getQuantity()) + 1)); holder.quanitity.setText(CenterRepository.getCenterRepository().getListOfProductsInShoppingList() .get(position).getQuantity()); Utils.vibrate(context); ((ECartHomeActivity) context).updateCheckOutAmount(BigDecimal.valueOf(Long.valueOf(CenterRepository .getCenterRepository().getListOfProductsInShoppingList().get(position).getSellMRP())), true); } }); holder.removeItem.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (Integer.valueOf(CenterRepository.getCenterRepository().getListOfProductsInShoppingList() .get(position).getQuantity()) > 2) { CenterRepository.getCenterRepository().getListOfProductsInShoppingList().get(position) .setQuantity(String.valueOf( Integer.valueOf(CenterRepository.getCenterRepository() .getListOfProductsInShoppingList().get(position).getQuantity()) - 1)); holder.quanitity.setText(CenterRepository.getCenterRepository() .getListOfProductsInShoppingList().get(position).getQuantity()); ((ECartHomeActivity) context).updateCheckOutAmount( BigDecimal.valueOf(Long.valueOf(CenterRepository.getCenterRepository() .getListOfProductsInShoppingList().get(position).getSellMRP())), false); Utils.vibrate(context); } else if (Integer.valueOf(CenterRepository.getCenterRepository().getListOfProductsInShoppingList() .get(position).getQuantity()) == 1) { ((ECartHomeActivity) context).updateItemCount(false); ((ECartHomeActivity) context).updateCheckOutAmount( BigDecimal.valueOf(Long.valueOf(CenterRepository.getCenterRepository() .getListOfProductsInShoppingList().get(position).getSellMRP())), false); CenterRepository.getCenterRepository().getListOfProductsInShoppingList().remove(position); if (Integer.valueOf(((ECartHomeActivity) context).getItemCount()) == 0) { MyCartFragment.updateMyCartFragment(false); } Utils.vibrate(context); } } }); }
From source file:de.ktran.anno1404warenrechner.views.PopulationNumberDialog.java
private void setAdvancementText(int value, PopulationType.Civilization civilization) { String advanceTextStart = getActivity().getString(R.string.advance_to); String advanceName = getPopulationTypeByProgress(value, civilization).getString(getContext()); if (advancementText != null) { advancementText.setText(advanceTextStart + " " + advanceName.toLowerCase(), TextView.BufferType.SPANNABLE); Spannable sp = (Spannable) advancementText.getText(); sp.setSpan(new StyleSpan(Typeface.BOLD), advanceTextStart.length(), 1 + advanceTextStart.length() + advanceName.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); }/* w ww.j av a 2 s . co m*/ }
From source file:com.qiscus.sdk.ui.adapter.viewholder.QiscusBaseLinkViewHolder.java
private void clickify(String clickableText, ClickSpan.OnClickListener listener) { CharSequence text = messageTextView.getText(); String string = text.toString(); ClickSpan span = new ClickSpan(listener); int start = string.indexOf(clickableText); int end = start + clickableText.length(); if (start == -1) { return;/*from w w w.j a v a 2 s .c om*/ } if (text instanceof Spannable) { ((Spannable) text).setSpan(span, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } else { SpannableString s = SpannableString.valueOf(text); s.setSpan(span, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); messageTextView.setText(s); } MovementMethod m = messageTextView.getMovementMethod(); if (m == null || !(m instanceof LinkMovementMethod)) { messageTextView.setMovementMethod(LinkMovementMethod.getInstance()); } }
From source file:com.maxleapmobile.gitmaster.ui.fragment.RecommendFragment.java
private void initUI(View view) { actionArea = (LinearLayout) view.findViewById(R.id.recommend_action_area); starProgressBar = (ProgressBar) view.findViewById(R.id.recommend_star_progressbar); starText = (TextView) view.findViewById(R.id.recommend_star); starText.setOnClickListener(this); view.findViewById(R.id.recommend_fork).setOnClickListener(this); skipBtn = view.findViewById(R.id.recommend_skip); skipBtn.setOnClickListener(this); mProgressBar = (ProgressBar) view.findViewById(R.id.repo_progressbar); TextView notice2 = (TextView) view.findViewById(R.id.recommend_notice2); SpannableString notice2SS = new SpannableString(mContext.getString(R.string.recommend_notice2_part1) + " " + mContext.getString(R.string.recommend_notice2_part2)); notice2SS.setSpan(new CustomClickableSpan(), 0, mContext.getString(R.string.recommend_notice2_part1).length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); notice2.setText(notice2SS);/* w w w. ja v a 2s .com*/ notice2.setOnClickListener(this); notice3 = (TextView) view.findViewById(R.id.recommend_notice3); final SpannableString notice3SS = new SpannableString(mContext.getString(R.string.recommend_notice3_part1) + " " + mContext.getString(R.string.recommend_notice3_part2)); notice3SS.setSpan(new CustomClickableSpan(), mContext.getString(R.string.recommend_notice3_part1).length(), notice3SS.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); notice3.setText(notice3SS); notice3.setOnClickListener(this); mWebView = (ProgressWebView) view.findViewById(R.id.recommend_webview); mWebView.setWebViewClient(new WebViewClient() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { super.onPageStarted(view, url, favicon); mProgressBar.setVisibility(View.GONE); } }); mEmptyView = (LinearLayout) view.findViewById(R.id.recommend_empty); mEmptyView.setVisibility(View.GONE); if (mParmasMap == null) { mParmasMap = new HashMap(); mParmasMap.put("userid", username); mParmasMap.put("page", page); mParmasMap.put("per_page", PER_PAGE); } }
From source file:org.thoughtcrime.securesms.components.webrtc.WebRtcCallScreen.java
public void setUntrustedIdentity(Recipient personInfo, IdentityKey untrustedIdentity) { String name = recipient.toShortString(); String introduction = String.format(getContext().getString(R.string.WebRtcCallScreen_new_safety_numbers), name, name);//w ww.ja v a2 s .c o m SpannableString spannableString = new SpannableString(introduction + " " + getContext().getString(R.string.WebRtcCallScreen_you_may_wish_to_verify_this_contact)); spannableString.setSpan(new VerifySpan(getContext(), personInfo.getRecipientId(), untrustedIdentity), introduction.length() + 1, spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); setPersonInfo(personInfo); this.incomingCallOverlay.setActiveCall(); this.status.setText(R.string.WebRtcCallScreen_new_safety_numbers_title); this.untrustedIdentityContainer.setVisibility(View.VISIBLE); this.untrustedIdentityExplanation.setText(spannableString); this.untrustedIdentityExplanation.setMovementMethod(LinkMovementMethod.getInstance()); this.endCallButton.setVisibility(View.INVISIBLE); }
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); }