// Path: library/src/main/java/com/hkm/slider/TouchView/UrlTouchImageView.java
// public class UrlTouchImageView extends RelativeLayout {
//     protected ProgressBar mProgressBar;
//     protected TouchImageView mImageView;
// 
//     protected Context mContext;
//     private String mImageUrl;
//     protected RequestBuilder<Bitmap> generator;
// 
//     public UrlTouchImageView(Context ctx) {
//         super(ctx);
//         mContext = ctx;
//         init();
// 
//     }
// 
//     public UrlTouchImageView(Context ctx, AttributeSet attrs) {
//         super(ctx, attrs);
//         mContext = ctx;
//         init();
//     }
// 
//     public TouchImageView getImageView() {
//         return mImageView;
//     }
// 
//     @SuppressWarnings("deprecation")
//     protected void init() {
//         mImageView = new TouchImageView(mContext);
//         LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
//         mImageView.setLayoutParams(params);
//         ViewTreeObserver vto = mImageView.getViewTreeObserver();
//         /**
//          * Callback method to be invoked when the global layout state or the visibility of views
//          * within the view tree changes
//          */
//         glide3();
//         vto.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
//             public boolean onPreDraw() {
//                 mImageView.getViewTreeObserver().removeOnPreDrawListener(this);
//                 initLoadingRequest();
//                 return false;
//             }
//         });
//         this.addView(mImageView);
//         mProgressBar = new ProgressBar(mContext, null);
//         params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
//         params.addRule(RelativeLayout.CENTER_VERTICAL);
//         params.setMargins(30, 0, 30, 0);
//         mProgressBar.setLayoutParams(params);
//         mProgressBar.setIndeterminate(false);
//         mProgressBar.setMax(100);
//         this.addView(mProgressBar);
//     }
// 
//     private void initLoadingRequest() {
//         generator.load(mImageUrl).into(mImageView);
//     }
// 
//     private void glide3() {
//         generator = Glide.with(mContext)
//                 .asBitmap()
//                 .apply(new RequestOptions()
//                         .diskCacheStrategy(DiskCacheStrategy.ALL)
//                         .skipMemoryCache(true)
//                 )
//                 .listener(new RequestListener<Bitmap>() {
//                     @Override
//                     public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource) {
//                         mImageView.setVisibility(GONE);
//                         return false;
//                     }
// 
//                     @Override
//                     public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) {
//                         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
//                             mProgressBar.animate().alpha(0).withEndAction(new Runnable() {
//                                 @Override
//                                 public void run() {
//                                     mProgressBar.setVisibility(GONE);
//                                 }
//                             });
//                         }
//                         return false;
//                     }
//                 });
//     }
// 
// 
//     public void setUrl(String imageUrl) {
//         mImageUrl = imageUrl;
//     }
// 
//     public void setScaleType(ScaleType scaleType) {
//         mImageView.setScaleType(scaleType);
//     }
// 
// }


import java.util.List;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import com.hkm.slider.TouchView.UrlTouchImageView;

package com.hkm.slider.GalleryWidget;





/**
 * Class wraps URLs to adapter, then it instantiates {@link com.hkm.slider.TouchView.FileTouchImageView} objects to paging up through them.
 */
public class UrlPagerAdapter extends BasePagerAdapter {

    public UrlPagerAdapter(Context context, List<String> resources) {
        super(context, resources);
    }

    @Override
    public void setPrimaryItem(ViewGroup container, int position, Object object) {
        super.setPrimaryItem(container, position, object);
        ((GalleryViewPager) container).mCurrentView = ((UrlTouchImageView) object).getImageView();
    }

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

// Path: library/src/main/java/com/hkm/slider/TouchView/UrlTouchImageView.java
// public class UrlTouchImageView extends RelativeLayout {
//     protected ProgressBar mProgressBar;
//     protected TouchImageView mImageView;
// 
//     protected Context mContext;
//     private String mImageUrl;
//     protected RequestBuilder<Bitmap> generator;
// 
//     public UrlTouchImageView(Context ctx) {
//         super(ctx);
//         mContext = ctx;
//         init();
// 
//     }
// 
//     public UrlTouchImageView(Context ctx, AttributeSet attrs) {
//         super(ctx, attrs);
//         mContext = ctx;
//         init();
//     }
// 
//     public TouchImageView getImageView() {
//         return mImageView;
//     }
// 
//     @SuppressWarnings("deprecation")
//     protected void init() {
//         mImageView = new TouchImageView(mContext);
//         LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
//         mImageView.setLayoutParams(params);
//         ViewTreeObserver vto = mImageView.getViewTreeObserver();
//         /**
//          * Callback method to be invoked when the global layout state or the visibility of views
//          * within the view tree changes
//          */
//         glide3();
//         vto.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
//             public boolean onPreDraw() {
//                 mImageView.getViewTreeObserver().removeOnPreDrawListener(this);
//                 initLoadingRequest();
//                 return false;
//             }
//         });
//         this.addView(mImageView);
//         mProgressBar = new ProgressBar(mContext, null);
//         params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
//         params.addRule(RelativeLayout.CENTER_VERTICAL);
//         params.setMargins(30, 0, 30, 0);
//         mProgressBar.setLayoutParams(params);
//         mProgressBar.setIndeterminate(false);
//         mProgressBar.setMax(100);
//         this.addView(mProgressBar);
//     }
// 
//     private void initLoadingRequest() {
//         generator.load(mImageUrl).into(mImageView);
//     }
// 
//     private void glide3() {
//         generator = Glide.with(mContext)
//                 .asBitmap()
//                 .apply(new RequestOptions()
//                         .diskCacheStrategy(DiskCacheStrategy.ALL)
//                         .skipMemoryCache(true)
//                 )
//                 .listener(new RequestListener<Bitmap>() {
//                     @Override
//                     public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource) {
//                         mImageView.setVisibility(GONE);
//                         return false;
//                     }
// 
//                     @Override
//                     public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) {
//                         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
//                             mProgressBar.animate().alpha(0).withEndAction(new Runnable() {
//                                 @Override
//                                 public void run() {
//                                     mProgressBar.setVisibility(GONE);
//                                 }
//                             });
//                         }
//                         return false;
//                     }
//                 });
//     }
// 
// 
//     public void setUrl(String imageUrl) {
//         mImageUrl = imageUrl;
//     }
// 
//     public void setScaleType(ScaleType scaleType) {
//         mImageView.setScaleType(scaleType);
//     }
// 
// }


// Path: library/src/main/java/com/hkm/slider/GalleryWidget/UrlPagerAdapter.java
import java.util.List;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import com.hkm.slider.TouchView.UrlTouchImageView;

package com.hkm.slider.GalleryWidget;





/**
 * Class wraps URLs to adapter, then it instantiates {@link com.hkm.slider.TouchView.FileTouchImageView} objects to paging up through them.
 */
public class UrlPagerAdapter extends BasePagerAdapter {

    public UrlPagerAdapter(Context context, List<String> resources) {
        super(context, resources);
    }

    @Override
    public void setPrimaryItem(ViewGroup container, int position, Object object) {
        super.setPrimaryItem(container, position, object);
        ((GalleryViewPager) container).mCurrentView = ((UrlTouchImageView) object).getImageView();
    }

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

        final UrlTouchImageView iv = new UrlTouchImageView(mContext);
