Program: 13993
Project: 13993
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  ProfilingUtils.split("String_Node_Str");
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main_activity);
  mViewPager=(WPViewPager)findViewById(R.id.viewpager_main);
  mViewPager.setOffscreenPageLimit(WPMainTabAdapter.NUM_TABS - 1);
  mTabAdapter=new WPMainTabAdapter(getFragmentManager());
  mViewPager.setAdapter(mTabAdapter);
  mConnectionBar=(TextView)findViewById(R.id.connection_bar);
  mConnectionBar.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      AniUtils.animateBottomBar(mConnectionBar,false);
      new Handler().postDelayed(new Runnable(){
        @Override public void run(){
          if (!isFinishing()) {
            checkConnection();
          }
        }
      }
,2000);
    }
  }
);
  mTabLayout=(WPMainTabLayout)findViewById(R.id.tab_layout);
  mTabLayout.createTabs();
  mTabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener(){
    @Override public void onTabSelected(    TabLayout.Tab tab){
      mViewPager.setCurrentItem(tab.getPosition());
    }
    @Override public void onTabUnselected(    TabLayout.Tab tab){
    }
    @Override public void onTabReselected(    TabLayout.Tab tab){
      Fragment fragment=mTabAdapter.getFragment(tab.getPosition());
      if (fragment instanceof OnScrollToTopListener) {
        ((OnScrollToTopListener)fragment).onScrollToTop();
      }
    }
  }
);
  mAppBarElevation=getResources().getDimensionPixelSize(R.dimen.appbar_elevation);
  mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(mTabLayout));
  mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener(){
    @Override public void onPageSelected(    int position){
      AppPrefs.setMainTabIndex(position);
switch (position) {
case WPMainTabAdapter.TAB_MY_SITE:
        setTabLayoutElevation(mAppBarElevation);
      break;
case WPMainTabAdapter.TAB_READER:
    setTabLayoutElevation(0);
  break;
case WPMainTabAdapter.TAB_ME:
setTabLayoutElevation(mAppBarElevation);
break;
case WPMainTabAdapter.TAB_NOTIFS:
setTabLayoutElevation(mAppBarElevation);
Fragment fragment=mTabAdapter.getFragment(position);
if (fragment instanceof NotificationsListFragment) {
((NotificationsListFragment)fragment).clearPendingNotificationsItemsOnUI();
}
break;
}
trackLastVisibleTab(position,true);
}
@Override public void onPageScrollStateChanged(int state){
}
@Override public void onPageScrolled(int position,float positionOffset,int positionOffsetPixels){
if (position == WPMainTabAdapter.TAB_MY_SITE) {
EventBus.getDefault().post(new MainViewPagerScrolled(positionOffset));
}
}
}
);
if (savedInstanceState == null) {
if (AccountHelper.isSignedIn()) {
boolean openedFromPush=(getIntent() != null && getIntent().getBooleanExtra(ARG_OPENED_FROM_PUSH,false));
if (openedFromPush) {
getIntent().putExtra(ARG_OPENED_FROM_PUSH,false);
launchWithNoteId();
}
 else {
int position=AppPrefs.getMainTabIndex();
if (mTabAdapter.isValidPosition(position) && position != mViewPager.getCurrentItem()) {
mViewPager.setCurrentItem(position);
}
checkMagicLinkSignIn();
}
}
 else {
ActivityLauncher.showSignInForResult(this);
}
}
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  ProfilingUtils.split("String_Node_Str");
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main_activity);
  mViewPager=(WPViewPager)findViewById(R.id.viewpager_main);
  mViewPager.setOffscreenPageLimit(WPMainTabAdapter.NUM_TABS - 1);
  mTabAdapter=new WPMainTabAdapter(getFragmentManager());
  mViewPager.setAdapter(mTabAdapter);
  mConnectionBar=(TextView)findViewById(R.id.connection_bar);
  mConnectionBar.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      AniUtils.animateBottomBar(mConnectionBar,false);
      new Handler().postDelayed(new Runnable(){
        @Override public void run(){
          if (!isFinishing()) {
            checkConnection();
          }
        }
      }
,2000);
    }
  }
);
  mTabLayout=(WPMainTabLayout)findViewById(R.id.tab_layout);
  mTabLayout.createTabs();
  mTabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener(){
    @Override public void onTabSelected(    TabLayout.Tab tab){
      mViewPager.setCurrentItem(tab.getPosition());
    }
    @Override public void onTabUnselected(    TabLayout.Tab tab){
    }
    @Override public void onTabReselected(    TabLayout.Tab tab){
      Fragment fragment=mTabAdapter.getFragment(tab.getPosition());
      if (fragment instanceof OnScrollToTopListener) {
        ((OnScrollToTopListener)fragment).onScrollToTop();
      }
    }
  }
);
  mAppBarElevation=getResources().getDimensionPixelSize(R.dimen.appbar_elevation);
  mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(mTabLayout));
  mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener(){
    @Override public void onPageSelected(    int position){
      AppPrefs.setMainTabIndex(position);
switch (position) {
case WPMainTabAdapter.TAB_MY_SITE:
        setTabLayoutElevation(mAppBarElevation);
      break;
case WPMainTabAdapter.TAB_READER:
    setTabLayoutElevation(0);
  break;
case WPMainTabAdapter.TAB_ME:
setTabLayoutElevation(mAppBarElevation);
break;
case WPMainTabAdapter.TAB_NOTIFS:
setTabLayoutElevation(mAppBarElevation);
Fragment fragment=mTabAdapter.getFragment(position);
if (fragment instanceof OnScrollToTopListener) {
((OnScrollToTopListener)fragment).onScrollToTop();
}
break;
}
trackLastVisibleTab(position,true);
}
@Override public void onPageScrollStateChanged(int state){
}
@Override public void onPageScrolled(int position,float positionOffset,int positionOffsetPixels){
if (position == WPMainTabAdapter.TAB_MY_SITE) {
EventBus.getDefault().post(new MainViewPagerScrolled(positionOffset));
}
}
}
);
if (savedInstanceState == null) {
if (AccountHelper.isSignedIn()) {
boolean openedFromPush=(getIntent() != null && getIntent().getBooleanExtra(ARG_OPENED_FROM_PUSH,false));
if (openedFromPush) {
getIntent().putExtra(ARG_OPENED_FROM_PUSH,false);
launchWithNoteId();
}
 else {
int position=AppPrefs.getMainTabIndex();
if (mTabAdapter.isValidPosition(position) && position != mViewPager.getCurrentItem()) {
mViewPager.setCurrentItem(position);
}
checkMagicLinkSignIn();
}
}
 else {
ActivityLauncher.showSignInForResult(this);
}
}
}