Search in sources :

Example 1 with PhotoDetailPagerAdapter

use of com.yydcdut.noteplugin.adapter.PhotoDetailPagerAdapter in project PhotoNoter by yydcdut.

the class PhotoDetailActivity method initViewPager.

private void initViewPager() {
    PhotoDetailPagerAdapter photoDetailPagerAdapter;
    if (isPreviewSelected) {
        mAdapterPathList = new ArrayList<>(SelectPhotoModel.getInstance().getCount());
        for (int i = 0; i < SelectPhotoModel.getInstance().getCount(); i++) {
            mAdapterPathList.add(SelectPhotoModel.getInstance().get(i));
        }
        photoDetailPagerAdapter = new PhotoDetailPagerAdapter(mAdapterPathList);
        mViewPager.setAdapter(photoDetailPagerAdapter);
        mPhotoCheckBox.setCheckedWithoutCallback(true);
    } else {
        int initPage = getIntent().getIntExtra(INTENT_PAGE, 0);
        String folderName = getIntent().getStringExtra(INTENT_FOLDER);
        List<MediaPhoto> mediaPhotoList = PhotoModel.getInstance().findByMedia(this).get(folderName).getMediaPhotoList();
        mAdapterPathList = new ArrayList<>(mediaPhotoList.size());
        for (MediaPhoto mediaPhoto : mediaPhotoList) {
            mAdapterPathList.add(mediaPhoto.getPath());
        }
        photoDetailPagerAdapter = new PhotoDetailPagerAdapter(mAdapterPathList);
        mViewPager.setAdapter(photoDetailPagerAdapter);
        mViewPager.setCurrentItem(initPage);
        for (int i = 0; i < SelectPhotoModel.getInstance().getCount(); i++) {
            String selectedPath = SelectPhotoModel.getInstance().get(i);
            if (selectedPath.equals(mAdapterPathList.get(initPage))) {
                mPhotoCheckBox.setCheckedWithoutCallback(true);
                break;
            }
        }
    }
    photoDetailPagerAdapter.setOnPhotoClickListener(this);
}
Also used : PhotoDetailPagerAdapter(com.yydcdut.noteplugin.adapter.PhotoDetailPagerAdapter) MediaPhoto(com.yydcdut.noteplugin.bean.MediaPhoto)

Aggregations

PhotoDetailPagerAdapter (com.yydcdut.noteplugin.adapter.PhotoDetailPagerAdapter)1 MediaPhoto (com.yydcdut.noteplugin.bean.MediaPhoto)1