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

add placeHolder #186

Merged
merged 1 commit into from
Sep 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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