use of com.shiqkuangsan.mycustomviews.ui.custom.MaterialProgressBar in project CustomViews by AndroidStudy233.
the class ViewPagerFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
viewPager = (OverScrollViewPager) view.findViewById(R.id.viewpager_piclooker);
tips = (TextView) view.findViewById(R.id.tv_piclooker_index);
mask = view.findViewById(R.id.view_piclooker_back);
runEnterAnimation();
Bundle bundle = getArguments();
imgs = bundle.getStringArrayList("imgs");
imageInfo = bundle.getParcelable("info");
imageInfos = bundle.getParcelableArrayList("infos");
position = bundle.getInt("position", 0);
tips.setText((position + 1) + "/" + imgs.size());
viewPager.setpagerCount(imgs.size());
viewPager.setAdapter(new PagerAdapter() {
@Override
public int getCount() {
return imgs.size();
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}
@Override
public Object instantiateItem(ViewGroup container, int pos) {
View view = LayoutInflater.from(getActivity()).inflate(R.layout.layout_view_detail, null, false);
final PhotoView myPhotoView = (PhotoView) view.findViewById(R.id.iv_piclooker_detail);
final MaterialProgressBar progressBar = (MaterialProgressBar) view.findViewById(R.id.pb_piclooker);
if (position == pos && ImageLoader.getInstance().getDiscCache().get(imgs.get(pos)) != null) {
// only animate when position equals u click in pre layout
myPhotoView.animaFrom(imageInfo);
}
// load pic from remote
ImageLoader.getInstance().displayImage(imgs.get(pos), myPhotoView, new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisc(true).build(), new SimpleImageLoadingListener() {
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
progressBar.setVisibility(View.GONE);
}
});
// force to get focal point,to listen key listener
myPhotoView.setFocusableInTouchMode(true);
myPhotoView.requestFocus();
// add key listener to listen back press
myPhotoView.setOnKeyListener(pressKeyListener);
myPhotoView.setOnClickListener(onClickListener);
myPhotoView.setTag(pos);
myPhotoView.enable();
container.addView(view);
return view;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((View) object);
}
});
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
tips.setText((position + 1) + "/" + imgs.size());
viewPager.updateCurrentIndex(position);
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
// set current position
// viewPager.getOverscrollView().setCurrentItem(position);
viewPager.setCurrentItem(position);
}
Aggregations