简单的Android浏览器
compile 'com.hqs.common.helper.imagebrowser:imagebrowser:1.1.19'
如果在缩放图片时出现莫名其妙的bug,由于使用了类的反射机制, 需要注意代码混淆
-keep class com.bm.library.** {*;}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
MyViewHolder myViewHolder = (MyViewHolder) holder;
myViewHolder.imageView.setImageDrawable(Drawable.createFromPath(files.get(position)));
myViewHolder.imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// 生成图片源数据
ArrayList<QImage> imgs = new ArrayList<>();
for (int i = 0; i < files.size(); i++) {
QImage qImage = new QImage();
qImage.filePathOrUrl = files.get(i);
if(i == position){
qImage.srcImageView = (ImageView) v;
}
imgs.add(qImage);
}
// 设置占位图片
ImageBrowser.placeHolderImageRes = R.mipmap.ic_launcher;
// 开始浏览图片
ImageBrowser.showWithImages(LocalImageActivity.this, imgs, position);
}
});
}