Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

Commit

Permalink
Merge pull request #186 from mazhenming892/master
Browse files Browse the repository at this point in the history
add placeHolder
  • Loading branch information
dschuermann authored Sep 7, 2020
2 parents bb5fc08 + dea9593 commit 2c308e5
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class HtmlHttpImageGetter implements ImageGetter {
private TextView container;
private URI baseUri;
private boolean matchParentWidth;
private int placeHolder;

private boolean compressImage = false;
private int qualityImage = 50;
Expand All @@ -58,7 +59,12 @@ public HtmlHttpImageGetter(TextView textView, String baseUrl) {
}

public HtmlHttpImageGetter(TextView textView, String baseUrl, boolean matchParentWidth) {
this(textView,baseUrl,0,matchParentWidth);
}

public HtmlHttpImageGetter(TextView textView, String baseUrl,int placeHolder, boolean matchParentWidth) {
this.container = textView;
this.placeHolder = placeHolder;
this.matchParentWidth = matchParentWidth;
if (baseUrl != null) {
this.baseUri = URI.create(baseUrl);
Expand All @@ -76,7 +82,12 @@ public void enableCompressImage(boolean enable, int quality) {

public Drawable getDrawable(String source) {
UrlDrawable urlDrawable = new UrlDrawable();

if (placeHolder != 0) {
Drawable placeDrawable = container.getContext().getResources().getDrawable(placeHolder);
placeDrawable.setBounds(0, 0, placeDrawable.getIntrinsicWidth(), placeDrawable.getIntrinsicHeight());
urlDrawable.setBounds(0, 0, placeDrawable.getIntrinsicWidth(), placeDrawable.getIntrinsicHeight());
urlDrawable.drawable = placeDrawable;
}
// get the actual source
ImageGetterAsyncTask asyncTask = new ImageGetterAsyncTask(urlDrawable, this, container,
matchParentWidth, compressImage, qualityImage);
Expand Down

0 comments on commit 2c308e5

Please sign in to comment.