MiniumApps/launcher3/src/main/java/co/siempo/phone/activities/NoteListActivity.java
/**
     * Callback method when 'Delete' icon pressed
     *
     * @param mode ActionMode of selection
     * @param item MenuItem clicked, in our case just action_delete
     * @return true if clicked, false otherwise
     */
Callback method when 'Delete' icon pressed
@param mode ActionMode of selection
@param item MenuItem clicked, in our case just action_delete
@return true if clicked, false otherwise
Callback method when ' Delete ' icon pressed @param mode ActionMode of selection @param item MenuItem clicked in our case just action_delete @return true if clicked false otherwise
@Override
    public boolean onActionItemClicked(final ActionMode mode, MenuItem item) {
        if (item.getItemId() == R.id.action_delete) {
            new AlertDialog.Builder(this)
                    .setMessage(R.string.title_notesDelete)
                    .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            notes = deleteNotes(notes, checkedArray);
                            adapter = new NoteAdapter(NoteListActivity.this, notes);
                            listView.setAdapter(adapter);
                            Boolean saveSuccessful = saveData(localPath, notes);
                            if (saveSuccessful) {
                                Toast toast = Toast.makeText(getApplicationContext(),
                                        getResources().getString(R.string.msg_deleteSuccessful),
                                        Toast.LENGTH_SHORT);
                                toast.show();
                            }
                            listView.post(new Runnable() {
                                public void run() {
                                    listView.smoothScrollToPosition(0);
                                }
                            });
                            if (notes.length() == 0)
                                noNotes.setVisibility(View.VISIBLE);
                            else
                                noNotes.setVisibility(View.INVISIBLE);
                            mode.finish();
                        }
                    })
                    .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                        }
                    })
                    .show();
            return true;
        }
        return false;
    }
@ Override public boolean onActionItemClicked ( final ActionMode mode , MenuItem item ) { if ( item . getItemId ( ) == R . id . action_delete ) { new AlertDialog . Builder ( this ) . setMessage ( R . string . title_notesDelete ) . setPositiveButton ( android . R . string . ok , new DialogInterface . OnClickListener ( ) { @ Override public void onClick ( DialogInterface dialog , int which ) { notes = deleteNotes ( notes , checkedArray ) ; adapter = new NoteAdapter ( NoteListActivity . this , notes ) ; listView . setAdapter ( adapter ) ; Boolean saveSuccessful = saveData ( localPath , notes ) ; if ( saveSuccessful ) { Toast toast = Toast . makeText ( getApplicationContext ( ) , getResources ( ) . getString ( R . string . msg_deleteSuccessful ) , Toast . LENGTH_SHORT ) ; toast . show ( ) ; } listView . post ( new Runnable ( ) { public void run ( ) { listView . smoothScrollToPosition ( 0 ) ; } } ) ; if ( notes . length ( ) == 0 ) noNotes . setVisibility ( View . VISIBLE ) ; else noNotes . setVisibility ( View . INVISIBLE ) ; mode . finish ( ) ; } } ) . setNegativeButton ( android . R . string . cancel , new DialogInterface . OnClickListener ( ) { @ Override public void onClick ( DialogInterface dialog , int which ) { dialog . dismiss ( ) ; } } ) . show ( ) ; return true ; } return false ; }
Callback method when 'Delete' icon pressed
 @param mode ActionMode of selection
 @param item MenuItem clicked, in our case just action_delete
 @return true if clicked, false otherwise
Callback method when ' Delete ' icon pressed @param mode ActionMode of selection @param item MenuItem clicked in our case just action_delete @return true if clicked false otherwise
// Pass notes and checked items for deletion array to 'deleteNotes' // Create and set new adapter with new notes array // Attempt to save notes to local file // If save successful -> toast successfully deleted // Smooth scroll to top // If no notes -> show 'Press + to add new note' text, invisible otherwise