Buggy code:
public class SoundFragment extends ScriptActivityFragment implements Dialog . OnKeyListener , LoaderManager . LoaderCallbacks < Cursor > , SoundBaseAdapter . OnSoundEditListener { public static final String TAG = SoundFragment . class . getSimpleName ( ) ; private static int selectedSoundPosition = Constants . NO_POSITION ; private static String actionModeTitle ; private static String singleItemAppendixDeleteActionMode ; private static String multipleItemAppendixDeleteActionMode ; private MediaPlayer mediaPlayer ; private SoundBaseAdapter adapter ; private ArrayList < SoundInfo > soundInfoList ; private SoundInfo selectedSoundInfo ; private ListView listView ; private SoundFragment . SoundDeletedReceiver soundDeletedReceiver ; private SoundFragment . SoundRenamedReceiver soundRenamedReceiver ; private SoundFragment . SoundCopiedReceiver soundCopiedReceiver ; private SoundFragment . SoundsListInitReceiver soundsListInitReceiver ; private ActionMode actionMode ; private View selectAllActionModeButton ; private boolean isRenameActionMode ; private boolean isResultHandled = false ; private boolean isAddNewSoundButtonClicked = false ; private SoundFragment . OnSoundInfoListChangedAfterNewListener soundInfoListChangedAfterNewListener ; public void setOnSoundInfoListChangedAfterNewListener ( SoundFragment . OnSoundInfoListChangedAfterNewListener listener ) { } private void setHandleAddbutton ( ) { } @ Override public void onCreate ( Bundle savedInstanceState ) { } @ Override public View onCreateView ( LayoutInflater inflater , ViewGroup container , Bundle savedInstanceState ) { } @ Override public void onActivityCreated ( Bundle savedInstanceState ) { } @ Override public void onPrepareOptionsMenu ( Menu menu ) { } @ Override public void onSaveInstanceState ( Bundle outState ) { } @ Override public void onStart ( ) { } @ Override public void onResume ( ) { } @ Override public void onHiddenChanged ( boolean hidden ) { } @ Override public void onPause ( ) { } @ Override public void onStop ( ) { } @ Override public void startCopyActionMode ( ) { } @ Override public void startBackPackActionMode ( ) { } @ Override public void startRenameActionMode ( ) { } @ Override public void startDeleteActionMode ( ) { } @ Override public void onActivityResult ( int requestCode , int resultCode , Intent data ) { super . onActivityResult ( requestCode , resultCode , data ) ; isAddNewSoundButtonClicked = false ; if ( ( ( resultCode == ( Activity . RESULT_OK ) ) && ( requestCode == ( SoundController . REQUEST_SELECT_MUSIC ) ) ) && ( data != null ) ) { Bundle arguments = new Bundle ( ) ; arguments . putParcelable ( BUNDLE_ARGUMENTS_SELECTED_SOUND , data . getData ( ) ) ; if ( ( getLoaderManager ( ) . getLoader ( ID_LOADER_MEDIA_IMAGE ) ) == null ) { getLoaderManager ( ) . initLoader ( ID_LOADER_MEDIA_IMAGE , arguments , this ) ; } else { getLoaderManager ( ) . restartLoader ( ID_LOADER_MEDIA_IMAGE , arguments , this ) ; } } if ( requestCode == ( SoundController . REQUEST_SELECT_MUSIC ) ) { Log . d ( "SoundFragment" , "onActivityResult<seq2seq4repair_space>RequestMusic" ) ; setHandleAddbutton ( ) ; } if ( ( resultCode == ( Activity . RESULT_CANCELED ) ) && ( ProjectManager . getInstance ( ) . getComingFromScriptFragmentToSoundFragment ( ) ) ) { getActivity ( ) . sendBroadcast ( new Intent ( ScriptActivity . ACTION_BRICK_LIST_CHANGED ) ) ; ProjectManager . getInstance ( ) . setHandleCorrectAddButton ( true ) ; <START_BUG> ImageButton addButton = ( ( ImageButton ) ( getSherlockActivity ( ) . findViewById ( button_add ) ) ) ; <END_BUG> addButton . setOnClickListener ( new OnClickListener ( ) { @ Override public void onClick ( View view ) { ScriptActivity scriptActivity = ( ( ScriptActivity ) ( getActivity ( ) ) ) ; scriptActivity . getScriptFragment ( ) . handleAddButton ( ) ; } } ) ; SoundController . getInstance ( ) . switchToScriptFragment ( this ) ; } ProjectManager . getInstance ( ) . setComingFromScriptFragmentToSoundFragment ( false ) ; } @ Override public void onSoundPlay ( View view ) { } @ Override public void onSoundPause ( View view ) { } @ Override public void onSoundChecked ( ) { } private void updateActionModeTitle ( ) { } @ Override public Loader < Cursor > onCreateLoader ( int id , Bundle arguments ) { } @ Override public void onLoadFinished ( Loader < Cursor > loader , Cursor data ) { } @ Override public void onLoaderReset ( Loader < Cursor > loader ) { } public void handlePauseSoundButton ( View view ) { } public void pauseSound ( SoundInfo soundInfo ) { } @ Override public void onCreateContextMenu ( ContextMenu menu , View view , ContextMenuInfo menuInfo ) { } @ Override public boolean onContextItemSelected ( MenuItem item ) { } private void updateSoundAdapter ( SoundInfo newSoundInfo ) { } @ Override public void setSelectMode ( int selectMode ) { } @ Override public int getSelectMode ( ) { } @ Override public void setShowDetails ( boolean showDetails ) { } @ Override public boolean getShowDetails ( ) { } @ Override public void handleAddButton ( ) { } public void addSoundRecord ( ) { } public void addSoundChooseFile ( ) { } @ TargetApi ( 19 ) private void disableGoogleDrive ( Intent intent ) { } @ Override public void showRenameDialog ( ) { } @ Override protected void showDeleteDialog ( ) { } private class SoundRenamedReceiver extends BroadcastReceiver { @ Override public void onReceive ( Context context , Intent intent ) { } } private class SoundDeletedReceiver extends BroadcastReceiver { @ Override public void onReceive ( Context context , Intent intent ) { } } private class SoundCopiedReceiver extends BroadcastReceiver { @ Override public void onReceive ( Context context , Intent intent ) { } } private void addSelectAllActionModeButton ( ActionMode mode , Menu menu ) { } private Callback renameModeCallBack = new ActionMode . Callback ( ) { @ Override public boolean onPrepareActionMode ( ActionMode mode , Menu menu ) { } @ Override public boolean onCreateActionMode ( ActionMode mode , Menu menu ) { } @ Override public boolean onActionItemClicked ( ActionMode mode , MenuItem item ) { } @ Override public void onDestroyActionMode ( ActionMode mode ) { } } ; private Callback copyModeCallBack = new ActionMode . Callback ( ) { @ Override public boolean onPrepareActionMode ( ActionMode mode , Menu menu ) { }

Fix:
ImageButton addButton = ( ( ImageButton ) ( getSupportActivity ( ) . findViewById ( button_add ) ) ) ;