package com.lzx.demo.imageloader;
import android.widget.ImageView;
import com.lzx.demo.R;
/**
* Created by Lzx on 2016/12/8.
*/
public class ImageLoader {
private int type; // (Big,Medium,small)
private Object url; //url
private int placeHolder; //placeholder when fail to load pics
private ImageView imgView; //ImageView instantce
private int wifiStrategy;//load strategy ,wheather under wifi
private ImageLoader(Builder builder) {
this.type = builder.type;
this.url = builder.url;
this.placeHolder = builder.placeHolder;
this.imgView = builder.imgView;
this.wifiStrategy = builder.wifiStrategy;
}
public int getType() {
return type;
}
public Object getUrl() {
return url;
}
public int getPlaceHolder() {
return placeHolder;
}
public ImageView getImgView() {
return imgView;
}
public int getWifiStrategy() {
return wifiStrategy;
}
public static class Builder {
private int type;
private Object url;//url或者本地资源文件
private int placeHolder;
private ImageView imgView;
private int wifiStrategy;
public Builder() {
this.type = ImageLoaderUtil.PIC_SMALL;
this.url = "";
this.placeHolder = R.drawable.ic_photo_default;
this.imgView = null;
this.wifiStrategy = ImageLoaderUtil.LOAD_STRATEGY_NORMAL;
}
public Builder type(int type) {
this.type = type;
return this;
}
public Builder url(Object url) {
this.url = url;
return this;
}
public Builder placeHolder(int placeHolder) {
this.placeHolder = placeHolder;
return this;
}
public Builder imgView(ImageView imgView) {
this.imgView = imgView;
return this;
}
public Builder strategy(int strategy) {
this.wifiStrategy = strategy;
return this;
}
public ImageLoader build() {
return new ImageLoader(this);
}
}
}