Java Code Examples for android.widget.TextView.BufferType

The following are top voted examples for showing how to use android.widget.TextView.BufferType. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: chromium-for-android-56-debug-video   File: SuggestionView.java   View source code 6 votes vote down vote up
/**
 * Sets a description line for the omnibox suggestion.
 *
 * @param str The description text.
 * @param isUrl Whether this text is a URL (as opposed to a normal string).
 */
private void showDescriptionLine(Spannable str, boolean isUrl) {
    TextView textLine = mContentsView.mTextLine2;
    if (textLine.getVisibility() != VISIBLE) {
        textLine.setVisibility(VISIBLE);
    }
    textLine.setText(str, BufferType.SPANNABLE);

    // Force left-to-right rendering for URLs. See UrlBar constructor for details.
    if (isUrl) {
        textLine.setTextColor(URL_COLOR);
        ApiCompatibilityUtils.setTextDirection(textLine, TEXT_DIRECTION_LTR);
    } else {
        textLine.setTextColor(getStandardFontColor());
        ApiCompatibilityUtils.setTextDirection(textLine, TEXT_DIRECTION_INHERIT);
    }
}
 
Example 2
Project: sctalk   File: IMUIHelper.java   View source code 6 votes vote down vote up
public static void setTextHilighted(TextView textView, String text,SearchElement searchElement) {
    textView.setText(text);
    if (textView == null
            || TextUtils.isEmpty(text)
            || searchElement ==null) {
        return;
    }

    int startIndex = searchElement.startIndex;
    int endIndex = searchElement.endIndex;
    if (startIndex < 0 || endIndex > text.length()) {
        return;
    }
    // 开始高亮处理
    int color =  Color.rgb(69, 192, 26);
    textView.setText(text, BufferType.SPANNABLE);
    Spannable span = (Spannable) textView.getText();
    span.setSpan(new ForegroundColorSpan(color), startIndex, endIndex, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
 
Example 3
Project: droidfan   File: StatusUtils.java   View source code 6 votes vote down vote up
public static void setStatus(final TextView textView, final String text) {
        final String htmlText = text + " ";
//        LogUtil.v(TAG, "setStatus:htmlText:" + htmlText);
        final HashMap<String, String> mentions = findMentions(htmlText);
//        LogUtil.v(TAG, "setStatus:mentions:" + mentions);
        final String plainText = Html.fromHtml(htmlText).toString();
//        LogUtil.v(TAG, "setStatus:plainText:" + plainText);
        final SpannableString spannable = new SpannableString(plainText);
        Linkify.addLinks(spannable, Linkify.WEB_URLS);
        linkifyUsers(spannable, mentions);
        linkifyTags(spannable);
        removeUnderLines(spannable);
//        LogUtil.v(TAG, "setStatus:finalText:" + spannable);
        textView.setText(spannable, BufferType.SPANNABLE);
        textView.setMovementMethod(LinkMovementMethod.getInstance());
    }
 
Example 4
Project: droidfan   File: StatusUtils.java   View source code 6 votes vote down vote up
public static void setItemStatus(final TextView textView, final String text) {
    final String htmlText = text + " ";
    final List<String> highlightWords = findHighlightWords(htmlText);
    final String plainText = Html.fromHtml(htmlText).toString();
    final SpannableString spannable = new SpannableString(plainText);
    Linkify.addLinks(spannable, Linkify.WEB_URLS);
    final Matcher m = PATTERN_USER.matcher(spannable);
    while (m.find()) {
        int start = m.start(1);
        int end = m.end(1);
        if (start >= 0 && start < end) {
            spannable.setSpan(new ForegroundColorSpan(AppContext.getContext().getResources().getColor(R.color.colorPrimary)), start, end,
                    Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
    }
    linkifyTags(spannable);
    removeUnderLines(spannable);
    applyHighlightSpan(spannable, highlightWords);
    textView.setText(spannable, BufferType.SPANNABLE);
}
 
Example 5
Project: AndroidChromium   File: SuggestionView.java   View source code 6 votes vote down vote up
/**
 * Sets a description line for the omnibox suggestion.
 *
 * @param str The description text.
 * @param isUrl Whether this text is a URL (as opposed to a normal string).
 */
private void showDescriptionLine(Spannable str, boolean isUrl) {
    TextView textLine = mContentsView.mTextLine2;
    if (textLine.getVisibility() != VISIBLE) {
        textLine.setVisibility(VISIBLE);
    }
    textLine.setText(str, BufferType.SPANNABLE);

    // Force left-to-right rendering for URLs. See UrlBar constructor for details.
    if (isUrl) {
        textLine.setTextColor(URL_COLOR);
        ApiCompatibilityUtils.setTextDirection(textLine, TEXT_DIRECTION_LTR);
    } else {
        textLine.setTextColor(getStandardFontColor());
        ApiCompatibilityUtils.setTextDirection(textLine, TEXT_DIRECTION_INHERIT);
    }
}
 
Example 6
Project: C.   File: SpacingTextView.java   View source code 6 votes vote down vote up
/**
 * 字距为任何字符串(技术上,一个简单的方法为CharSequence不使用)的TextView
 */
private void applyLetterSpacing() {
    if (this == null || this.originalText == null) return;
    StringBuilder builder = new StringBuilder();
    for(int i = 0; i < originalText.length(); i++) {
        String c = ""+ originalText.charAt(i);
        builder.append(c.toLowerCase());
        if(i+1 < originalText.length()) {
            builder.append("\u00A0");
        }
    }
    SpannableString finalText = new SpannableString(builder.toString());
    if(builder.toString().length() > 1) {
        for(int i = 1; i < builder.toString().length(); i+=2) {
            finalText.setSpan(new ScaleXSpan((letterSpacing+1)/10), i, i+1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
    }
    super.setText(finalText, BufferType.SPANNABLE);
}
 
Example 7
Project: neveshtanak-Deprecated-   File: App.java   View source code 6 votes vote down vote up
public static void fontAndReshape(TextView tv) {
	String text = "";

	if (tv.getText() instanceof SpannedString) {
		text = ((SpannedString) tv.getText()).toString();
	} else if (tv.getText() instanceof SpannableString) {
		text = ((SpannableString) tv.getText()).toString();
	} else {
		text = (String) tv.getText();
	}

	if (tv instanceof StyledTextView)
		((StyledTextView) tv).setPlainText(text, BufferType.NORMAL);
	else if (tv instanceof StyledButton)
		((StyledButton) tv).setPlainText(text, BufferType.NORMAL);
	else if (tv instanceof StyledEditText)
		((StyledEditText) tv).setPlainText(text, BufferType.NORMAL);

	tv.setTypeface(getFont("Yekan"));
	tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);

}
 
Example 8
Project: 365browser   File: SuggestionView.java   View source code 6 votes vote down vote up
/**
 * Sets a description line for the omnibox suggestion.
 *
 * @param str The description text.
 * @param isUrl Whether this text is a URL (as opposed to a normal string).
 */
private void showDescriptionLine(Spannable str, boolean isUrl) {
    TextView textLine = mContentsView.mTextLine2;
    if (textLine.getVisibility() != VISIBLE) {
        textLine.setVisibility(VISIBLE);
    }
    textLine.setText(str, BufferType.SPANNABLE);

    // Force left-to-right rendering for URLs. See UrlBar constructor for details.
    if (isUrl) {
        textLine.setTextColor(URL_COLOR);
        ApiCompatibilityUtils.setTextDirection(textLine, TEXT_DIRECTION_LTR);
    } else {
        textLine.setTextColor(getStandardFontColor());
        ApiCompatibilityUtils.setTextDirection(textLine, TEXT_DIRECTION_INHERIT);
    }
}
 
Example 9
Project: sophia   File: SearchResultsAdapter.java   View source code 6 votes vote down vote up
public View getView(final int position, View convertView, ViewGroup parent) {
View row = convertView;
       ViewHolder holder;

if (row == null) {
    row = inflater.inflate(R.layout.search_results_row, null);
           holder = new ViewHolder();
           holder.bookName = (TextView)row.findViewById(R.id.search_result_row_book);
           holder.chapterNumber = (TextView)row.findViewById(R.id.search_result_row_chapter);
           holder.verseNumber = (TextView)row.findViewById(R.id.search_result_row_verse_number);
           holder.verseText = (TextView)row.findViewById(R.id.search_result_row_verse_text);
           row.setTag(holder);
}
       else
           holder = (ViewHolder)row.getTag();

final Verse entry = (Verse)super.getItem(position);

//Log.d(TAG, "Verse: " + entry.number + " - " + entry.text);
holder.bookName.setText(bookNameLookupMap.get(entry.bookId));
holder.chapterNumber.setText("Chapter " + entry.chapter);
holder.verseNumber.setText("[" + entry.number + "]");
holder.verseText.setText(highlightSearchString(entry.text), BufferType.SPANNABLE);

return row;
   }
 
Example 10
Project: android-openvpn-settings   File: HtmlDialog.java   View source code 6 votes vote down vote up
private static Dialog makeDialog(Context context, int title, Spanned message)
{
	TextView textView = new TextView(context);
	textView.setText(message, BufferType.SPANNABLE );
	textView.setMovementMethod( LinkMovementMethod.getInstance() );

	ScrollView scrollView = new ScrollView(context);
	scrollView.addView( textView );

	final Dialog dialog = new AlertDialog.Builder(context).
	setTitle( title ).
	setView( scrollView ).
	setNeutralButton( "OK", null ).
	setCancelable(true).
	setIcon( android.R.drawable.ic_dialog_info).
	create();
	return dialog;
}
 
Example 11
Project: MedtronicUploader   File: DexcomG4Activity.java   View source code 6 votes vote down vote up
public void onServiceConnected(ComponentName className, IBinder service) {
	bService = service;
    mService = new Messenger(service);
    try {
        Message msg = Message.obtain(null, MedtronicConstants.MSG_REGISTER_CLIENT);
        msg.replyTo = mMessenger;
        mService.send(msg);
    } catch (RemoteException e) {
    	
    	 StringBuffer sb1 = new StringBuffer("");
		 sb1.append("EXCEPTION!!!!!! "+ e.getMessage()+" "+e.getCause());
		 for (StackTraceElement st : e.getStackTrace()){
			 sb1.append(st.toString()).append("\n");
		 }
		 Log.e(TAG,"Error Registering Client Service Connection\n"+sb1.toString());
    	if (ISDEBUG){
    		display.setText(display.getText()+"Error Registering Client Service Connection\n", BufferType.EDITABLE);
    	}
        // In this case the service has crashed before we could even do anything with it
    }
}
 
Example 12
Project: LostAndFound   File: LoginScreen.java   View source code 6 votes vote down vote up
private void initViews() {
	
	SpannableString spannable = new SpannableString(getString(R.string.app_name));
	spannable.setSpan(new ForegroundColorSpan(Color.rgb(99, 194, 208)), 0, 4, 0);
	spannable.setSpan(new ForegroundColorSpan(Color.rgb(255, 255, 255)), 5, 7, 1);
	spannable.setSpan(new ForegroundColorSpan(Color.rgb(255, 212, 0)), 7,spannable.length(), 2);
	
	final TextView appTitle = (TextView) findViewById(R.id.login_app_tittle);
	appTitle.setText(spannable, BufferType.SPANNABLE);

	btnLoginFacebook = (ImageButton) findViewById(R.id.loginFbBtn);
	btnLogin = (ImageButton) findViewById(R.id.loginBtn);
	btnGuest = (ImageButton) findViewById(R.id.loginGuestBtn); 
	btnRegister = (Button) findViewById(R.id.register);
	mTwitterBtn = (ImageButton) findViewById(R.id.loginTwBtn);
	etUsername = (EditText) findViewById(R.id.etLoginUser);
	etPassowrd = (EditText)findViewById(R.id.etLoginPassword);

	btnLogin.setOnClickListener(this);
	btnLoginFacebook.setOnClickListener(this);
	btnRegister.setOnClickListener(this);
	btnGuest.setOnClickListener(this);
	mTwitterBtn.setOnClickListener(this);
	
}
 
Example 13
Project: omnisearch   File: OmniSearchHome.java   View source code 6 votes vote down vote up
void addOrRemoveAppView(final ISearchableElement searchableElement, final Match match) {
	final View appView = searchableElement.getViewDetails().getSearchResultView();
	final boolean matches = match.isMatches();
	ViewDetails viewDetails = searchableElement.getViewDetails();
	final TextView primaryTextDisplay = viewDetails.getPrimaryTextDisplay();
	runOnUiThread(new Runnable(){
		@Override
		public void run() {
			if(matches){
				if(appView.getParent() == null){
						searchResultsView.addView(appView);
					searchResultsCount++;
				}
			} else {
				if(appView.getParent() == searchResultsView){
					searchResultsView.removeView(appView);
					searchResultsCount--;
				}
			}
			searchCountText.setText(String.valueOf(searchResultsCount));
			primaryTextDisplay.setText(match.getMatchedSpan(),BufferType.SPANNABLE);
		}
	});
}
 
Example 14
Project: yyox   File: ServicePriceActivity.java   View source code 5 votes vote down vote up
@Override
    public void priceFee(String totalCostStr) {
//        mFreight_money.setText("RMB:"+totalCostStr);

        SpannableString styledText = new SpannableString("RMB"+totalCostStr);
        styledText.setSpan(new AbsoluteSizeSpan(15,true), 0, 4, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        styledText.setSpan(new AbsoluteSizeSpan(20,true), 3, ("RMB"+totalCostStr).length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        mFreight_money.setText(styledText, BufferType.SPANNABLE);
    }
 
Example 15
Project: KTalk   File: EaseChatRowText.java   View source code 5 votes vote down vote up
@Override
public void onSetUpView() {
    EMTextMessageBody txtBody = (EMTextMessageBody) message.getBody();
    Spannable span = EaseSmileUtils.getSmiledText(context, txtBody.getMessage());
    // 设置内容
    contentView.setText(span, BufferType.SPANNABLE);

    handleTextMessage();
}
 
Example 16
Project: Tribe   File: EaseChatRowText.java   View source code 5 votes vote down vote up
@Override
public void onSetUpView() {
    EMTextMessageBody txtBody = (EMTextMessageBody) message.getBody();
    Spannable span = EaseSmileUtils.getSmiledText(context, txtBody.getMessage());
    // 设置内容
    contentView.setText(span, BufferType.SPANNABLE);

    handleTextMessage();
}
 
Example 17
Project: Tribe   File: EaseChatRowText.java   View source code 5 votes vote down vote up
@Override
public void onSetUpView() {
    EMTextMessageBody txtBody = (EMTextMessageBody) message.getBody();
    Spannable span = EaseSmileUtils.getSmiledText(context, txtBody.getMessage());
    // 设置内容
    contentView.setText(span, BufferType.SPANNABLE);

    handleTextMessage();
}
 
Example 18
Project: OSchina_resources_android   File: Tweet.java   View source code 5 votes vote down vote up
public void setLikeUsers(Context contet, TextView likeUser, boolean limit) {
    // 构造多个超链接的html, 通过选中的位置来获取用户名
    if (getLikeCount() > 0 && getLikeUser() != null
            && !getLikeUser().isEmpty()) {
        likeUser.setVisibility(View.VISIBLE);
        likeUser.setMovementMethod(LinkMovementMethod.getInstance());
        likeUser.setFocusable(false);
        likeUser.setLongClickable(false);
        likeUser.setText(addClickablePart(contet, limit), BufferType.SPANNABLE);
    } else {
        likeUser.setVisibility(View.GONE);
        likeUser.setText("");
    }
    likeUser.setVisibility(View.GONE);
}
 
Example 19
Project: FanChat   File: EaseChatRowText.java   View source code 5 votes vote down vote up
@Override
public void onSetUpView() {
    EMTextMessageBody txtBody = (EMTextMessageBody) message.getBody();
    Spannable span = EaseSmileUtils.getSmiledText(context, txtBody.getMessage());
    // 设置内容
    contentView.setText(span, BufferType.SPANNABLE);

    handleTextMessage();
}
 
Example 20
Project: boohee_v5.6   File: EmojiconTextView.java   View source code 5 votes vote down vote up
public void setText(CharSequence text, BufferType type) {
    try {
        if (!TextUtils.isEmpty(text)) {
            SpannableStringBuilder builder = new SpannableStringBuilder(text);
            EmojiconHandler.addEmojis(getContext(), builder, this.mEmojiconSize, this
                    .mTextStart, this.mTextLength, this.mUseSystemDefault);
            text = builder;
        }
        super.setText(text, type);
    } catch (IndexOutOfBoundsException e) {
        setText(text.toString());
    }
}
 
Example 21
Project: boohee_v5.6   File: NewBadgeView.java   View source code 5 votes vote down vote up
public void setText(CharSequence text, BufferType type) {
    if (isHideOnNull() && (text == null || text.toString().equalsIgnoreCase("0"))) {
        setVisibility(8);
    } else {
        setVisibility(0);
    }
    super.setText(text, type);
}
 
Example 22
Project: boohee_v5.6   File: LinkUtils.java   View source code 5 votes vote down vote up
public static void autoLink(TextView view, final OnClickListener listener, String patternStr) {
    String text = view.getText().toString();
    if (!TextUtils.isEmpty(text)) {
        Pattern pattern;
        Spannable spannable = new SpannableString(text);
        if (TextUtils.isEmpty(patternStr)) {
            pattern = URL_PATTERN;
        } else {
            pattern = Pattern.compile(patternStr);
        }
        Matcher matcher = pattern.matcher(text);
        while (matcher.find()) {
            spannable.setSpan(new SensibleUrlSpan(matcher.group(1), pattern, listener),
                    matcher.start(1), matcher.end(1), 33);
        }
        view.setText(spannable, BufferType.SPANNABLE);
        final SensibleLinkMovementMethod method = new SensibleLinkMovementMethod();
        view.setMovementMethod(method);
        if (listener != null) {
            view.setOnClickListener(new android.view.View.OnClickListener() {
                public void onClick(View v) {
                    if (!method.isLinkClicked()) {
                        listener.onClicked();
                    }
                }
            });
        }
    }
}
 
Example 23
Project: GCSApp   File: EaseChatRowRedPacket.java   View source code 5 votes vote down vote up
@Override
public void onSetUpView() {
    EMTextMessageBody txtBody = (EMTextMessageBody) message.getBody();
    Spannable span = EaseSmileUtils.getSmiledText(context, txtBody.getMessage());
    // 设置内容
    contentView.setText(span, BufferType.SPANNABLE);

    handleTextMessage();
}
 
Example 24
Project: JianshuApp   File: SubscriptionAdapter.java   View source code 5 votes vote down vote up
@Override
public void enableLoadmore(boolean enable) {
    if (isEnableLoadmore() == enable) {
        return;
    }

    super.enableLoadmore(enable);

    if (!enable) {
        // 显示footer
        if (mFooterView == null) {
            mFooterView = View.inflate(ActivityLifcycleManager.get().current(), LAYOUT_ID_FOOTER, null);
            TextView tvEnd = (TextView) mFooterView.findViewById(R.id.txt_end);
            tvEnd.setMovementMethod(LinkMovementMethod.getInstance());
            String txtEnd = AppUtils.getContext().getString(R.string.to_discover_more_zuthor_and_collection);
            SpannableStringBuilder ssb = new SpannableStringBuilder(txtEnd);
            int startIndex = txtEnd.indexOf("更");
            int endIndex = txtEnd.length();
            if (startIndex > -1) {
                ssb.setSpan(new ClickableSpanNoUnderLine() {
                    public void onClick(View widget) {
                        if (ThrottleUtils.valid(widget)) {
                            AddSubscribeActivity.launch();
                        }
                    }
                }, startIndex, endIndex, 0);
                tvEnd.setText(ssb, BufferType.SPANNABLE);
            }
        }

        if (mFooterView.getParent() == null) {
            addFooterView(mFooterView);
        }
    } else {
        removeFooterView(mFooterView);
    }
}
 
Example 25
Project: TAG   File: MessageAdapter.java   View source code 5 votes vote down vote up
/**
 * 文本消息
 * 
 * @param message
 * @param holder
 * @param position
 */
private void handleTextMessage(EMMessage message, ViewHolder holder, final int position) {
	TextMessageBody txtBody = (TextMessageBody) message.getBody();
	Spannable span = SmileUtils.getSmiledText(context, txtBody.getMessage());
	holder.tv.setText(span, BufferType.SPANNABLE);
	holder.tv.setOnLongClickListener(new OnLongClickListener() {
		@Override
		public boolean onLongClick(View v) {
			activity.startActivityForResult(
					(new Intent(activity, ContextMenu.class)).putExtra("position", position).putExtra("type",
							EMMessage.Type.TXT.ordinal()), ChatActivity.REQUEST_CODE_CONTEXT_MENU);
			return true;
		}
	});
	if (message.direct == EMMessage.Direct.SEND) {
		switch (message.status) {
		case SUCCESS:
			holder.pb.setVisibility(View.GONE);
			holder.staus_iv.setVisibility(View.GONE);
			break;
		case FAIL:
			holder.pb.setVisibility(View.GONE);
			holder.staus_iv.setVisibility(View.VISIBLE);
			break;
		case INPROGRESS: //发送中
			holder.pb.setVisibility(View.VISIBLE);
			break;
		default:
			sendMsgInBackground(message, holder);
		}
	}
}
 
Example 26
Project: TAG   File: MessageAdapter_0907.java   View source code 5 votes vote down vote up
/**
 * 文本消息
 * 
 * @param message
 * @param holder
 * @param position
 */
private void handleTextMessage(EMMessage message, ViewHolder holder, final int position) {
	TextMessageBody txtBody = (TextMessageBody) message.getBody();
	Spannable span = SmileUtils.getSmiledText(context, txtBody.getMessage());
	holder.tv.setText(span, BufferType.SPANNABLE);
	holder.tv.setOnLongClickListener(new OnLongClickListener() {
		@Override
		public boolean onLongClick(View v) {
			activity.startActivityForResult(
					(new Intent(activity, ContextMenu.class)).putExtra("position", position).putExtra("type",
							EMMessage.Type.TXT.ordinal()), ChatActivity.REQUEST_CODE_CONTEXT_MENU);
			return true;
		}
	});
	if (message.direct == EMMessage.Direct.SEND) {
		switch (message.status) {
		case SUCCESS:
			holder.pb.setVisibility(View.GONE);
			holder.staus_iv.setVisibility(View.GONE);
			break;
		case FAIL:
			holder.pb.setVisibility(View.GONE);
			holder.staus_iv.setVisibility(View.VISIBLE);
			break;
		case INPROGRESS: //发送中
			holder.pb.setVisibility(View.VISIBLE);
			break;
		default:
			sendMsgInBackground(message, holder);
		}
	}
}
 
Example 27
Project: 600SeriesAndroidUploader   File: MainActivity.java   View source code 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    String message = intent.getStringExtra(MedtronicCnlIntentService.Constants.EXTENDED_DATA);
    Log.i(TAG, "Message Receiver: " + message);

    synchronized (messages) {
        while (messages.size() > 398) {
            messages.poll();
        }
        messages.add(new StatusMessage(message));
    }

    StringBuilder sb = new StringBuilder();
    for (StatusMessage msg : messages) {
        if (sb.length() > 0)
            sb.append("\n");
        sb.append(msg);
    }

    mTextViewLog.setText(sb.toString(), BufferType.EDITABLE);

    // auto scroll status log
    if ((mScrollView.getChildAt(0).getBottom() < mScrollView.getHeight()) || ((mScrollView.getChildAt(0).getBottom() - mScrollView.getScrollY() - mScrollView.getHeight()) < (mScrollView.getHeight() / 3))) {
        mScrollView.post(new Runnable() {
            public void run() {
                mScrollView.fullScroll(View.FOCUS_DOWN);
            }
        });
    }
}
 
Example 28
Project: 600SeriesAndroidUploader   File: MainActivity.java   View source code 5 votes vote down vote up
public void clearMessages() {
    synchronized (messages) {
        messages.clear();
    }

    mTextViewLog.setText("", BufferType.EDITABLE);
}
 
Example 29
Project: MeifuGO   File: EaseChatRowText.java   View source code 5 votes vote down vote up
@Override
public void onSetUpView() {
    EMTextMessageBody txtBody = (EMTextMessageBody) message.getBody();
    Spannable span = EaseSmileUtils.getSmiledText(context, txtBody.getMessage());
    // 设置内容
    contentView.setText(span, BufferType.SPANNABLE);

    handleTextMessage();
}
 
Example 30
Project: Hyphenate-EaseUI-Android   File: EaseChatRowText.java   View source code 5 votes vote down vote up
@Override
public void onSetUpView() {
    EMTextMessageBody txtBody = (EMTextMessageBody) message.getBody();
    Spannable span = EaseSmileUtils.getSmiledText(context, txtBody.getMessage());
    // 设置内容
    contentView.setText(span, BufferType.SPANNABLE);

    handleTextMessage();
}
 
Example 31
Project: info_demo   File: MessageAdapter.java   View source code 5 votes vote down vote up
/**
 * 文本消息
 * 
 * @param message
 * @param holder
 * @param position
 */
private void handleTextMessage(EMMessage message, ViewHolder holder, final int position) {
	TextMessageBody txtBody = (TextMessageBody) message.getBody();
	Spannable span = HXSmileUtils.getSmiledText(context, txtBody.getMessage());
	// 设置内容
	holder.tv.setText(span, BufferType.SPANNABLE);
	// 设置长按事件监听
	holder.tv.setOnLongClickListener(new OnLongClickListener() {
		@Override
		public boolean onLongClick(View v) {
			activity.startActivityForResult(
					(new Intent(activity, ContextMenu.class)).putExtra("position", position).putExtra("type",
							EMMessage.Type.TXT.ordinal()), ChatActivity.REQUEST_CODE_CONTEXT_MENU);
			return true;
		}
	});

	if (message.direct == EMMessage.Direct.SEND) {
		switch (message.status) {
		case SUCCESS: // 发送成功
			holder.pb.setVisibility(View.GONE);
			holder.staus_iv.setVisibility(View.GONE);
			break;
		case FAIL: // 发送失败
			holder.pb.setVisibility(View.GONE);
			holder.staus_iv.setVisibility(View.VISIBLE);
			break;
		case INPROGRESS: // 发送中
			holder.pb.setVisibility(View.VISIBLE);
			holder.staus_iv.setVisibility(View.GONE);
			break;
		default:
			// 发送消息
			sendMsgInBackground(message, holder);
		}
	}
}
 
Example 32
Project: Vafrinn   File: SuggestionView.java   View source code 5 votes vote down vote up
/**
 * Sets a description line for the omnibox suggestion.
 *
 * @param str The description text.
 */
private void showDescriptionLine(Spannable str, int textColor) {
    if (mContentsView.mTextLine2.getVisibility() != VISIBLE) {
        mContentsView.mTextLine2.setVisibility(VISIBLE);
    }
    mContentsView.mTextLine2.setTextColor(textColor);
    mContentsView.mTextLine2.setText(str, BufferType.SPANNABLE);
}
 
Example 33
Project: Vafrinn   File: SuggestionView.java   View source code 5 votes vote down vote up
/**
 * Sets both lines of the Omnibox suggestion based on an Answers in Suggest result.
 *
 * @param answer The answer to be displayed.
 */
private void setAnswer(SuggestionAnswer answer) {
    float density = getResources().getDisplayMetrics().density;

    SuggestionAnswer.ImageLine firstLine = answer.getFirstLine();
    mContentsView.mTextLine1.setTextSize(AnswerTextBuilder.getMaxTextHeightSp(firstLine));
    Spannable firstLineText = AnswerTextBuilder.buildSpannable(
            firstLine, mContentsView.mTextLine1.getPaint().getFontMetrics(), density);
    mContentsView.mTextLine1.setText(firstLineText, BufferType.SPANNABLE);

    SuggestionAnswer.ImageLine secondLine = answer.getSecondLine();
    mContentsView.mTextLine2.setTextSize(AnswerTextBuilder.getMaxTextHeightSp(secondLine));
    Spannable secondLineText = AnswerTextBuilder.buildSpannable(
            secondLine, mContentsView.mTextLine2.getPaint().getFontMetrics(), density);
    mContentsView.mTextLine2.setText(secondLineText, BufferType.SPANNABLE);

    if (secondLine.hasImage()) {
        mContentsView.mAnswerImage.setVisibility(VISIBLE);

        float textSize = mContentsView.mTextLine2.getTextSize();
        int imageSize = (int) (textSize * ANSWER_IMAGE_SCALING_FACTOR);
        mContentsView.mAnswerImage.getLayoutParams().height = imageSize;
        mContentsView.mAnswerImage.getLayoutParams().width = imageSize;
        mContentsView.mAnswerImageMaxSize = imageSize;

        String url = "https:" + secondLine.getImage().replace("\\/", "/");
        AnswersImage.requestAnswersImage(
                mLocationBar.getCurrentTab().getProfile(),
                url,
                new AnswersImage.AnswersImageObserver() {
                    @Override
                    public void onAnswersImageChanged(Bitmap bitmap) {
                        mContentsView.mAnswerImage.setImageBitmap(bitmap);
                    }
                });
    }
}
 
Example 34
Project: nono-android   File: EaseChatRowText.java   View source code 5 votes vote down vote up
@Override
public void onSetUpView() {
    EMTextMessageBody txtBody = (EMTextMessageBody) message.getBody();
    Spannable span = EaseSmileUtils.getSmiledText(context, txtBody.getMessage());
    // 设置内容
    contentView.setText(span, BufferType.SPANNABLE);

    handleTextMessage();
}
 
Example 35
Project: FMTech   File: SetupWizardNavBar.java   View source code 5 votes vote down vote up
public void setText(CharSequence paramCharSequence, TextView.BufferType paramBufferType)
{
  if (getId() == 2131755301) {
    paramCharSequence = "";
  }
  super.setText(paramCharSequence, paramBufferType);
}
 
Example 36
Project: FMTech   File: CountdownButton.java   View source code 5 votes vote down vote up
public void setText(CharSequence paramCharSequence, TextView.BufferType paramBufferType)
{
  if ((this.mCapitalizeButtonText) && (!TextUtils.isEmpty(paramCharSequence)))
  {
    Locale localLocale = getResources().getConfiguration().locale;
    paramCharSequence = paramCharSequence.toString().toUpperCase(localLocale);
  }
  super.setText(paramCharSequence, paramBufferType);
}
 
Example 37
Project: juzidian   File: SearchResultItemView.java   View source code 5 votes vote down vote up
public void setDictionaryEntry(final DictionaryEntry entry) {
	final String pinyinDisplay = this.createPinyinDisplay(entry);
	final String englishDefinitionDisplay = this.createEnglishDefinitionDisplay(entry);
	this.chineseTextView.setText(entry.getSimplified() + " " + pinyinDisplay, BufferType.SPANNABLE);
	final Spannable chineseSpannable = (Spannable) this.chineseTextView.getText();
	final int pinyinStartIndex = entry.getSimplified().length();
	chineseSpannable.setSpan(SPAN_SIZE_HANZI, 0, pinyinStartIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
	this.definitionTextView.setText(englishDefinitionDisplay);
}
 
Example 38
Project: easeui   File: EaseChatRowText.java   View source code 5 votes vote down vote up
@Override
public void onSetUpView() {
    TextMessageBody txtBody = (TextMessageBody) message.getBody();
    Spannable span = EaseSmileUtils.getSmiledText(context, txtBody.getMessage());
    // 判断是不是阅后即焚的消息
    if (message.getBooleanAttribute(EaseConstant.EASE_ATTR_READFIRE, false) && message.direct == Direct.RECEIVE) {
        contentView.setText(
                String.format(context.getString(R.string.readfire_message_content), txtBody.getMessage().length()));
    } else {
        // 设置内容
        contentView.setText(span, BufferType.SPANNABLE);
    }
    handleTextMessage();
}
 
Example 39
Project: MedtronicUploader   File: DexcomG4Activity.java   View source code 5 votes vote down vote up
public void onServiceDisconnected(ComponentName className) {
    // This is called when the connection with the service has been unexpectedly disconnected - process crashed.
    mService = null;
    bService = null;
    Log.i(TAG,"Service Disconnected\n");
    if (ISDEBUG){
    	display.setText(display.getText()+"Service Disconnected\n", BufferType.EDITABLE);
    }
}
 
Example 40
Project: school_shop   File: MessageAdapter.java   View source code 5 votes vote down vote up
/**
 * 文本消息
 * 
 * @param message
 * @param holder
 * @param position
 */
private void handleTextMessage(EMMessage message, ViewHolder holder, final int position) {
	TextMessageBody txtBody = (TextMessageBody) message.getBody();
	Spannable span = SmileUtils.getSmiledText(context, txtBody.getMessage());
	// 设置内容
	holder.tv.setText(span, BufferType.SPANNABLE);
	// 设置长按事件监听
	holder.tv.setOnLongClickListener(new OnLongClickListener() {
		@Override
		public boolean onLongClick(View v) {
			activity.startActivityForResult(
					(new Intent(activity, ContextMenu.class)).putExtra("position", position).putExtra("type",
							EMMessage.Type.TXT.ordinal()), ChatActivity.REQUEST_CODE_CONTEXT_MENU);
			return true;
		}
	});

	if (message.direct == EMMessage.Direct.SEND) {
		switch (message.status) {
		case SUCCESS: // 发送成功
			holder.pb.setVisibility(View.GONE);
			holder.staus_iv.setVisibility(View.GONE);
			break;
		case FAIL: // 发送失败
			holder.pb.setVisibility(View.GONE);
			holder.staus_iv.setVisibility(View.VISIBLE);
			break;
		case INPROGRESS: // 发送中
			holder.pb.setVisibility(View.VISIBLE);
			holder.staus_iv.setVisibility(View.GONE);
			break;
		default:
			// 发送消息
			sendMsgInBackground(message, holder);
		}
	}
}