Program: 14485
Project: 14485
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (WordPress.wpDB == null) {
    Toast.makeText(this,R.string.fatal_db_error,Toast.LENGTH_LONG).show();
    finish();
    return;
  }
  if (savedInstanceState == null) {
    AnalyticsTracker.track(AnalyticsTracker.Stat.STATS_ACCESSED);
  }
  mNoMenuDrawer=getIntent().getBooleanExtra(ARG_NO_MENU_DRAWER,false);
  ActionBar actionBar=getSupportActionBar();
  if (mNoMenuDrawer) {
    setContentView(R.layout.stats_activity);
    if (actionBar != null) {
      actionBar.setDisplayHomeAsUpEnabled(true);
    }
  }
 else {
    createMenuDrawer(R.layout.stats_activity);
  }
  mFragmentContainer=(LinearLayout)findViewById(R.id.stats_fragment_container);
  mSwipeToRefreshHelper=new SwipeToRefreshHelper(this,(SwipeRefreshLayout)findViewById(R.id.ptr_layout),new RefreshListener(){
    @Override public void onRefreshStarted(){
      if (!NetworkUtils.checkConnection(getBaseContext())) {
        mSwipeToRefreshHelper.setRefreshing(false);
        return;
      }
      if (mIsUpdatingStats) {
        AppLog.w(T.STATS,"String_Node_Str");
        return;
      }
      loadStatsFragments(true,true,true);
      refreshStats(mCurrentTimeframe,StatsUtils.getCurrentDateTZ(mLocalBlogID),true);
    }
  }
);
  setTitle(R.string.stats);
  if (savedInstanceState != null) {
    mNavPosition=savedInstanceState.getInt(SAVED_NAV_POSITION);
    mResultCode=savedInstanceState.getInt(SAVED_WP_LOGIN_STATE);
    mLocalBlogID=savedInstanceState.getInt(ARG_LOCAL_TABLE_BLOG_ID);
    mCurrentTimeframe=(StatsTimeframe)savedInstanceState.getSerializable(SAVED_STATS_TIMEFRAME);
    mRequestedDate=savedInstanceState.getString(SAVED_STATS_REQUESTED_DATE);
  }
 else   if (getIntent() != null) {
    mLocalBlogID=getIntent().getIntExtra(ARG_LOCAL_TABLE_BLOG_ID,-1);
    if (getIntent().hasExtra(SAVED_STATS_TIMEFRAME)) {
      mCurrentTimeframe=(StatsTimeframe)getIntent().getSerializableExtra(SAVED_STATS_TIMEFRAME);
    }
 else {
      mCurrentTimeframe=StatsTimeframe.DAY;
    }
    mRequestedDate=StatsUtils.getCurrentDateTZ(mLocalBlogID);
  }
  final Blog currentBlog=WordPress.getBlog(mLocalBlogID);
  if (currentBlog == null) {
    AppLog.e(T.STATS,"String_Node_Str" + mLocalBlogID + "String_Node_Str");
    Toast.makeText(this,R.string.stats_no_blog,Toast.LENGTH_LONG).show();
    finish();
    return;
  }
  loadStatsFragments(false,true,true);
  ScrollViewExt scrollView=(ScrollViewExt)findViewById(R.id.scroll_view_stats);
  if (scrollView != null) {
    scrollView.setScrollViewListener(this);
  }
  if (!mNoMenuDrawer && actionBar != null && mSpinner == null) {
    final Toolbar toolbar=(Toolbar)findViewById(R.id.toolbar);
    if (toolbar != null) {
      View view=View.inflate(this,R.layout.reader_spinner,toolbar);
      mSpinner=(Spinner)view.findViewById(R.id.action_bar_spinner);
      StatsTimeframe[] timeframes={StatsTimeframe.DAY,StatsTimeframe.WEEK,StatsTimeframe.MONTH,StatsTimeframe.YEAR};
      mTimeframeSpinnerAdapter=new TimeframeSpinnerAdapter(this,timeframes);
      actionBar.setDisplayShowTitleEnabled(false);
      mSpinner.setAdapter(mTimeframeSpinnerAdapter);
      mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){
        @Override public void onItemSelected(        AdapterView<?> parent,        View view,        int position,        long id){
          final StatsTimeframe selectedTimeframe=(StatsTimeframe)mTimeframeSpinnerAdapter.getItem(position);
          if (mCurrentTimeframe == selectedTimeframe) {
            AppLog.d(T.STATS,"String_Node_Str" + selectedTimeframe.getLabel());
            return;
          }
          AppLog.d(T.STATS,"String_Node_Str" + selectedTimeframe.getLabel());
          mCurrentTimeframe=selectedTimeframe;
          if (NetworkUtils.isNetworkAvailable(StatsActivity.this)) {
            String date=StatsUtils.getCurrentDateTZ(mLocalBlogID);
            mSwipeToRefreshHelper.setRefreshing(true);
            refreshStats(selectedTimeframe,date,true);
            loadStatsFragments(true,true,false);
          }
        }
        @Override public void onNothingSelected(        AdapterView<?> parent){
        }
      }
);
    }
  }
  selectCurrentTimeframeInActionBar();
}

