List of usage examples for android.text.style ImageSpan ImageSpan
public ImageSpan(@NonNull Drawable drawable)
From source file:tv.acfun.a63.CommentsActivity.java
private void initCommentsBar() { mCommentBar = findViewById(R.id.comments_bar); if (ActionBarUtil.hasSB() && getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE) { RelativeLayout.LayoutParams params = (LayoutParams) mCommentBar.getLayoutParams(); params.bottomMargin = getResources().getDimensionPixelSize(R.dimen.abc_action_bar_default_height); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); mCommentBar.setLayoutParams(params); }//from ww w .j ava 2s.c o m mBtnSend = (ImageButton) findViewById(R.id.comments_send_btn); mCommentText = (EditText) findViewById(R.id.comments_edit); mBtnEmotion = findViewById(R.id.comments_emotion_btn); mEmotionGrid = (GridView) findViewById(R.id.emotions); mBtnSend.setOnClickListener(this); mBtnEmotion.setOnClickListener(this); mEmotionGrid.setAdapter(mEmotionAdapter); mEmotionGrid.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { int index = mCommentText.getSelectionEnd(); Editable text = mCommentText.getText(); String emotion = parent.getItemAtPosition(position).toString(); text.insert(index, emotion); EmotionView v = (EmotionView) parent.getAdapter().getView(position, null, null); Drawable drawable = TextViewUtils.convertViewToDrawable(v); drawable.setBounds(0, 0, drawable.getIntrinsicWidth() / 2, drawable.getIntrinsicHeight() / 2); text.setSpan(new ImageSpan(drawable), index, index + emotion.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } }); }
From source file:com.hippo.ehviewer.ui.scene.GalleryListScene.java
private void setSearchBarHint(Context context, SearchBar searchBar) { Resources resources = context.getResources(); Drawable searchImage = DrawableManager.getDrawable(context, R.drawable.v_magnify_x24); SpannableStringBuilder ssb = new SpannableStringBuilder(" "); ssb.append(resources.getString(/*from ww w . j a v a 2s .c o m*/ EhUrl.SITE_EX == Settings.getGallerySite() ? R.string.gallery_list_search_bar_hint_exhentai : R.string.gallery_list_search_bar_hint_e_hentai)); int textSize = (int) (searchBar.getEditTextTextSize() * 1.25); if (searchImage != null) { searchImage.setBounds(0, 0, textSize, textSize); ssb.setSpan(new ImageSpan(searchImage), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } searchBar.setEditTextHint(ssb); }
From source file:com.hippo.ehviewer.ui.scene.FavoritesScene.java
private void updateSearchBar() { Context context = getContext2(); if (null == context || null == mUrlBuilder || null == mSearchBar || null == mFavCatArray) { return;//w w w . j a va2 s .com } // Update title int favCat = mUrlBuilder.getFavCat(); String favCatName; if (favCat >= 0 && favCat < 10) { favCatName = mFavCatArray[favCat]; } else if (favCat == FavListUrlBuilder.FAV_CAT_LOCAL) { favCatName = getString(R.string.local_favorites); } else { favCatName = getString(R.string.cloud_favorites); } String keyword = mUrlBuilder.getKeyword(); if (TextUtils.isEmpty(keyword)) { if (!ObjectUtils.equal(favCatName, mOldFavCat)) { mSearchBar.setTitle(getString(R.string.favorites_title, favCatName)); } } else { if (!ObjectUtils.equal(favCatName, mOldFavCat) || !ObjectUtils.equal(keyword, mOldKeyword)) { mSearchBar.setTitle(getString(R.string.favorites_title_2, favCatName, keyword)); } } // Update hint if (!ObjectUtils.equal(favCatName, mOldFavCat)) { Drawable searchImage = DrawableManager.getDrawable(context, R.drawable.v_magnify_x24); SpannableStringBuilder ssb = new SpannableStringBuilder(" "); ssb.append(getString(R.string.favorites_search_bar_hint, favCatName)); int textSize = (int) (mSearchBar.getEditTextTextSize() * 1.25); if (searchImage != null) { searchImage.setBounds(0, 0, textSize, textSize); ssb.setSpan(new ImageSpan(searchImage), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } mSearchBar.setEditTextHint(ssb); } mOldFavCat = favCatName; mOldKeyword = keyword; // Save recent fav cat Settings.putRecentFavCat(mUrlBuilder.getFavCat()); }
From source file:tv.acfun.video.CommentsActivity.java
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { int count = mAdapter.getCount(); if (position > count) { if (isreload) { mFootview.findViewById(R.id.list_footview_progress).setVisibility(View.VISIBLE); TextView textview = (TextView) mFootview.findViewById(R.id.list_footview_text); textview.setText(R.string.buffering); requestData(pageIndex, false); }//from w w w .j a v a 2 s .c o m return; } // showBar(); //TODO: show input bar when selected comment Object o = parent.getItemAtPosition(position); if (o == null || !(o instanceof Comment)) return; Comment c = (Comment) o; int quoteCount = getQuoteCount(); removeQuote(mCommentText.getText()); if (quoteCount == c.count) return; // ? String pre = ":#" + c.count; mQuoteSpan = new Quote(c.count); SpannableStringBuilder sb = SpannableStringBuilder.valueOf(mCommentText.getText()); TextView tv = TextViewUtils.createBubbleTextView(this, pre); BitmapDrawable bd = (BitmapDrawable) TextViewUtils.convertViewToDrawable(tv); bd.setBounds(0, 0, bd.getIntrinsicWidth(), bd.getIntrinsicHeight()); sb.insert(0, pre); mQuoteImage = new ImageSpan(bd); sb.setSpan(mQuoteImage, 0, pre.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); sb.setSpan(mQuoteSpan, 0, pre.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); sb.append(""); mCommentText.setText(sb); mCommentText.setSelection(mCommentText.getText().length()); }
From source file:cn.figo.mydemo.ui.activity.VideoActivity.java
private SpannableStringBuilder createSpannable(Drawable drawable) { String text = "bitmap"; SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(text); ImageSpan span = new ImageSpan(drawable);//ImageSpan.ALIGN_BOTTOM); spannableStringBuilder.setSpan(span, 0, text.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); spannableStringBuilder.append(""); spannableStringBuilder.setSpan(new BackgroundColorSpan(Color.parseColor("#8A2233B1")), 0, spannableStringBuilder.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); return spannableStringBuilder; }
From source file:tv.acfun.a63.CommentsActivity.java
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { int count = mAdapter.getCount(); if (position > count) { if (isreload) { mFootview.findViewById(R.id.list_footview_progress).setVisibility(View.VISIBLE); TextView textview = (TextView) mFootview.findViewById(R.id.list_footview_text); textview.setText(R.string.loading); requestData(pageIndex, false); }/* w ww . ja va2 s. co m*/ return; } showBar(); // show input bar when selected comment Object o = parent.getItemAtPosition(position); if (o == null || !(o instanceof Comment)) return; Comment c = (Comment) o; int quoteCount = getQuoteCount(); removeQuote(mCommentText.getText()); if (quoteCount == c.count) return; // ? String pre = ":#" + c.count; mQuoteSpan = new Quote(c.count); /** * @see http * ://www.kpbird.com/2013/02/android-chips-edittext-token-edittext * .html */ SpannableStringBuilder sb = SpannableStringBuilder.valueOf(mCommentText.getText()); TextView tv = TextViewUtils.createBubbleTextView(this, pre); BitmapDrawable bd = (BitmapDrawable) TextViewUtils.convertViewToDrawable(tv); bd.setBounds(0, 0, bd.getIntrinsicWidth(), bd.getIntrinsicHeight()); sb.insert(0, pre); mQuoteImage = new ImageSpan(bd); sb.setSpan(mQuoteImage, 0, pre.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); sb.setSpan(mQuoteSpan, 0, pre.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); sb.append(""); mCommentText.setText(sb); mCommentText.setSelection(mCommentText.getText().length()); }
From source file:com.forrestguice.suntimeswidget.SuntimesUtils.java
public static ImageSpan createImageSpan(Context context, int drawableID, int width, int height, int tint) { Drawable drawable = null;//from w w w. j a va2 s . c o m try { drawable = context.getResources().getDrawable(drawableID); } catch (Exception e) { Log.e("createImageSpan", "invalid drawableID " + drawableID + "! ...set to null."); } if (drawable != null) { if (width > 0 && height > 0) { drawable.setBounds(0, 0, width, height); } drawable.setColorFilter(tint, PorterDuff.Mode.SRC_ATOP); } return new ImageSpan(drawable); }
From source file:com.forrestguice.suntimeswidget.SuntimesUtils.java
public static ImageSpan createImageSpan(ImageSpan other) { Drawable drawable = null;//from w ww .ja v a 2 s. c o m if (other != null) drawable = other.getDrawable(); return new ImageSpan(drawable); }
From source file:lewa.support.v7.widget.SearchView.java
private CharSequence getDecoratedHint(CharSequence hintText) { // If the field is always expanded, then don't add the search icon to the hint if (!mIconifiedByDefault) return hintText; SpannableStringBuilder ssb = new SpannableStringBuilder(" "); // for the icon ssb.append(hintText);//from w ww . j a va2s . c o m Drawable searchIcon = getContext().getResources().getDrawable(mSearchIconResId); int textSize = (int) (mQueryTextView.getTextSize() * 1.25); searchIcon.setBounds(0, 0, textSize, textSize); ssb.setSpan(new ImageSpan(searchIcon), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); return ssb; }
From source file:android.support.v7.widget.SearchView.java
private CharSequence getDecoratedHint(CharSequence hintText) { // If the field is always expanded or we don't have a search hint icon, // then don't add the search icon to the hint. if (!mIconifiedByDefault || mSearchHintIcon == null) { return hintText; }// ww w. j ava2 s .co m final int textSize = (int) (mSearchSrcTextView.getTextSize() * 1.25); mSearchHintIcon.setBounds(0, 0, textSize, textSize); final SpannableStringBuilder ssb = new SpannableStringBuilder(" "); ssb.setSpan(new ImageSpan(mSearchHintIcon), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); ssb.append(hintText); return ssb; }