Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
hzwangchenyan committed Jun 6, 2017
1 parent 2249848 commit 08c963d
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ HtmlText 是 android.text.Html 的一个扩展,可以加载 HTML 并将其转
- `<font color="..." face="...">`
- `<h1>`, `<h2>`, `<h3>`, `<h4>`, `<h5>`, `<h6>`
- `<a href="...">`
- `<img src="...">`
- `< img src="...">`

### Extended support by HtmlText

Expand All @@ -43,7 +43,7 @@ HtmlText 是 android.text.Html 的一个扩展,可以加载 HTML 并将其转
- `<strike>`
- `<div>`[HTML contains two newline, there is one]
- `<font size="..." color="...">`[extend support size]
- `<img src="..." width="..." height="...">`[extend support width, height]
- `< img src="..." width="..." height="...">`[extend support width, height]

## Sample

Expand All @@ -58,7 +58,7 @@ HtmlText.from(sample)
@Override
public void loadImage(String url, final Callback callback) {
// Glide sample, you can also use other image loader
Glide.with(MainActivity.this)
Glide.with(context)
.load(url)
.asBitmap()
.into(new SimpleTarget<Bitmap>() {
Expand All @@ -77,12 +77,12 @@ HtmlText.from(sample)
@Override
public Drawable getDefaultDrawable() {
return ContextCompat.getDrawable(MainActivity.this, R.drawable.image_placeholder_loading);
return ContextCompat.getDrawable(context, R.drawable.image_placeholder_loading);
}
@Override
public Drawable getErrorDrawable() {
return ContextCompat.getDrawable(MainActivity.this, R.drawable.image_placeholder_fail);
return ContextCompat.getDrawable(context, R.drawable.image_placeholder_fail);
}
@Override
Expand All @@ -97,18 +97,22 @@ HtmlText.from(sample)
})
.setOnTagClickListener(new OnTagClickListener() {
@Override
public void onImageClick(List<String> imageUrlList, int position) {
public void onImageClick(Context context, List<String> imageUrlList, int position) {
// image click
}
@Override
public void onLinkClick(String url) {
public void onLinkClick(Context context, String url) {
// link click
}
})
.into(textView);
```

## Download

Github: [HtmlText](https://github.com/wangchenyan/HtmlText)

## Thanks

- [html-textview](https://github.com/SufficientlySecure/html-textview)
Expand Down

0 comments on commit 08c963d

Please sign in to comment.