当前位置: 首页>>代码示例>>Java>>正文


Java ImageGetter类代码示例

本文整理汇总了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);
}
 
开发者ID:babs,项目名称:android-customfonthtml,代码行数:23,代码来源:CustomHtml.java

示例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));
}
 
开发者ID:fei-ke,项目名称:ChipHellClient,代码行数:20,代码来源:PostItemView.java

示例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;
}
 
开发者ID:SilentCircle,项目名称:silent-contacts-android,代码行数:17,代码来源:ContactDetailDisplayUtils.java

示例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;
}
 
开发者ID:entboost,项目名称:EntboostIM,代码行数:33,代码来源:UIUtils.java

示例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;
		}
	};
}
 
开发者ID:zhangjingpu,项目名称:youkes_vr,代码行数:17,代码来源:EmoticonUtil.java

示例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;
}
 
开发者ID:babs,项目名称:android-customfonthtml,代码行数:11,代码来源:CustomHtml.java

示例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;
}
 
开发者ID:huibinfeng0810,项目名称:github-v2,代码行数:17,代码来源:MarkdownLoader.java

示例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);
}
 
开发者ID:huibinfeng0810,项目名称:github-v2,代码行数:15,代码来源:HtmlUtils.java

示例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));
}
 
开发者ID:SilentCircle,项目名称:silent-contacts-android,代码行数:12,代码来源:HtmlUtils.java

示例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\\-\\.,@?^=%&amp;:/~\\+#]*[\\w\\-\\@?^=%&amp;/~\\+#])?",
            Pattern.CASE_INSENSITIVE);
    Linkify.addLinks(comment, http, "http://");
    Linkify.addLinks(comment, Pattern.compile("(ac\\d{5,})", Pattern.CASE_INSENSITIVE), "av://");
}
 
开发者ID:xiaochenai,项目名称:acfun-new,代码行数:41,代码来源:TextViewUtils.java

示例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;
}
 
开发者ID:crowdint,项目名称:emojimenu,代码行数:16,代码来源:EmojiParser.java

示例12: FromHtmlCache

import android.text.Html.ImageGetter; //导入依赖的package包/类
public FromHtmlCache() {
    dummyImageGetter = new ImageGetter() {

        @Override
        public Drawable getDrawable(String source) {
            return NOTHING;
        }
    };
}
 
开发者ID:gpodder,项目名称:detlef,代码行数:10,代码来源:EpisodeListAdapter.java

示例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;
}
 
开发者ID:ifLab,项目名称:WeCenterMobile-Android,代码行数:61,代码来源:TextShow.java

示例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;
}
 
开发者ID:SilentCircle,项目名称:silent-contacts-android,代码行数:7,代码来源:ContactDetailDisplayUtils.java


注:本文中的android.text.Html.ImageGetter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。