// Path: app/src/main/java/com/zmj/qvod/constant/ImageLoader.java
// public class ImageLoader {
// 
//     public static void load(Context context, String url, ImageView iv) {    //使用Glide加载ImageView(如头像)时，不要使用占位图
//         Glide.with(context).load(url).crossFade().diskCacheStrategy(DiskCacheStrategy.SOURCE).into(iv);
//     }
// 
//     @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
//     public static void load(Activity activity, String url, ImageView iv) {    //使用Glide加载ImageView(如头像)时，不要使用占位图
//         if (!activity.isDestroyed()) {
//             Glide.with(activity).load(url).crossFade().diskCacheStrategy(DiskCacheStrategy.SOURCE).into(iv);
//         }
//     }
// 
//     public static void loadAll(Context context, String url, ImageView iv) {    //不缓存，全部从网络加载
//         Glide.with(context).load(url).crossFade().skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE).into(iv);
//     }
// 
//     @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
//     public static void loadAll(Activity activity, String url, ImageView iv) {    //不缓存，全部从网络加载
//         if (!activity.isDestroyed()) {
//             Glide.with(activity).load(url).crossFade().skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE).into(iv);
//         }
//     }
// 
//     public static void load(String url, ImageView iv, int type) {    //使用占位图
//         switch (type) {
//             case 320:
//                 Glide.with(VideoApplication.getInstance()).load(url).crossFade(1500).placeholder(R.drawable.default_320).into(iv);
//                 break;
//             case 200:
//                 Glide.with(VideoApplication.getInstance()).load(url).crossFade(1500).placeholder(R.drawable.default_200).into(iv);
//                 break;
//             case 100:
//                 Glide.with(VideoApplication.getInstance()).load(url).placeholder(R.drawable.pic_default).into(iv);
//                 break;
//             default:
//                 break;
//         }
//     }
// 
//     /**
//      * Glide 获得图片缓存路径
//      */
//     public static String getImagePath(String imgUrl) {
//         String path = null;
//         FutureTarget<File> future = Glide.with(VideoApplication.getInstance())
//                 .load(imgUrl)
//                 .downloadOnly(500, 500);
//         try {
//             File cacheFile = future.get();
//             path = cacheFile.getAbsolutePath();
//         } catch (InterruptedException | ExecutionException e) {
//             e.printStackTrace();
//         }
//         return path;
//     }
// }
// 
// Path: app/src/main/java/com/zmj/qvod/module/bean/PicBean.java
// public class PicBean implements Serializable {
// 
//     private List<ItemsBean> items;
// 
//     public List<ItemsBean> getItems() {
//         return items;
//     }
// 
//     public static class ItemsBean implements Serializable {
// 
//         private String thumbUrl;
//         private String pic_url;
//         private String height;
//         private String width;
// 
//         public String getHeight() {
//             return height;
//         }
// 
//         public void setHeight(String height) {
//             this.height = height;
//         }
// 
//         public String getWidth() {
//             return width;
//         }
// 
// 
//         public String getThumbUrl() {
//             return thumbUrl;
//         }
// 
//         public String getPic_url() {
//             return pic_url;
//         }
// 
//     }
// }


import android.app.Activity;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.animation.GlideAnimation;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.target.Target;
import com.github.chrisbanes.photoview.PhotoView;
import com.jude.rollviewpager.adapter.DynamicPagerAdapter;
import com.zmj.qvod.R;
import com.zmj.qvod.constant.ImageLoader;
import com.zmj.qvod.module.bean.PicBean;
import java.util.ArrayList;
import butterknife.ButterKnife;
package com.zmj.qvod.adapter;





/**
 * Created by zmj on 2016/2/6 0006.
 */
public class ImageBrowseAdapter extends DynamicPagerAdapter {

    private ArrayList<PicBean.ItemsBean> items;

    private Activity activity;

    public ImageBrowseAdapter(Activity activity) {
        this.activity = activity;
    }

