Buggy code:
private static final int MENU_SAVE_ID = string . TEA_menu_save ; private static final int MENU_DISCARD_ID = string . TEA_menu_discard ; private static final int MENU_DELETE_ID = string . TEA_menu_delete ; private static final int MENU_COMMENTS_REFRESH_ID = string . TEA_menu_comments ; public static final int RESULT_CODE_SAVED = Activity . RESULT_FIRST_USER ; public static final int RESULT_CODE_DISCARDED = ( Activity . RESULT_FIRST_USER ) + 1 ; public static final int RESULT_CODE_DELETED = ( Activity . RESULT_FIRST_USER ) + 2 ; public static final String TAB_BASIC = "basic" ; public static final String TAB_SHARE = "share" ; public static final String TAB_ALARMS = "alarms" ; public static final String TAB_MORE = "more" ; public static final String OVERRIDE_FINISH_ANIM = "finishAnim" ; public static final String TOKEN_TASK_WAS_ASSIGNED = "task_assigned" ; public static final String TOKEN_ASSIGNED_TO = "task_assigned_to" ; public static final int TAB_VIEW_UPDATES = 0 ; public static final int TAB_VIEW_MORE = 1 ; @ Autowired private ExceptionService exceptionService ; @ Autowired private Database database ; @ Autowired private TaskService taskService ; @ Autowired private MetadataService metadataService ; @ Autowired private AddOnService addOnService ; @ Autowired private ActFmPreferenceService actFmPreferenceService ; private ImageButton voiceAddNoteButton ; private EditPeopleControlSet peopleControlSet = null ; private EditNotesControlSet notesControlSet = null ; private HideUntilControlSet hideUntilControls = null ; private TagsControlSet tagsControlSet = null ; private EditText title ; private TaskEditMoreControls moreControls ; private EditNoteActivity editNotes ; private ViewPager mPager ; private TaskEditViewPager mAdapter ; private TabPageIndicator mIndicator ; private final List < TaskEditControlSet > controls = Collections . synchronizedList ( new ArrayList < TaskEditControlSet > ( ) ) ; boolean isNewTask = false ; Task model = null ; private boolean shouldSaveState = true ; private final TaskEditActivity . ControlReceiver controlReceiver = new TaskEditActivity . ControlReceiver ( ) ; private VoiceInputAssistant voiceNoteAssistant ; private EditText notesEditText ; private Dialog whenDialog ; private boolean overrideFinishAnim ; TaskEditActivity . OnTaskEditDetailsClickedListener mListener ; private long remoteId = 0 ; public interface OnTaskEditDetailsClickedListener { public void onTaskEditDetailsClicked ( int category , int position ) { } } @ Override public void onAttach ( SupportActivity activity ) { } public TaskEditActivity ( ) { } @ Override public void onCreate ( Bundle savedInstanceState ) { } @ Override public View onCreateView ( LayoutInflater inflater , ViewGroup container , Bundle savedInstanceState ) { } @ Override public void onActivityCreated ( Bundle savedInstanceState ) { } private void loadMoreContainer ( ) { } private void setCurrentTab ( int position ) { } private void setUpUIComponents ( ) { } private void removeTeaSeparator ( View view ) { } private void setUpListeners ( ) { } private void constructWhenDialog ( View whenDialogView ) { } class TaskEditBackgroundLoader extends Thread { public void onUiThread ( ) { } @ Override public void run ( ) { } } @ SuppressWarnings ( "nls" ) protected void loadItem ( Intent intent ) { } public void repopulateFromScratch ( Intent intent ) { } public void populateFields ( Intent intent ) { } private void populateFields ( ) { } public void save ( boolean onPause ) { } public boolean onKeyDown ( int keyCode , KeyEvent event ) { } @ Override public void onDetach ( ) { } protected class ControlReceiver extends BroadcastReceiver { @ Override public void onReceive ( Context context , Intent intent ) { } } protected void saveButtonClick ( ) { } private String addDueTimeToToast ( String additionalMessage ) { } protected void discardButtonClick ( ) { } private void showCancelToast ( ) { } protected void deleteButtonClick ( ) { } private void showDeleteToast ( ) { } protected void commentsButtonClick ( ) { } @ Override public boolean onOptionsItemSelected ( MenuItem item ) { } @ Override public void onCreateOptionsMenu ( Menu menu , MenuInflater inflater ) { super . onCreateOptionsMenu ( menu , inflater ) ; MenuItem item ; AstridWrapperActivity activity = ( ( AstridWrapperActivity ) ( getActivity ( ) ) ) ; <START_BUG> if ( ( activity instanceof TaskListWrapperActivity ) && ( ( activity . fragmentLayout ) != ( AstridWrapperActivity . LAYOUT_DOUBLE ) ) ) { <END_BUG> item = menu . add ( NONE , TaskEditActivity . MENU_DISCARD_ID , 0 , TEA_menu_discard ) ; item . setIcon ( ic_menu_close_clear_cancel ) ; item . setShowAsAction ( SHOW_AS_ACTION_ALWAYS ) ; item = menu . add ( NONE , TaskEditActivity . MENU_SAVE_ID , 0 , TEA_menu_save ) ; item . setIcon ( ic_menu_save ) ; item . setShowAsAction ( SHOW_AS_ACTION_ALWAYS ) ; } item = menu . add ( NONE , TaskEditActivity . MENU_DELETE_ID , 0 , TEA_menu_delete ) ; item . setIcon ( ic_menu_delete ) ; if ( ( ( AstridWrapperActivity ) ( getActivity ( ) ) ) . isMultipleFragments ( ) ) item . setShowAsAction ( SHOW_AS_ACTION_IF_ROOM ) ; if ( ( actFmPreferenceService . isLoggedIn ( ) ) && ( ( remoteId ) > 0 ) ) { item = menu . add ( NONE , TaskEditActivity . MENU_COMMENTS_REFRESH_ID , NONE , ENA_refresh_comments ) ; item . setIcon ( ic_menu_refresh ) ; } } @ Override public void onPause ( ) { } @ Override public void onResume ( ) { } @ Override public void onActivityResult ( int requestCode , int resultCode , Intent data ) { } @ Override public void onSaveInstanceState ( Bundle outState ) { } @ Override public void onStart ( ) { } @ Override public void onStop ( ) { } private void adjustInfoPopovers ( ) { } public View getPageView ( int position ) { } private void setPagerHeightForPosition ( int position ) { } public static void setViewHeightBasedOnChildren ( LinearLayout view ) { } @ Override public void onPageScrolled ( int position , float positionOffset , int positionOffsetPixels ) { } @ Override public void onPageSelected ( int position ) { } @ Override public void onPageScrollStateChanged ( int state ) { } @ Override public void updatesChanged ( ) { } @ Override public void commentAdded ( ) { } public void scrollToView ( View v ) { } }

Fix:
if ( ( ( activity instanceof TaskListWrapperActivity ) && ( ( activity . fragmentLayout ) != ( AstridWrapperActivity . LAYOUT_DOUBLE ) ) ) || ( activity instanceof TaskEditWrapperActivity ) ) {