// Path: app/src/main/java/moe/yukinoneko/gcomic/module/gallery/PictureFragment.java
// public class PictureFragment extends BaseFragment<PictureFragment.PicturePresenter> implements IBaseView {
//     private static final String PIC_URL = "PIC_URL";
//     private static final String PIC_BYTE = "PIC_BYTE";
//     private static final String IS_FROM_DISK = "IS_FROM_DISK";
// 
//     @BindView(R.id.pv_picture) PhotoView pvPicture;
//     @BindView(R.id.loading_progress_bar) ProgressBar loadingProgressBar;
// 
//     private String mPicUrl;
//     private byte[] mPicByte;
//     private boolean isFromDisk;
// 
//     public static PictureFragment newInstance(String picUrl, byte[] picByte, boolean isFromDisk) {
//         PictureFragment fragment = new PictureFragment();
//         Bundle args = new Bundle();
//         args.putString(PIC_URL, picUrl);
//         args.putByteArray(PIC_BYTE, picByte);
//         args.putBoolean(IS_FROM_DISK, isFromDisk);
//         fragment.setArguments(args);
//         return fragment;
//     }
// 
//     @Override
//     protected int provideViewLayoutId() {
//         return R.layout.fragment_picture;
//     }
// 
//     @Override
//     protected void initPresenter() {
//         presenter = new PicturePresenter(getContext(), this);
//         presenter.init();
//     }
// 
//     @Override
//     public void init() {
//         if (getArguments() != null) {
//             mPicUrl = getArguments().getString(PIC_URL);
//             mPicByte = getArguments().getByteArray(PIC_BYTE);
//             isFromDisk = getArguments().getBoolean(IS_FROM_DISK);
//         }
//         pvPicture.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {
//             @Override
//             public void onViewTap(View view, float x, float y) {
//                 FragmentActivity activity = getActivity();
//                 if (activity instanceof GalleryActivity) {
//                     ((GalleryActivity) getActivity()).toggleSystemUi();
//                 } else {
//                     ((ExternalGalleryActivity) getActivity()).toggleSystemUi();
//                 }
//             }
//         });
// 
//         // 别问我为什么这样写= =
//         if (isFromDisk) {
//             Glide.with(this)
//                  .load(mPicByte)
//                  .listener(new RequestListener<byte[], GlideDrawable>() {
//                      @Override
//                      public boolean onException(Exception e, byte[] model, Target<GlideDrawable> target, boolean isFirstResource) {
//                          return false;
//                      }
// 
//                      @Override
//                      public boolean onResourceReady(GlideDrawable resource, byte[] model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
//                          loadingProgressBar.setVisibility(View.INVISIBLE);
//                          return false;
//                      }
//                  })
//                  .into(pvPicture);
//         } else {
//             Glide.with(this)
//                  .load(GlideUrlFactory.newGlideUrlInstance(mPicUrl))
//                  .listener(new RequestListener<GlideUrl, GlideDrawable>() {
//                      @Override
//                      public boolean onException(Exception e, GlideUrl model, Target<GlideDrawable> target, boolean isFirstResource) {
//                          return false;
//                      }
// 
//                      @Override
//                      public boolean onResourceReady(GlideDrawable resource, GlideUrl model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
//                          loadingProgressBar.setVisibility(View.INVISIBLE);
//                          return false;
//                      }
//                  })
//                  .into(pvPicture);
//         }
//     }
// 
//     class PicturePresenter extends BasePresenter<IBaseView> {
//         public PicturePresenter(Context context, IBaseView iView) {
//             super(context, iView);
//         }
//     }
// }


import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import java.util.ArrayList;
import java.util.List;
import moe.yukinoneko.gcomic.module.gallery.PictureFragment;
/*
 * Copyright (C) 2016  SamuelGjk <samuel.alva@outlook.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package moe.yukinoneko.gcomic.module.gallery.external;




/**
 * Created by SamuelGjk on 2016/7/5.
 */
public class ExternalGalleryPagerAdapter extends FragmentStatePagerAdapter {
    private List<byte[]> mBytes;

    public ExternalGalleryPagerAdapter(FragmentManager fm) {
        super(fm);

        mBytes = new ArrayList<>();
    }

    @Override
    public Fragment getItem(int position) {
        return PictureFragment.newInstance(null, mBytes.get(position), true);
    }

    @Override
    public int getCount() {
        return mBytes.size();
    }

