Buggy code:
public class MainActivity extends BaseActivity { @ Inject SharedPreferences prefs ; @ Inject PersistentData persistentData ; @ Inject @ Named ( "DebugSettings" ) Class debugSettingsClass ; @ InjectView ( id . toolbar ) Toolbar toolbar ; @ InjectView ( id . loadingBar ) ProgressBar loadingBar ; @ InjectView ( id . drawerLayout ) DrawerLayout drawerLayout ; @ InjectView ( id . drawer ) LinearLayout drawer ; @ InjectView ( id . debugSettings ) TextView debugSettings ; @ InjectView ( id . favoriteBoardsHeader ) CompatTextView favoriteBoardsHeader ; @ InjectView ( id . favoriteBoards ) ListView favoriteBoardsView ; ActionBarDrawerToggle drawerToggle ; MainActivity . FavoritesAdapter favoriteBoardsAdapter ; FragmentManager fm ; OnBackStackChangedListener backStackChangedListener ; @ Override protected List < Object > getModules ( ) { } @ Override protected int getLayoutResource ( ) { } @ Override protected void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ) ; fm = getSupportFragmentManager ( ) ; setSupportActionBar ( toolbar ) ; getSupportActionBar ( ) . setHomeButtonEnabled ( true ) ; if ( BuildConfig . DEBUG ) debugSettings . setVisibility ( VISIBLE ) ; backStackChangedListener = new FragmentManager . OnBackStackChangedListener ( ) { @ Override public void onBackStackChanged ( ) { FragmentManager fm = getSupportFragmentManager ( ) ; int stackHeight = fm . getBackStackEntryCount ( ) ; if ( stackHeight > 0 ) { drawerToggle . setDrawerIndicatorEnabled ( false ) ; getSupportActionBar ( ) . setDisplayHomeAsUpEnabled ( true ) ; } else { getSupportActionBar ( ) . setDisplayHomeAsUpEnabled ( false ) ; drawerToggle . setDrawerIndicatorEnabled ( true ) ; drawerToggle . syncState ( ) ; } Fragment fragment = fm . getFragments ( ) . get ( stackHeight ) ; if ( fragment != null ) fragment . onResume ( ) ; <START_BUG> if ( fragment instanceof UiFragment ) { <END_BUG> UiFragment f = ( ( UiFragment ) ( fragment ) ) ; ViewHelper . setTranslationY ( toolbar , f . toolbarPosition ) ; } } } ; fm . addOnBackStackChangedListener ( backStackChangedListener ) ; drawerToggle = new ActionBarDrawerToggle ( this , drawerLayout , toolbar , string . navigation_drawer_open , string . navigation_drawer_close ) ; drawerToggle . setToolbarNavigationClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { if ( ! ( drawerToggle . isDrawerIndicatorEnabled ( ) ) ) { onOptionsItemSelected ( mockHomeButton ) ; } } } ) ; drawerLayout . setDrawerListener ( drawerToggle ) ; favoriteBoardsAdapter = new MainActivity . FavoritesAdapter ( this , new java . util . ArrayList ( persistentData . getFavorites ( ) ) ) ; favoriteBoardsView . setAdapter ( favoriteBoardsAdapter ) ; favoriteBoardsAdapter . notifyDataSetChanged ( ) ; persistentData . addFavoritesChangedCallback ( new PersistentData . FavoritesCallback ( ) { @ Override public void onChanged ( Set < Board > newFavorites ) { favoriteBoardsAdapter . updateItems ( new java . util . ArrayList ( newFavorites ) ) ; if ( newFavorites . isEmpty ( ) ) favoriteBoardsHeader . setVisibility ( GONE ) ; else favoriteBoardsHeader . setVisibility ( VISIBLE ) ; } } ) ; favoriteBoardsView . setOnItemClickListener ( new AdapterView . OnItemClickListener ( ) { @ Override public void onItemClick ( AdapterView < ? > parent , View view , int position , long id ) { clearBackStackOnDrawerClick ( ) ; Fragment f = ThreadsFragment . create ( favoriteBoardsAdapter . getItem ( position ) . name ) ; fm . beginTransaction ( ) . replace ( container , f , null ) . commit ( ) ; } } ) ; if ( ( persistentData . getFavorites ( ) . size ( ) ) == 0 ) { favoriteBoardsHeader . setVisibility ( GONE ) ; Fragment f = new BoardsFragment ( ) ; fm . beginTransaction ( ) . replace ( container , f , null ) . commit ( ) ; } else { favoriteBoardsHeader . setVisibility ( VISIBLE ) ; Fragment f = new FavoritesFragment ( ) ; fm . beginTransaction ( ) . replace ( container , f , null ) . commit ( ) ; } } @ OnClick ( id . allBoards ) void onAllBoards ( ) { } @ OnClick ( id . favoriteBoardsBtn ) void onFavoriteBoards ( ) { } @ OnClick ( id . settings ) void onSettings ( ) { } @ OnClick ( id . debugSettings ) void onDebugSettings ( ) { } @ OnClick ( id . about ) void onAbout ( ) { } @ Override protected void onPostCreate ( Bundle savedInstanceState ) { } @ Override public void onConfigurationChanged ( Configuration newConfig ) { } @ Override public boolean onCreateOptionsMenu ( Menu menu ) { } @ Override public boolean onOptionsItemSelected ( MenuItem item ) { } @ Override public void onBackPressed ( ) { } @ Override protected void onDestroy ( ) { } @ Override protected void onResume ( ) { } private static int dur = 120 ; public void showToolbar ( ) { } @ SuppressWarnings ( "UnusedDeclaration" ) public void hideToolbar ( ) { } private void clearBackStackOnDrawerClick ( ) { } private static class FavoritesAdapter extends BindableAdapter < Board > { private List < Board > items ; public FavoritesAdapter ( Context context , List < Board > items ) { } @ Override public View newView ( LayoutInflater inflater , int position , ViewGroup container ) { } @ Override public void bindView ( Board item , int position , View view ) { } @ Override public int getCount ( ) { } @ Override public Board getItem ( int position ) { } @ Override public long getItemId ( int position ) { } public void updateItems ( List < Board > items ) { } } public static class FavoriteView extends LinearLayout { @ InjectView ( id . shortName ) TextView shortName ; @ InjectView ( id . longName ) TextView longName ; public FavoriteView ( Context context , AttributeSet attrs ) { } @ Override protected void onFinishInflate ( ) { }

Fix:
if ( ( fragment instanceof UiFragment ) && ( prefs . getBoolean ( HIDABLE_TOOLBAR , true ) ) ) {