use of com.lingtuan.firefly.imagescan.PhotoView in project SmartMesh_Android by SmartMeshFoundation.
the class ScanPicAdapter method instantiateItem.
@Override
public View instantiateItem(ViewGroup container, final int position) {
FrameLayout imageLayout = (FrameLayout) View.inflate(context, R.layout.item_photo_image, null);
final PhotoView photoView = new PhotoView(context, btPhoto);
ViewGroup.LayoutParams lp = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
imageLayout.addView(photoView, lp);
final ProgressBar spinner = (ProgressBar) imageLayout.findViewById(R.id.loading);
btPhoto.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (isOurSelf && stcb != null) {
isShowTitle = !isShowTitle;
stcb.showTitleCallBack(String.valueOf(getCount()), isShowTitle);
} else {
// close
if (fcb != null) {
fcb.finishCallBack();
}
}
}
});
photoView.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View arg0) {
final String oldPath = NextApplication.mImageLoader.getDiscCache().get(imageList.get(position)).getPath();
File oldfile = new File(oldPath);
if (!oldfile.exists()) {
// Picture has not been downloaded
return true;
}
if (longClickCallback != null) {
longClickCallback.onLongClickCallback(oldPath);
}
return true;
}
});
NextApplication.displayNothing(photoView, imageList.get(position), new ImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
spinner.setVisibility(View.VISIBLE);
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
spinner.setVisibility(View.GONE);
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
spinner.setVisibility(View.GONE);
}
@Override
public void onLoadingCancelled(String imageUri, View view) {
spinner.setVisibility(View.GONE);
}
});
container.addView(imageLayout, 0);
return imageLayout;
}
Aggregations