Buggy code:
public class Shopping_List extends AppCompatActivity { private static ArrayList < Item > itemArrayList ; private static ArrayList < Item > itemLibraryArrayList ; private static Shopping_List . ItemsAdapter adapter ; private static Shopping_List . ItemsLibraryAdapter libraryAdapter ; private static HashMap < String , Integer > colorDict ; private static HashSet < Item > itemLibraryChosenHashSet ; private static MenuItem itemTotalMenuItem ; private static MenuItem deleteItemsMenuItem ; private static ListView itemListView ; private static SwipeRefreshLayout swipeRefreshLayout ; @ Override protected void onCreate ( Bundle savedInstanceState ) { } public void setSwipeRefreshlayoutRefreshing ( boolean refresh ) { } public void handleDeleteGreenItemsButton ( ) { } @ Override protected void onStart ( ) { } public static void ClearItemArrayList ( ) { } public static void AddToItemArrayList ( final Item newItem ) { } public void NotifyAdapterThatItemListChanged ( ) { } public static void removeItemFromItemArrayList ( final Item oldItem ) { } @ Override public boolean onCreateOptionsMenu ( Menu menu ) { } @ Override public boolean onOptionsItemSelected ( MenuItem item ) { } public void DisplayToast ( String str ) { } public void removeItemsFromItemArrayList ( List < Object > itemIds ) { } public void DeleteGreenItems ( MenuItem item ) { } private void populateColorDict ( Item item , View view ) { } private void handleColor ( String itemName , View listItemView ) { } private void updateItemTotalTitle ( ) { } private View getViewByPosition ( int pos ) { } private class ItemsAdapter extends ArrayAdapter < Item > { public ItemsAdapter ( Context context , ArrayList < Item > users ) { } @ Override public View getView ( int position , View convertView , ViewGroup parent ) { } } public static void AddToLibraryItemArrayList ( final Item newItem ) { } public void NotifyAdapterThatItemLibraryListChanged ( ) { } public void AddNewItem ( MenuItem view ) { final AlertDialog . Builder alert = new AlertDialog . Builder ( this ) ; final LayoutInflater createEditItemInflater = this . getLayoutInflater ( ) ; final View inflatedView = createEditItemInflater . inflate ( create_item_layout , null ) ; alert . setView ( inflatedView ) ; final TextView libraryItemChosenHashSetCount = ( ( TextView ) ( inflatedView . findViewById ( selectedItemsCount ) ) ) ; Shopping_List . itemLibraryArrayList = new ArrayList ( ) ; Shopping_List . itemLibraryChosenHashSet = new HashSet ( ) ; Shopping_List . libraryAdapter = new Shopping_List . ItemsLibraryAdapter ( inflatedView . getContext ( ) , Shopping_List . itemLibraryArrayList ) ; final EditText itemNameView = ( ( EditText ) ( inflatedView . findViewById ( itemName ) ) ) ; <START_BUG> itemNameView . addTextChangedListener ( new DelayedTextWatcher ( 1000 ) { <END_BUG> @ Override public void beforeTextChanged ( CharSequence s , int start , int count , int after ) { final List < Item > localItemsNotFoundToBeRemoved = new ArrayList < Item > ( ) ; for ( Item i : Shopping_List . itemLibraryArrayList ) { if ( ! ( i . getName ( ) . toLowerCase ( ) . contains ( s . toString ( ) ) ) ) localItemsNotFoundToBeRemoved . add ( i ) ; } Shopping_List . itemLibraryArrayList . removeAll ( localItemsNotFoundToBeRemoved ) ; NotifyAdapterThatItemLibraryListChanged ( ) ; } @ Override public void afterTextChangedDelayed ( Editable s ) { new Client . ClientBuilder ( ByteCommand . getLibraryItemsThatContain , getPreferences ( MODE_PRIVATE ) . getString ( "IpAddress" , "127.0.0.1" ) ) . SearchString ( s . toString ( ) ) . build ( ) . execute ( ) ; } } ) ; final ListView itemLibraryListView = ( ( ListView ) ( inflatedView . findViewById ( libraryItemsListView ) ) ) ; itemLibraryListView . setAdapter ( Shopping_List . libraryAdapter ) ; itemLibraryListView . setEmptyView ( inflatedView . findViewById ( createEmpty ) ) ; new Client . ClientBuilder ( ByteCommand . getLibrary , getPreferences ( MODE_PRIVATE ) . getString ( "IpAddress" , "127.0.0.1" ) ) . build ( ) . execute ( ) ; itemLibraryListView . setOnItemClickListener ( new AdapterView . OnItemClickListener ( ) { @ Override public void onItemClick ( AdapterView < ? > parent , View view , int position , long id ) { TextView itemNameTextView = ( ( TextView ) ( view . findViewById ( itemName ) ) ) ; String chosenItemName = itemNameTextView . getText ( ) . toString ( ) ; Item foundItem = new Item . ItemBuilder ( Integer . parseInt ( view . getTag ( ) . toString ( ) ) , chosenItemName ) . build ( ) ; if ( Shopping_List . itemLibraryChosenHashSet . contains ( foundItem ) ) { view . setBackgroundColor ( TRANSPARENT ) ; Shopping_List . itemLibraryChosenHashSet . remove ( foundItem ) ; } else { Item i = Shopping_List . itemLibraryArrayList . get ( Shopping_List . itemLibraryArrayList . indexOf ( foundItem ) ) ; Shopping_List . itemLibraryChosenHashSet . add ( i ) ; changeColorLibrary ( i , view ) ; } libraryItemChosenHashSetCount . setText ( String . valueOf ( Shopping_List . itemLibraryChosenHashSet . size ( ) ) ) ; if ( ( Shopping_List . itemLibraryChosenHashSet . size ( ) ) == 0 ) { itemNameView . setHint ( add_item ) ; } else { itemNameView . setHint ( filter_results ) ; } } } ) ; itemLibraryListView . setChoiceMode ( CHOICE_MODE_MULTIPLE ) ; itemLibraryListView . setItemsCanFocus ( false ) ; NotifyAdapterThatItemLibraryListChanged ( ) ; alert . setPositiveButton ( "Save" , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int whichButton ) { try { if ( ( Shopping_List . itemLibraryChosenHashSet . size ( ) ) > 0 ) { final List < Object > itemIdLibraryChosenArrayList = new ArrayList < > ( ) ; for ( Item i : Shopping_List . itemLibraryChosenHashSet ) { itemIdLibraryChosenArrayList . add ( i . getId ( ) ) ; } new Client . ClientBuilder ( ByteCommand . reAddItems , getPreferences ( MODE_PRIVATE ) . getString ( "IpAddress" , "127.0.0.1" ) ) . ItemIds ( itemIdLibraryChosenArrayList ) . build ( ) . execute ( ) ; }

Fix:
itemNameView . addTextChangedListener ( new DelayedTextWatcher ( 200 ) {