protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_picture_detail); // TODO initView(); customActionBar(); mCurrentPosition = getIntent().getIntExtra(EXTRA_IMAGE_POSITION, 0); mImagePath = getIntent().getStringExtra(EXTRA_IMAGE_PATH); if (!TextUtils.isEmpty(mImagePath)) { mImageUrls.add(mImagePath); } else { mImageUrls = getIntent().getStringArrayListExtra(EXTRA_IMAGE_LIST); } mViewPager.setAdapter(getPagerAdapter()); mIndicator.setViewPager(mViewPager); mIndicator.setCurrentItem(mCurrentPosition); mViewPager.setCurrentItem(mCurrentPosition); mViewPager.setOnPageChangeListener(new OnPageChangeListenerImpl()); }
public void run() { mCurrentPosition = (mCurrentPosition + 1) % mImageUrls.size(); mViewPager.setCurrentItem(mCurrentPosition); mIndicator.setCurrentItem(mCurrentPosition); mHandler.postDelayed(mSwapRunnable, 2000L); }