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);
}
Aggregations