Fixed version (ground truth):
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  if (WordPress.wpDB == null) {
    Toast.makeText(this,R.string.fatal_db_error,Toast.LENGTH_LONG).show();
    finish();
    return;
  }
  if (savedInstanceState == null) {
    AnalyticsTracker.track(AnalyticsTracker.Stat.STATS_ACCESSED);
  }
  mNoMenuDrawer=getIntent().getBooleanExtra(ARG_NO_MENU_DRAWER,false);
  ActionBar actionBar=getSupportActionBar();
  if (mNoMenuDrawer) {
    setContentView(R.layout.stats_activity);
    if (actionBar != null) {
      actionBar.setDisplayHomeAsUpEnabled(true);
    }
  }
 else {
    createMenuDrawer(R.layout.stats_activity);
  }
  mFragmentContainer=(LinearLayout)findViewById(R.id.stats_fragment_container);
  mSwipeToRefreshHelper=new SwipeToRefreshHelper(this,(SwipeRefreshLayout)findViewById(R.id.ptr_layout),new RefreshListener(){
    @Override public void onRefreshStarted(){
      if (!NetworkUtils.checkConnection(getBaseContext())) {
        mSwipeToRefreshHelper.setRefreshing(false);
        return;
      }
      if (mIsUpdatingStats) {
        AppLog.w(T.STATS,"String_Node_Str");
        return;
      }
      mRequestedDate=StatsUtils.getCurrentDateTZ(mLocalBlogID);
      loadStatsFragments(true,true,true);
      refreshStats(mCurrentTimeframe,mRequestedDate,true);
    }
  }
);
  setTitle(R.string.stats);
  if (savedInstanceState != null) {
    mNavPosition=savedInstanceState.getInt(SAVED_NAV_POSITION);
    mResultCode=savedInstanceState.getInt(SAVED_WP_LOGIN_STATE);
    mLocalBlogID=savedInstanceState.getInt(ARG_LOCAL_TABLE_BLOG_ID);
    mCurrentTimeframe=(StatsTimeframe)savedInstanceState.getSerializable(SAVED_STATS_TIMEFRAME);
    mRequestedDate=savedInstanceState.getString(SAVED_STATS_REQUESTED_DATE);
  }
 else   if (getIntent() != null) {
    mLocalBlogID=getIntent().getIntExtra(ARG_LOCAL_TABLE_BLOG_ID,-1);
    if (getIntent().hasExtra(SAVED_STATS_TIMEFRAME)) {
      mCurrentTimeframe=(StatsTimeframe)getIntent().getSerializableExtra(SAVED_STATS_TIMEFRAME);
    }
 else {
      mCurrentTimeframe=StatsTimeframe.DAY;
    }
    mRequestedDate=StatsUtils.getCurrentDateTZ(mLocalBlogID);
  }
  final Blog currentBlog=WordPress.getBlog(mLocalBlogID);
  if (currentBlog == null) {
    AppLog.e(T.STATS,"String_Node_Str" + mLocalBlogID + "String_Node_Str");
    Toast.makeText(this,R.string.stats_no_blog,Toast.LENGTH_LONG).show();
    finish();
    return;
  }
  loadStatsFragments(false,true,true);
  ScrollViewExt scrollView=(ScrollViewExt)findViewById(R.id.scroll_view_stats);
  if (scrollView != null) {
    scrollView.setScrollViewListener(this);
  }
  if (!mNoMenuDrawer && actionBar != null && mSpinner == null) {
    final Toolbar toolbar=(Toolbar)findViewById(R.id.toolbar);
    if (toolbar != null) {
      View view=View.inflate(this,R.layout.reader_spinner,toolbar);
      mSpinner=(Spinner)view.findViewById(R.id.action_bar_spinner);
      StatsTimeframe[] timeframes={StatsTimeframe.DAY,StatsTimeframe.WEEK,StatsTimeframe.MONTH,StatsTimeframe.YEAR};
      mTimeframeSpinnerAdapter=new TimeframeSpinnerAdapter(this,timeframes);
      actionBar.setDisplayShowTitleEnabled(false);
      mSpinner.setAdapter(mTimeframeSpinnerAdapter);
      mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){
        @Override public void onItemSelected(        AdapterView<?> parent,        View view,        int position,        long id){
          final StatsTimeframe selectedTimeframe=(StatsTimeframe)mTimeframeSpinnerAdapter.getItem(position);
          if (mCurrentTimeframe == selectedTimeframe) {
            AppLog.d(T.STATS,"String_Node_Str" + selectedTimeframe.getLabel());
            return;
          }
          AppLog.d(T.STATS,"String_Node_Str" + selectedTimeframe.getLabel());
          mCurrentTimeframe=selectedTimeframe;
          if (NetworkUtils.isNetworkAvailable(StatsActivity.this)) {
            String date=StatsUtils.getCurrentDateTZ(mLocalBlogID);
            mSwipeToRefreshHelper.setRefreshing(true);
            refreshStats(selectedTimeframe,date,true);
            loadStatsFragments(true,true,false);
          }
        }
        @Override public void onNothingSelected(        AdapterView<?> parent){
        }
      }
);
    }
  }
  selectCurrentTimeframeInActionBar();
}