本文整理汇总了Java中android.text.Html.ImageGetter类的典型用法代码示例。如果您正苦于以下问题:Java ImageGetter类的具体用法?Java ImageGetter怎么用?Java ImageGetter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ImageGetter类属于android.text.Html包,在下文中一共展示了ImageGetter类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startImg
import android.text.Html.ImageGetter; //导入依赖的package包/类
private static void startImg(SpannableStringBuilder text,
Attributes attributes, Html.ImageGetter img) {
String src = attributes.getValue("", "src");
Drawable d = null;
if (img != null) {
d = img.getDrawable(src);
}
if (d == null) {
// com.android.internal.R.drawable.unknown_image
d = Resources.getSystem().getDrawable(
android.R.drawable.ic_menu_help);
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
}
int len = text.length();
text.append("\uFFFC");
text.setSpan(new ImageSpan(d, src), len, text.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
示例2: bindValue
import android.text.Html.ImageGetter; //导入依赖的package包/类
public void bindValue(Post post) {
ImageLoader.getInstance().displayImage(post.getAvatarUrl(), imageViewAvatar, Constants.avatarDisplayOption, animateFirstListener);
textViewAuthi.setText(Html.fromHtml(post.getAuthi()));
String content = post.getContent();
if (post.getImgList() != null) {
content += post.getImgList();
}
textViewContent.setText(Html.fromHtml(content, new ImageGetter() {
@Override
public Drawable getDrawable(String source) {
if (!source.startsWith("http:")) {
source = Constants.BASE_URL + source;
}
LogMessage.i("PostItemView", source);
return new UrlDrawable(source, textViewContent);
}
}, null));
}
示例3: addStreamItemText
import android.text.Html.ImageGetter; //导入依赖的package包/类
@VisibleForTesting
static View addStreamItemText(Context context, StreamItemEntry streamItem, View rootView) {
TextView htmlView = (TextView) rootView.findViewById(R.id.stream_item_html);
TextView attributionView = (TextView) rootView.findViewById(R.id.stream_item_attribution);
TextView commentsView = (TextView) rootView.findViewById(R.id.stream_item_comments);
ImageGetter imageGetter = new DefaultImageGetter(context.getPackageManager());
// Stream item text
setDataOrHideIfNone(streamItem.getDecodedText(), htmlView);
// Attribution
setDataOrHideIfNone(ContactBadgeUtil.getSocialDate(streamItem, context),
attributionView);
// Comments
setDataOrHideIfNone(streamItem.getDecodedComments(), commentsView);
return rootView;
}
示例4: getTipCharSequence
import android.text.Html.ImageGetter; //导入依赖的package包/类
/**
* 展示html代码(包含图片)
*
* @param res 系统资源对象
* @param html 消息内容
* @param smallEmotion 表情图标是否以小尺寸显示
* @return
*/
public static CharSequence getTipCharSequence(final Resources res, final String html, final boolean smallEmotion) {
if (StringUtils.isBlank(html)) {
return "";
}
String newHtml = html.replaceAll("\r\n", "<br/>");
newHtml = newHtml.replaceAll("\n", "<br/>");
newHtml = newHtml.replaceAll("\r", "<br/>");
CharSequence charSequence = Html.fromHtml(newHtml, new ImageGetter() {
@Override
public Drawable getDrawable(String source) {
BitmapDrawable drawable = new BitmapDrawable(res, YIResourceUtils.getResourceBitmap(
Long.valueOf(source), EB_RESOURCE_TYPE.EB_RESOURCE_EMOTION.ordinal()));
int right = 60, bottom = 60;
if (smallEmotion)
right = bottom =40;
drawable.setBounds(0, 0, right, bottom);// 设置表情图片的显示大小
return drawable;
}
}, null);
return charSequence;
}
示例5: getImageGetter
import android.text.Html.ImageGetter; //导入依赖的package包/类
/**
* @param c
* @return
*/
public static ImageGetter getImageGetter(final Context c) {
return new ImageGetter() {
public Drawable getDrawable(String source) {
System.out.println("source ="+source);
Integer resID=c.getResources().getIdentifier(source,"drawable", c.getPackageName());
Drawable d = c.getResources().getDrawable(resID);
d.setBounds(0, 0, 24, 24);
return d;
}
};
}
示例6: HtmlToSpannedConverter
import android.text.Html.ImageGetter; //导入依赖的package包/类
public HtmlToSpannedConverter(String source,
ICustomFontLoader fontLoader, Html.ImageGetter imageGetter,
Html.TagHandler tagHandler, Parser parser) {
mSource = source;
mSpannableStringBuilder = new SpannableStringBuilder();
mFontLoader = fontLoader;
mImageGetter = imageGetter;
mTagHandler = tagHandler;
mReader = parser;
}
示例7: MarkdownLoader
import android.text.Html.ImageGetter; //导入依赖的package包/类
/**
* @param context
* @param repository
* @param raw
* @param imageGetter
* @param encode
*/
public MarkdownLoader(Context context, IRepositoryIdProvider repository,
String raw, ImageGetter imageGetter, boolean encode) {
super(context);
this.repository = repository;
this.raw = raw;
this.imageGetter = imageGetter;
this.encode = encode;
}
示例8: encode
import android.text.Html.ImageGetter; //导入依赖的package包/类
/**
* Encode HTML
*
* @param html
* @param imageGetter
* @return html
*/
public static CharSequence encode(final String html,
final ImageGetter imageGetter) {
if (TextUtils.isEmpty(html))
return "";
return android.text.Html.fromHtml(html, imageGetter, TAG_HANDLER);
}
示例9: fromHtml
import android.text.Html.ImageGetter; //导入依赖的package包/类
/**
* Converts HTML string to a {@link Spanned} text, adjusting formatting and using a custom
* image getter. Any extra new line characters at the end of the text will be trimmed.
*/
public static CharSequence fromHtml(Context context, String text, ImageGetter imageGetter,
TagHandler tagHandler) {
if (TextUtils.isEmpty(text)) {
return null;
}
return postprocess(context, Html.fromHtml(text, imageGetter, tagHandler));
}
示例10: setCommentContent
import android.text.Html.ImageGetter; //导入依赖的package包/类
public static void setCommentContent(final TextView comment, Comment c) {
String text = c.content;
text = replace(text);
comment.setText(Html.fromHtml(text,new ImageGetter() {
@Override
public Drawable getDrawable(String source) {
try {
Drawable drawable = Drawable.createFromStream(comment.getContext().getAssets().open(source),source);
if(drawable!=null)
drawable.setBounds(0, 0, drawable.getIntrinsicWidth()*(int)AcApp.density, drawable.getIntrinsicHeight()*(int)AcApp.density);
return drawable;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
},new Html.TagHandler() {
@Override
public void handleTag(boolean opening, String tag, Editable output, XMLReader xmlReader) {
int len = output.length();
if(opening){
if(tag.equalsIgnoreCase("strike")){
output.setSpan(new StrikethroughSpan(), len, len, Spannable.SPAN_MARK_MARK);
}
}else{
if(tag.equalsIgnoreCase("strike")){
end((SpannableStringBuilder) output,StrikethroughSpan.class,new StrikethroughSpan());
}
}
}
}));
comment.setTextColor(Color.BLACK);
Pattern http = Pattern.compile("http://[\\w\\-_]+(\\.[\\w\\-_]+)+([\\w\\-\\.,@?^=%&:/~\\+#]*[\\w\\-\\@?^=%&/~\\+#])?",
Pattern.CASE_INSENSITIVE);
Linkify.addLinks(comment, http, "http://");
Linkify.addLinks(comment, Pattern.compile("(ac\\d{5,})", Pattern.CASE_INSENSITIVE), "av://");
}
示例11: insertEmoji
import android.text.Html.ImageGetter; //导入依赖的package包/类
private Spanned insertEmoji(final String name) {
ImageGetter imageGetter = new ImageGetter() {
public Drawable getDrawable(String source) {
Bitmap bitmap = emojiStore.getBitmap(name);
Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, 30, 30, true);
Drawable d = new BitmapDrawable(
emojiStore.getActivity().getResources(), scaledBitmap);
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
return d;
}
};
Spanned cs = Html.fromHtml("<img src ='" + name + "'/>", imageGetter, null);
return cs;
}
示例12: FromHtmlCache
import android.text.Html.ImageGetter; //导入依赖的package包/类
public FromHtmlCache() {
dummyImageGetter = new ImageGetter() {
@Override
public Drawable getDrawable(String source) {
return NOTHING;
}
};
}
示例13: doInBackground
import android.text.Html.ImageGetter; //导入依赖的package包/类
@Override
protected Spanned doInBackground(String... arg0) {
// TODO Auto-generated method stub
final Spanned spanned;
ImageGetter imgGetter = new Html.ImageGetter() {
@SuppressWarnings("deprecation")
@Override
public Drawable getDrawable(String source) {
Drawable d = null;
Bitmap bm = null;
urlSpans.add(source);
String url = source.replaceAll("[^\\w]", "");
String imageurl = Environment
.getExternalStorageDirectory()
+ "/fanfantopic/" + url;
try {
if (!fileUtils.isFileExists(url)
|| fileUtils.getFileSize(url) == 0) {
InputStream is = null;
HttpResponse httpResponse = new DefaultHttpClient()
.execute(new HttpGet(source));
if (httpResponse.getStatusLine().getStatusCode() == 200) {
is = httpResponse.getEntity()
.getContent();
} else {
System.out.println("���粻��");
}
bm = BitmapFactory.decodeStream(is);
fileUtils.saveBitmap(source.replaceAll("[^\\w]", ""),
bm);
is.close();
} else {
//ImageGet imageGet = new ImageGet();
bm = BitmapFactory.decodeFile(imageurl);
//bm = imageGet.getBitmap();
}
d = new BitmapDrawable(bm);
if (bm.getWidth() >= screenW-100) {
float so = ((float)(bm.getHeight())/bm.getWidth());
float h = (screenW-100)*so;
d.setBounds(0, 0,(int)(screenW-100),(int)h);
} else {
start = (int) (screenW - bm.getWidth())/2;
d.setBounds(start, 0,bm.getWidth()+start,bm.getHeight());
}
} catch (Exception e) {
e.printStackTrace();
}
return d;
}
};
spanned = Html.fromHtml(text, imgGetter, new ImgTaghand());
return spanned;
}
示例14: getImageGetter
import android.text.Html.ImageGetter; //导入依赖的package包/类
public static Html.ImageGetter getImageGetter(Context context) {
if (sImageGetter == null) {
sImageGetter = new DefaultImageGetter(context.getPackageManager());
}
return sImageGetter;
}