2020-08-11 14:48:10 +08:00
|
|
|
|
package com.lzy.ninegrid;
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
|
import android.widget.ImageView;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
public abstract class NineGridViewAdapter implements Serializable {
|
|
|
|
|
|
|
|
|
|
|
|
protected Context context;
|
|
|
|
|
|
private List<ImageInfo> imageInfo;
|
|
|
|
|
|
|
|
|
|
|
|
public NineGridViewAdapter(Context context, List<ImageInfo> imageInfo) {
|
|
|
|
|
|
this.context = context;
|
|
|
|
|
|
this.imageInfo = imageInfo;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 如果要实现图片点击的逻辑,重写此方法即可
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param context 上下文
|
|
|
|
|
|
* @param nineGridView 九宫格控件
|
|
|
|
|
|
* @param index 当前点击图片的的索引
|
|
|
|
|
|
* @param imageInfo 图片地址的数据集合
|
|
|
|
|
|
*/
|
|
|
|
|
|
protected void onImageItemClick(Context context, NineGridView nineGridView, int index, List<ImageInfo> imageInfo) {
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 生成ImageView容器的方式,默认使用NineGridImageViewWrapper类,即点击图片后,图片会有蒙板效果
|
|
|
|
|
|
* 如果需要自定义图片展示效果,重写此方法即可
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param context 上下文
|
2020-09-02 15:33:38 +08:00
|
|
|
|
* @param type
|
2020-08-11 14:48:10 +08:00
|
|
|
|
* @return 生成的 ImageView
|
|
|
|
|
|
*/
|
2020-09-02 15:33:38 +08:00
|
|
|
|
protected NineGridViewWrapper generateImageView(Context context, int type) {
|
2020-08-11 14:48:10 +08:00
|
|
|
|
NineGridViewWrapper imageView = new NineGridViewWrapper(context);
|
2020-09-02 15:33:38 +08:00
|
|
|
|
imageView.setType(type);
|
2021-01-22 14:53:58 +08:00
|
|
|
|
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
2020-08-11 14:48:10 +08:00
|
|
|
|
imageView.setImageResource(R.drawable.ic_default_color);
|
|
|
|
|
|
return imageView;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<ImageInfo> getImageInfo() {
|
|
|
|
|
|
return imageInfo;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setImageInfoList(List<ImageInfo> imageInfo) {
|
|
|
|
|
|
this.imageInfo = imageInfo;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|