Buggy code:
prefs = ApplicationWrapper . getInstance ( ) . getSharedPrefs ( ) ; prefs . edit ( ) . putBoolean ( COLLAPSED , false ) . apply ( ) ; LayoutInflater inflater = ( ( LayoutInflater ) ( getSystemService ( LAYOUT_INFLATER_SERVICE ) ) ) ; inflater . inflate ( notepad_layout , frame , true ) ; final EditText editText = ( ( EditText ) ( frame . findViewById ( notepadContent ) ) ) ; editText . addTextChangedListener ( new TextWatcher ( ) { @ Override public void onTextChanged ( CharSequence s , int start , int before , int count ) { save ( frame , id ) ; } @ Override public void beforeTextChanged ( CharSequence s , int start , int count , int after ) { } @ Override public void afterTextChanged ( Editable s ) { } } ) ; final ImageButton dock = ( ( ImageButton ) ( frame . findViewById ( dockButton ) ) ) ; dock . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { collapse ( frame , id ) ; ApplicationWrapper . track ( "window" , "dock" ) ; } } ) ; dock . setOnTouchListener ( new NotepadWindow . DragMoveTouchListener ( id ) ) ; ImageButton undock = ( ( ImageButton ) ( frame . findViewById ( undockButton ) ) ) ; undock . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { undock ( frame , id ) ; ApplicationWrapper . track ( "window" , "undock" ) ; } } ) ; undock . setOnTouchListener ( new NotepadWindow . DragMoveTouchListener ( id ) ) ; ImageButton menu = ( ( ImageButton ) ( frame . findViewById ( settingsButton ) ) ) ; menu . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { ( ( InputMethodManager ) ( getSystemService ( INPUT_METHOD_SERVICE ) ) ) . hideSoftInputFromWindow ( editText . getWindowToken ( ) , 0 ) ; getDropDown ( id ) . showAsDropDown ( v , 0 , ( - 2 ) ) ; ApplicationWrapper . track ( "window" , "menu<seq2seq4repair_space>open" ) ; } } ) ; menu . setOnTouchListener ( new NotepadWindow . DragMoveTouchListener ( id ) ) ; spinner = ( ( NoteSwitchSpinner ) ( frame . findViewById ( noteSelectionSpinner ) ) ) ; final NoteSwitchSpinnerAdapter adapter = new NoteSwitchSpinnerAdapter ( ) ; spinner . setAdapter ( adapter ) ; spinner . setOnTouchListener ( new NotepadWindow . DragMoveTouchListener ( id , spinner ) ) ; spinner . setPopupBackgroundDrawable ( null ) ; spinner . setPopupBackgroundResource ( spinner_dropdown_background ) ; spinner . setCustomOnClickListener ( new NoteSwitchSpinner . NoteTitleClickListener ( ) { @ Override public void onNoteTitleClick ( NoteSwitchSpinner . DropdownPopup dialog , int position ) { spinner . setSelection ( position ) ; String item = adapter . getItem ( position ) ; NotepadUtils . setCurrentNote ( item ) ; dialog . dismiss ( ) ; } } ) ; spinner . setSelection ( adapter . getPosition ( NotepadUtils . getCurrentNoteTitle ( ) ) ) ; ImageButton add = ( ( ImageButton ) ( frame . findViewById ( addButton ) ) ) ; add . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { final EditText input = new EditText ( ApplicationWrapper . getInstance ( ) ) ; input . setOnFocusChangeListener ( new View . OnFocusChangeListener ( ) { @ Override public void onFocusChange ( View v , boolean hasFocus ) { input . post ( new Runnable ( ) { @ Override public void run ( ) { InputMethodManager inputMethodManager = ( ( InputMethodManager ) ( ApplicationWrapper . getInstance ( ) . getSystemService ( INPUT_METHOD_SERVICE ) ) ) ; inputMethodManager . showSoftInput ( input , SHOW_IMPLICIT ) ; } } ) ; } } ) ; input . requestFocus ( ) ; AlertDialog . Builder builder = new AlertDialog . Builder ( new android . view . ContextThemeWrapper ( ApplicationWrapper . getInstance ( ) , style . Theme_DeviceDefault_Dialog ) ) . setTitle ( "New<seq2seq4repair_space>Note<seq2seq4repair_space>Title" ) . setView ( input ) . setPositiveButton ( yes , new DialogInterface . OnClickListener ( ) { @ Override public void onClick ( DialogInterface dialog , int which ) { String newNote = input . getText ( ) . toString ( ) ; <START_BUG> adapter . insert ( newNote , 0 ) ; <END_BUG> NotepadUtils . setCurrentNote ( newNote ) ; NotepadUtils . updateNotepad ( ) ; } } ) . setNegativeButton ( no , null ) ; AlertDialog alert = builder . create ( ) ; Window window = alert . getWindow ( ) ; WindowManager . LayoutParams params = window . getAttributes ( ) ; params . token = NotepadWindow . this . notepadView . getWindowToken ( ) ; params . type = LayoutParams . TYPE_APPLICATION_ATTACHED_DIALOG ; window . setAttributes ( params ) ; alert . show ( ) ; } } ) ; add . setOnTouchListener ( new NotepadWindow . DragMoveTouchListener ( id ) ) ; NotepadUtils . updateNotepad ( ) ; new Handler ( ) . postDelayed ( new Runnable ( ) { @ Override public void run ( ) { unfocus ( id ) ; updateViewLayout ( id , getParams ( id , null ) ) ; save ( editText , id ) ; } } , 10 ) ; } @ Override public StandOutLayoutParams getParams ( int id , wei . mark . standout . ui . Window window ) { } @ Override public int getFlags ( int id ) { } public void onMove ( int id , wei . mark . standout . ui . Window window , View view , MotionEvent event ) { } @ Override public Notification getPersistentNotification ( int id ) { } @ Override public String getPersistentNotificationTitle ( int id ) { }

Fix:
adapter . append ( newNote ) ;