use of org.moire.ultrasonic.domain.Artist in project ultrasonic by ultrasonic.
the class SearchActivity method onCreateContextMenu.
@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();
if (!isArtist && !isAlbum) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.select_song_context, menu);
} else {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.select_album_context, menu);
}
MenuItem shareButton = menu.findItem(R.id.menu_item_share);
MenuItem downloadMenuItem = menu.findItem(R.id.album_menu_download);
if (downloadMenuItem != null) {
downloadMenuItem.setVisible(!Util.isOffline(this));
}
if (Util.isOffline(this) || isArtist) {
if (shareButton != null) {
shareButton.setVisible(false);
}
}
}
use of org.moire.ultrasonic.domain.Artist in project ultrasonic by ultrasonic.
the class SearchActivity method onContextItemSelected.
@Override
public boolean onContextItemSelected(MenuItem menuItem) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();
if (info == null) {
return true;
}
Object selectedItem = list.getItemAtPosition(info.position);
Artist artist = selectedItem instanceof Artist ? (Artist) selectedItem : null;
Entry entry = selectedItem instanceof Entry ? (Entry) selectedItem : null;
String entryId = null;
if (entry != null) {
entryId = entry.getId();
}
String id = artist != null ? artist.getId() : entryId;
if (id == null) {
return true;
}
List<Entry> songs = new ArrayList<Entry>(1);
switch(menuItem.getItemId()) {
case R.id.album_menu_play_now:
downloadRecursively(id, false, false, true, false, false, false, false, false);
break;
case R.id.album_menu_play_next:
downloadRecursively(id, false, true, false, true, false, true, false, false);
break;
case R.id.album_menu_play_last:
downloadRecursively(id, false, true, false, false, false, false, false, false);
break;
case R.id.album_menu_pin:
downloadRecursively(id, true, true, false, false, false, false, false, false);
break;
case R.id.album_menu_unpin:
downloadRecursively(id, false, false, false, false, false, false, true, false);
break;
case R.id.album_menu_download:
downloadRecursively(id, false, false, false, false, true, false, false, false);
break;
case R.id.song_menu_play_now:
if (entry != null) {
songs = new ArrayList<MusicDirectory.Entry>(1);
songs.add(entry);
download(false, false, true, false, false, songs);
}
break;
case R.id.song_menu_play_next:
if (entry != null) {
songs = new ArrayList<MusicDirectory.Entry>(1);
songs.add(entry);
download(true, false, false, true, false, songs);
}
break;
case R.id.song_menu_play_last:
if (entry != null) {
songs = new ArrayList<MusicDirectory.Entry>(1);
songs.add(entry);
download(true, false, false, false, false, songs);
}
break;
case R.id.song_menu_pin:
if (entry != null) {
songs.add(entry);
Util.toast(SearchActivity.this, getResources().getQuantityString(R.plurals.select_album_n_songs_pinned, songs.size(), songs.size()));
downloadBackground(true, songs);
}
break;
case R.id.song_menu_download:
if (entry != null) {
songs.add(entry);
Util.toast(SearchActivity.this, getResources().getQuantityString(R.plurals.select_album_n_songs_downloaded, songs.size(), songs.size()));
downloadBackground(false, songs);
}
break;
case R.id.song_menu_unpin:
if (entry != null) {
songs.add(entry);
Util.toast(SearchActivity.this, getResources().getQuantityString(R.plurals.select_album_n_songs_unpinned, songs.size(), songs.size()));
getDownloadService().unpin(songs);
}
break;
case R.id.menu_item_share:
if (entry != null) {
songs = new ArrayList<MusicDirectory.Entry>(1);
songs.add(entry);
createShare(songs);
}
default:
return super.onContextItemSelected(menuItem);
}
return true;
}
use of org.moire.ultrasonic.domain.Artist in project ultrasonic by ultrasonic.
the class SearchActivity method expandArtists.
private void expandArtists() {
artistAdapter.clear();
for (Artist artist : searchResult.getArtists()) {
artistAdapter.add(artist);
}
artistAdapter.notifyDataSetChanged();
mergeAdapter.removeAdapter(moreArtistsAdapter);
mergeAdapter.notifyDataSetChanged();
}
use of org.moire.ultrasonic.domain.Artist in project ultrasonic by ultrasonic.
the class SearchActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.search);
setActionBarTitle(R.string.common_appname);
setActionBarSubtitle(R.string.search_title);
View searchMenuItem = findViewById(R.id.menu_search);
menuDrawer.setActiveView(searchMenuItem);
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);
if (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);
}
}
}
}
});
registerForContextMenu(list);
onNewIntent(getIntent());
}
use of org.moire.ultrasonic.domain.Artist in project ultrasonic by ultrasonic.
the class SelectArtistActivity method onContextItemSelected.
@Override
public boolean onContextItemSelected(MenuItem menuItem) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();
if (info == null) {
return true;
}
Artist artist = (Artist) artistListView.getItemAtPosition(info.position);
if (artist != null) {
switch(menuItem.getItemId()) {
case R.id.artist_menu_play_now:
downloadRecursively(artist.getId(), false, false, true, false, false, false, false, true);
break;
case R.id.artist_menu_play_next:
downloadRecursively(artist.getId(), false, false, true, true, false, true, false, true);
break;
case R.id.artist_menu_play_last:
downloadRecursively(artist.getId(), false, true, false, false, false, false, false, true);
break;
case R.id.artist_menu_pin:
downloadRecursively(artist.getId(), true, true, false, false, false, false, false, true);
break;
case R.id.artist_menu_unpin:
downloadRecursively(artist.getId(), false, false, false, false, false, false, true, true);
break;
case R.id.artist_menu_download:
downloadRecursively(artist.getId(), false, false, false, false, true, false, false, true);
break;
default:
return super.onContextItemSelected(menuItem);
}
} else if (info.position == 1) {
MusicFolder selectedFolder = menuItem.getItemId() == -1 ? null : musicFolders.get(menuItem.getItemId());
String musicFolderId = selectedFolder == null ? null : selectedFolder.getId();
String musicFolderName = selectedFolder == null ? getString(R.string.select_artist_all_folders) : selectedFolder.getName();
Util.setSelectedMusicFolderId(this, musicFolderId);
folderName.setText(musicFolderName);
refresh();
}
return true;
}
Aggregations