Search in sources :

Example 1 with PhotoView

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;
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) ImageLoadingListener(com.nostra13.universalimageloader.core.listener.ImageLoadingListener) ViewGroup(android.view.ViewGroup) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) PhotoView(com.lingtuan.firefly.imagescan.PhotoView) View(android.view.View) PhotoView(com.lingtuan.firefly.imagescan.PhotoView) Bitmap(android.graphics.Bitmap) FrameLayout(android.widget.FrameLayout) OnLongClickListener(android.view.View.OnLongClickListener) OnClickListener(android.view.View.OnClickListener) LayoutParams(android.view.ViewGroup.LayoutParams) ProgressBar(android.widget.ProgressBar) File(java.io.File)

Aggregations

Bitmap (android.graphics.Bitmap)1 View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 OnLongClickListener (android.view.View.OnLongClickListener)1 ViewGroup (android.view.ViewGroup)1 LayoutParams (android.view.ViewGroup.LayoutParams)1 FrameLayout (android.widget.FrameLayout)1 ProgressBar (android.widget.ProgressBar)1 PhotoView (com.lingtuan.firefly.imagescan.PhotoView)1 FailReason (com.nostra13.universalimageloader.core.assist.FailReason)1 ImageLoadingListener (com.nostra13.universalimageloader.core.listener.ImageLoadingListener)1 File (java.io.File)1