Example usage for android.widget ProgressBar getTag

List of usage examples for android.widget ProgressBar getTag

Introduction

In this page you can find the example usage for android.widget ProgressBar getTag.

Prototype

@ViewDebug.ExportedProperty
public Object getTag() 

Source Link

Document

Returns this view's tag.

Usage

From source file:com.uzmap.pkg.uzmodules.photoBrowser.ImageBrowserAdapter.java

@Override
public Object instantiateItem(ViewGroup container, final int position) {

    mViewContainer = container;/* w w w  .j  a  v  a 2s .c om*/

    int item_view_id = UZResourcesIDFinder.getResLayoutID("photo_browser_item_layout");
    View itemView = View.inflate(mContext, item_view_id, null);

    itemView.setTag(position);

    int photo_view_id = UZResourcesIDFinder.getResIdID("photoView");
    final PhotoView imageView = (PhotoView) itemView.findViewById(photo_view_id);

    imageView.setZoomable(this.zoomEnable);

    int load_progress_id = UZResourcesIDFinder.getResIdID("loadProgress");
    final ProgressBar progress = (ProgressBar) itemView.findViewById(load_progress_id);
    progress.setTag(position);

    mImageLoader.load(imageView, progress, mImagePaths.get(position));

    mImageLoader.setOnLoadCompleteListener(new OnLoadCompleteListener() {
        @Override
        public void onLoadComplete(ProgressBar bar) {
            PhotoBrowser.callback(mUZContext, PhotoBrowser.EVENT_TYPE_LOADSUCCESSED, (Integer) bar.getTag());
        }

        @Override
        public void onLoadFailed(final ProgressBar bar) {
            PhotoBrowser.callback(mUZContext, PhotoBrowser.EVENT_TYPE_LOADFAILED, (Integer) bar.getTag());
            new Handler(Looper.getMainLooper()).post(new Runnable() {
                @Override
                public void run() {
                    bar.setVisibility(View.GONE);
                }
            });
        }
    });

    imageView.setOnViewTapListener(new OnViewTapListener() {

        @Override
        public void onViewTap(View arg0, float arg1, float arg2) {
            PhotoBrowser.callback(mUZContext, PhotoBrowser.EVENT_TYPE_CLICK, position);
        }
    });

    imageView.setOnPhotoTapListener(new OnPhotoTapListener() {
        @Override
        public void onPhotoTap(View arg0, float arg1, float arg2) {
            PhotoBrowser.callback(mUZContext, PhotoBrowser.EVENT_TYPE_CLICK, position);
        }
    });

    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            PhotoBrowser.callback(mUZContext, PhotoBrowser.EVENT_TYPE_CLICK, position);
        }
    });

    imageView.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            PhotoBrowser.callback(mUZContext, PhotoBrowser.EVENT_TYPE_LONG_CLICK, position);
            return false;
        }
    });

    container.addView(itemView);
    return itemView;
}

From source file:com.uzmap.pkg.uzmodules.photoBrowser.PhotoBrowser.java

public void jsmethod_setImage(UZModuleContext uzContext) {
    int index = uzContext.optInt("index");
    String imagePath = uzContext.optString("image");

    if (!imagePath.startsWith("http")) {
        imagePath = UZUtility.makeRealPath(imagePath, getWidgetInfo());
    }/*from   w  w  w. j a  va 2 s .  c  o m*/

    if (index >= 0 && index < mAdapter.getCount() && !TextUtils.isEmpty(imagePath)) {
        View view = getExistChild(index);
        if (view != null) {

            int photo_view_id = UZResourcesIDFinder.getResIdID("photoView");
            final PhotoView imageView = (PhotoView) view.findViewById(photo_view_id);

            int load_progress_id = UZResourcesIDFinder.getResIdID("loadProgress");
            final ProgressBar progress = (ProgressBar) view.findViewById(load_progress_id);

            mLoader.load(imageView, progress, imagePath);

            if (mUZContext == null) {
                return;
            }

            mLoader.setOnLoadCompleteListener(new OnLoadCompleteListener() {
                @Override
                public void onLoadComplete(ProgressBar bar) {
                    PhotoBrowser.callback(mUZContext, PhotoBrowser.EVENT_TYPE_LOADSUCCESSED,
                            (Integer) bar.getTag());
                }

                @Override
                public void onLoadFailed(final ProgressBar bar) {
                    PhotoBrowser.callback(mUZContext, PhotoBrowser.EVENT_TYPE_LOADFAILED,
                            (Integer) bar.getTag());
                    new Handler(Looper.getMainLooper()).post(new Runnable() {
                        @Override
                        public void run() {
                            bar.setVisibility(View.GONE);
                        }
                    });
                }
            });

        } else {
            mConfig.imagePaths.set(index, imagePath);
        }
    }
}