Program: 168339
Project: 168339
Buggy source:
private void initViewComponents(String valueRef){
  FormPageAdapter formPageAdapter=new FormPageAdapter(getFragmentManager(),valueRef);
  LinearLayout pagerIndicator=(LinearLayout)findViewById(R.id.viewPagerCountDots);
  mBtnNext=(Button)findViewById(R.id.btn_next);
  mBtnFinish=(Button)findViewById(R.id.btn_finish);
  mBtnNext.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View view){
      mViewPager.setCurrentItem(mViewPager.getCurrentItem() + 1);
    }
  }
);
  mBtnFinish.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View view){
      mPresenter.createEncounter();
    }
  }
);
  mViewPager=(ViewPager)findViewById(R.id.container);
  mViewPager.setAdapter(formPageAdapter);
  mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener(){
    @Override public void onPageSelected(    int position){
      for (int i=0; i < mDotsCount; i++) {
        mDots[i].setImageDrawable(ContextCompat.getDrawable(getBaseContext(),R.drawable.nonselecteditem_dot));
      }
      mDots[position].setImageDrawable(ContextCompat.getDrawable(getBaseContext(),R.drawable.selecteditem_dot));
      if (position + 1 == mDotsCount) {
        mBtnNext.setVisibility(View.GONE);
        mBtnFinish.setVisibility(View.VISIBLE);
      }
 else {
        mBtnNext.setVisibility(View.VISIBLE);
        mBtnFinish.setVisibility(View.GONE);
      }
    }
    @Override public void onPageScrolled(    int position,    float positionOffset,    int positionOffsetPixels){
    }
    @Override public void onPageScrollStateChanged(    int state){
    }
  }
);
  mDotsCount=formPageAdapter.getCount();
  mDots=new ImageView[mDotsCount];
  for (int i=0; i < mDotsCount; i++) {
    mDots[i]=new ImageView(this);
    mDots[i].setImageDrawable(ContextCompat.getDrawable(this,R.drawable.nonselecteditem_dot));
    LinearLayout.LayoutParams params=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT);
    params.setMargins(4,0,4,0);
    pagerIndicator.addView(mDots[i],params);
  }
  mDots[0].setImageDrawable(ContextCompat.getDrawable(this,R.drawable.selecteditem_dot));
  if (mDotsCount == 1) {
    mBtnNext.setVisibility(View.GONE);
    mBtnFinish.setVisibility(View.VISIBLE);
  }
}

Fixed version (ground truth):
private void initViewComponents(String valueRef){
  FormPageAdapter formPageAdapter=new FormPageAdapter(getFragmentManager(),valueRef);
  LinearLayout pagerIndicator=(LinearLayout)findViewById(R.id.viewPagerCountDots);
  mBtnNext=(Button)findViewById(R.id.btn_next);
  mBtnFinish=(Button)findViewById(R.id.btn_finish);
  mBtnNext.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View view){
      mViewPager.setCurrentItem(mViewPager.getCurrentItem() + 1);
    }
  }
);
  mBtnFinish.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View view){
      mPresenter.createEncounter();
    }
  }
);
  mViewPager=(ViewPager)findViewById(R.id.container);
  mViewPager.setAdapter(formPageAdapter);
  mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener(){
    @Override public void onPageSelected(    int position){
      for (int i=0; i < mDotsCount; i++) {
        mDots[i].setImageDrawable(ContextCompat.getDrawable(getBaseContext(),R.drawable.nonselecteditem_dot));
      }
      mDots[position].setImageDrawable(ContextCompat.getDrawable(getBaseContext(),R.drawable.selecteditem_dot));
      if (position + 1 == mDotsCount) {
        mBtnNext.setVisibility(View.GONE);
        mBtnFinish.setVisibility(View.VISIBLE);
      }
 else {
        mBtnNext.setVisibility(View.VISIBLE);
        mBtnFinish.setVisibility(View.GONE);
      }
    }
    @Override public void onPageScrolled(    int position,    float positionOffset,    int positionOffsetPixels){
    }
    @Override public void onPageScrollStateChanged(    int state){
    }
  }
);
  mDotsCount=formPageAdapter.getCount();
  mDots=new ImageView[mDotsCount];
  for (int i=0; i < mDotsCount; i++) {
    mDots[i]=new ImageView(this);
    mDots[i].setImageDrawable(ContextCompat.getDrawable(this,R.drawable.nonselecteditem_dot));
    LinearLayout.LayoutParams params=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT);
    pagerIndicator.addView(mDots[i],params);
  }
  mDots[0].setImageDrawable(ContextCompat.getDrawable(this,R.drawable.selecteditem_dot));
  if (mDotsCount == 1) {
    mBtnNext.setVisibility(View.GONE);
    mBtnFinish.setVisibility(View.VISIBLE);
  }
}