    @Override
    public View getView(ViewGroup container, int position) {
        View contentView = LayoutInflater.from(container.getContext()).inflate(R.layout.view_photo, null);
        PhotoView imageView = ButterKnife.findById(contentView, R.id.photo_view);
        LinearLayout loadingView = ButterKnife.findById(contentView, R.id.ll_photo);

        //手势控件
        Glide.with(container.getContext())
                .load(items.get(position).getPic_url())
                .asBitmap()
                .placeholder(R.drawable.pic_default)
                .listener(new RequestListener<String, Bitmap>() {
                    @Override
                    public boolean onException(Exception e, String model, Target<Bitmap> target, boolean isFirstResource) {
                        loadingView.setVisibility(View.GONE);
// Path: app/src/main/java/com/zmj/qvod/constant/ImageLoader.java
// public class ImageLoader {
// 
//     public static void load(Context context, String url, ImageView iv) {    //使用Glide加载ImageView(如头像)时，不要使用占位图
//         Glide.with(context).load(url).crossFade().diskCacheStrategy(DiskCacheStrategy.SOURCE).into(iv);
//     }
// 
//     @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
//     public static void load(Activity activity, String url, ImageView iv) {    //使用Glide加载ImageView(如头像)时，不要使用占位图
//         if (!activity.isDestroyed()) {
//             Glide.with(activity).load(url).crossFade().diskCacheStrategy(DiskCacheStrategy.SOURCE).into(iv);
//         }
//     }
// 
//     public static void loadAll(Context context, String url, ImageView iv) {    //不缓存，全部从网络加载
//         Glide.with(context).load(url).crossFade().skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE).into(iv);
//     }
// 
//     @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
//     public static void loadAll(Activity activity, String url, ImageView iv) {    //不缓存，全部从网络加载
//         if (!activity.isDestroyed()) {
//             Glide.with(activity).load(url).crossFade().skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE).into(iv);
//         }
//     }
// 
//     public static void load(String url, ImageView iv, int type) {    //使用占位图
//         switch (type) {
//             case 320:
//                 Glide.with(VideoApplication.getInstance()).load(url).crossFade(1500).placeholder(R.drawable.default_320).into(iv);
//                 break;
//             case 200:
//                 Glide.with(VideoApplication.getInstance()).load(url).crossFade(1500).placeholder(R.drawable.default_200).into(iv);
//                 break;
//             case 100:
//                 Glide.with(VideoApplication.getInstance()).load(url).placeholder(R.drawable.pic_default).into(iv);
//                 break;
//             default:
//                 break;
//         }
//     }
// 
//     /**
//      * Glide 获得图片缓存路径
//      */
//     public static String getImagePath(String imgUrl) {
//         String path = null;
//         FutureTarget<File> future = Glide.with(VideoApplication.getInstance())
//                 .load(imgUrl)
//                 .downloadOnly(500, 500);
//         try {
//             File cacheFile = future.get();
//             path = cacheFile.getAbsolutePath();
//         } catch (InterruptedException | ExecutionException e) {
//             e.printStackTrace();
//         }
//         return path;
//     }
// }
// 
// Path: app/src/main/java/com/zmj/qvod/module/bean/PicBean.java
// public class PicBean implements Serializable {
// 
//     private List<ItemsBean> items;
// 
//     public List<ItemsBean> getItems() {
//         return items;
//     }
// 
//     public static class ItemsBean implements Serializable {
// 
//         private String thumbUrl;
//         private String pic_url;
//         private String height;
//         private String width;
// 
//         public String getHeight() {
//             return height;
//         }
// 
//         public void setHeight(String height) {
//             this.height = height;
//         }
// 
//         public String getWidth() {
//             return width;
//         }
// 
// 
//         public String getThumbUrl() {
//             return thumbUrl;
//         }
// 
//         public String getPic_url() {
//             return pic_url;
//         }
// 
//     }
// }


// Path: app/src/main/java/com/zmj/qvod/adapter/ImageBrowseAdapter.java
import android.app.Activity;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.animation.GlideAnimation;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.target.Target;
import com.github.chrisbanes.photoview.PhotoView;
import com.jude.rollviewpager.adapter.DynamicPagerAdapter;
import com.zmj.qvod.R;
import com.zmj.qvod.constant.ImageLoader;
import com.zmj.qvod.module.bean.PicBean;
import java.util.ArrayList;
import butterknife.ButterKnife;

package com.zmj.qvod.adapter;





/**
 * Created by zmj on 2016/2/6 0006.
 */
public class ImageBrowseAdapter extends DynamicPagerAdapter {

    private ArrayList<PicBean.ItemsBean> items;

    private Activity activity;

    public ImageBrowseAdapter(Activity activity) {
        this.activity = activity;
    }

    @Override
    public View getView(ViewGroup container, int position) {
        View contentView = LayoutInflater.from(container.getContext()).inflate(R.layout.view_photo, null);
        PhotoView imageView = ButterKnife.findById(contentView, R.id.photo_view);
        LinearLayout loadingView = ButterKnife.findById(contentView, R.id.ll_photo);

        //手势控件
        Glide.with(container.getContext())
                .load(items.get(position).getPic_url())
                .asBitmap()
                .placeholder(R.drawable.pic_default)
                .listener(new RequestListener<String, Bitmap>() {
                    @Override
                    public boolean onException(Exception e, String model, Target<Bitmap> target, boolean isFirstResource) {
                        loadingView.setVisibility(View.GONE);
                        ImageLoader.load(items.get(position).getThumbUrl(), imageView, 100);