    @Override
    public int getItemPosition(Object object) {
        return POSITION_NONE;
    }

// Path: app/src/main/java/moe/yukinoneko/gcomic/module/gallery/PictureFragment.java
// public class PictureFragment extends BaseFragment<PictureFragment.PicturePresenter> implements IBaseView {
//     private static final String PIC_URL = "PIC_URL";
//     private static final String PIC_BYTE = "PIC_BYTE";
//     private static final String IS_FROM_DISK = "IS_FROM_DISK";
// 
//     @BindView(R.id.pv_picture) PhotoView pvPicture;
//     @BindView(R.id.loading_progress_bar) ProgressBar loadingProgressBar;
// 
//     private String mPicUrl;
//     private byte[] mPicByte;
//     private boolean isFromDisk;
// 
//     public static PictureFragment newInstance(String picUrl, byte[] picByte, boolean isFromDisk) {
//         PictureFragment fragment = new PictureFragment();
//         Bundle args = new Bundle();
//         args.putString(PIC_URL, picUrl);
//         args.putByteArray(PIC_BYTE, picByte);
//         args.putBoolean(IS_FROM_DISK, isFromDisk);
//         fragment.setArguments(args);
//         return fragment;
//     }
// 
//     @Override
//     protected int provideViewLayoutId() {
//         return R.layout.fragment_picture;
//     }
// 
//     @Override
//     protected void initPresenter() {
//         presenter = new PicturePresenter(getContext(), this);
//         presenter.init();
//     }
// 
//     @Override
//     public void init() {
//         if (getArguments() != null) {
//             mPicUrl = getArguments().getString(PIC_URL);
//             mPicByte = getArguments().getByteArray(PIC_BYTE);
//             isFromDisk = getArguments().getBoolean(IS_FROM_DISK);
//         }
//         pvPicture.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {
//             @Override
//             public void onViewTap(View view, float x, float y) {
//                 FragmentActivity activity = getActivity();
//                 if (activity instanceof GalleryActivity) {
//                     ((GalleryActivity) getActivity()).toggleSystemUi();
//                 } else {
//                     ((ExternalGalleryActivity) getActivity()).toggleSystemUi();
//                 }
//             }
//         });
// 
//         // 别问我为什么这样写= =
//         if (isFromDisk) {
//             Glide.with(this)
//                  .load(mPicByte)
//                  .listener(new RequestListener<byte[], GlideDrawable>() {
//                      @Override
//                      public boolean onException(Exception e, byte[] model, Target<GlideDrawable> target, boolean isFirstResource) {
//                          return false;
//                      }
// 
//                      @Override
//                      public boolean onResourceReady(GlideDrawable resource, byte[] model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
//                          loadingProgressBar.setVisibility(View.INVISIBLE);
//                          return false;
//                      }
//                  })
//                  .into(pvPicture);
//         } else {
//             Glide.with(this)
//                  .load(GlideUrlFactory.newGlideUrlInstance(mPicUrl))
//                  .listener(new RequestListener<GlideUrl, GlideDrawable>() {
//                      @Override
//                      public boolean onException(Exception e, GlideUrl model, Target<GlideDrawable> target, boolean isFirstResource) {
//                          return false;
//                      }
// 
//                      @Override
//                      public boolean onResourceReady(GlideDrawable resource, GlideUrl model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
//                          loadingProgressBar.setVisibility(View.INVISIBLE);
//                          return false;
//                      }
//                  })
//                  .into(pvPicture);
//         }
//     }
// 
//     class PicturePresenter extends BasePresenter<IBaseView> {
//         public PicturePresenter(Context context, IBaseView iView) {
//             super(context, iView);
//         }
//     }
// }


// Path: app/src/main/java/moe/yukinoneko/gcomic/module/gallery/external/ExternalGalleryPagerAdapter.java
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import java.util.ArrayList;
import java.util.List;
import moe.yukinoneko.gcomic.module.gallery.PictureFragment;

/*
 * Copyright (C) 2016  SamuelGjk <samuel.alva@outlook.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package moe.yukinoneko.gcomic.module.gallery.external;




/**
 * Created by SamuelGjk on 2016/7/5.
 */
public class ExternalGalleryPagerAdapter extends FragmentStatePagerAdapter {
    private List<byte[]> mBytes;

    public ExternalGalleryPagerAdapter(FragmentManager fm) {
        super(fm);

        mBytes = new ArrayList<>();
    }

    @Override
    public Fragment getItem(int position) {
        return PictureFragment.newInstance(null, mBytes.get(position), true);
    }

    @Override
    public int getCount() {
        return mBytes.size();
    }

    @Override
    public int getItemPosition(Object object) {
        return POSITION_NONE;
    }

    void replaceAll(List<byte[]> bytes) {