MiniumApps/launcher3/src/main/java/co/siempo/phone/activities/NoteListActivity.java
/**
     * Initialize toolbar with required components such as
     * - title, menu/OnMenuItemClickListener and searchView -
     */
Initialize toolbar with required components such as
- title, menu/OnMenuItemClickListener and searchView
Initialize toolbar with required components such as - title menu / OnMenuItemClickListener and searchView
protected void initToolbar() {
        toolbar.setTitle(R.string.app_name);
        toolbar.inflateMenu(R.menu.menu_main);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        Menu menu = toolbar.getMenu();
        if (menu != null) {
            searchMenu = menu.findItem(R.id.action_search);
            if (searchMenu != null) {
                SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchMenu);
                if (searchView != null) {
                    searchView.setQueryHint(getString(R.string.label_search));
                    searchView.setOnQueryTextListener(this);
                    MenuItemCompat.setOnActionExpandListener(searchMenu,
                            new MenuItemCompat.OnActionExpandListener() {
                                @Override
                                public boolean onMenuItemActionExpand(MenuItem item) {
                                    searchActive = true;
                                    newNoteButtonVisibility(false);
                                    listView.setLongClickable(false);
                                    realIndexesOfSearchResults = new ArrayList<>();
                                    for (int i = 0; i < notes.length(); i++)
                                        realIndexesOfSearchResults.add(i);
                                    adapter.notifyDataSetChanged();
                                    return true;
                                }
                                @Override
                                public boolean onMenuItemActionCollapse(MenuItem item) {
                                    searchEnded();
                                    return true;
                                }
                            });
                }
            }
        }
    }
protected void initToolbar ( ) { toolbar . setTitle ( R . string . app_name ) ; toolbar . inflateMenu ( R . menu . menu_main ) ; toolbar . setNavigationOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { finish ( ) ; } } ) ; Menu menu = toolbar . getMenu ( ) ; if ( menu != null ) { searchMenu = menu . findItem ( R . id . action_search ) ; if ( searchMenu != null ) { SearchView searchView = ( SearchView ) MenuItemCompat . getActionView ( searchMenu ) ; if ( searchView != null ) { searchView . setQueryHint ( getString ( R . string . label_search ) ) ; searchView . setOnQueryTextListener ( this ) ; MenuItemCompat . setOnActionExpandListener ( searchMenu , new MenuItemCompat . OnActionExpandListener ( ) { @ Override public boolean onMenuItemActionExpand ( MenuItem item ) { searchActive = true ; newNoteButtonVisibility ( false ) ; listView . setLongClickable ( false ) ; realIndexesOfSearchResults = new ArrayList < > ( ) ; for ( int i = 0 ; i < notes . length ( ) ; i ++ ) realIndexesOfSearchResults . add ( i ) ; adapter . notifyDataSetChanged ( ) ; return true ; } @ Override public boolean onMenuItemActionCollapse ( MenuItem item ) { searchEnded ( ) ; return true ; } } ) ; } } } }
Initialize toolbar with required components such as
 - title, menu/OnMenuItemClickListener and searchView
Initialize toolbar with required components such as - title menu / OnMenuItemClickListener and searchView
// Inflate menu_main to be displayed in the toolbar // Set an OnMenuItemClickListener to handle menu item clicks //toolbar.setOnMenuItemClickListener(this); // Get 'Search' menu item // If the item menu not null -> get it's support action view // If searchView not null -> set query hint and open/query/close listeners // Disable long-click on listView to prevent deletion // Init realIndexes array