@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.search); setTitle(R.string.search_title); DEFAULT_ARTISTS = Util.getDefaultArtists(this); DEFAULT_ALBUMS = Util.getDefaultAlbums(this); DEFAULT_SONGS = Util.getDefaultSongs(this); View buttons = LayoutInflater.from(this).inflate(R.layout.search_buttons, null); artistsHeading = buttons.findViewById(R.id.search_artists); albumsHeading = buttons.findViewById(R.id.search_albums); songsHeading = buttons.findViewById(R.id.search_songs); searchButton = (TextView) buttons.findViewById(R.id.search_search); moreArtistsButton = buttons.findViewById(R.id.search_more_artists); moreAlbumsButton = buttons.findViewById(R.id.search_more_albums); moreSongsButton = buttons.findViewById(R.id.search_more_songs); list = (ListView) findViewById(R.id.search_list); list.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (view == searchButton) { onSearchRequested(); } else if (view == moreArtistsButton) { expandArtists(); } else if (view == moreAlbumsButton) { expandAlbums(); } else if (view == moreSongsButton) { expandSongs(); } else { Object item = parent.getItemAtPosition(position); if (item instanceof Artist) { onArtistSelected((Artist) item); } else if (item instanceof MusicDirectory.Entry) { MusicDirectory.Entry entry = (MusicDirectory.Entry) item; if (entry.isDirectory()) { onAlbumSelected(entry, false); } else if (entry.isVideo()) { onVideoSelected(entry); } else { onSongSelected(entry, false, true, true, false); } } } } }); list.setOnTouchListener(gestureListener); registerForContextMenu(list); onNewIntent(getIntent()); }
@Override protected void onCreate(Bundle bundle) { super.onCreate(bundle); setContentView(R.layout.lyrics); View nowPlayingMenuItem = findViewById(R.id.menu_now_playing); menuDrawer.setActiveView(nowPlayingMenuItem); load(); }
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); String query = intent.getStringExtra(Constants.INTENT_EXTRA_NAME_QUERY); boolean autoplay = intent.getBooleanExtra(Constants.INTENT_EXTRA_NAME_AUTOPLAY, false); boolean requestsearch = intent.getBooleanExtra(Constants.INTENT_EXTRA_REQUEST_SEARCH, false); if (query != null) { mergeAdapter = new MergeAdapter(); list.setAdapter(mergeAdapter); search(query, autoplay); } else { populateList(); if (requestsearch) onSearchRequested(); } }
@Override public void onCreateContextMenu( ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, view, menuInfo); AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; Object selectedItem = list.getItemAtPosition(info.position); boolean isArtist = selectedItem instanceof Artist; boolean isAlbum = selectedItem instanceof MusicDirectory.Entry && ((MusicDirectory.Entry) selectedItem).isDirectory(); boolean isSong = selectedItem instanceof MusicDirectory.Entry && (!((MusicDirectory.Entry) selectedItem).isDirectory()) && (!((MusicDirectory.Entry) selectedItem).isVideo()); if (isArtist || isAlbum) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.select_album_context, menu); } else if (isSong) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.select_song_context, menu); } }
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); return true; }