use of org.moire.ultrasonic.view.AlbumView in project ultrasonic by ultrasonic.
the class SelectAlbumActivity method onCreate.
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.select_album);
albumButtons = findViewById(R.id.menu_album);
refreshAlbumListView = (PullToRefreshListView) findViewById(R.id.select_album_entries);
albumListView = refreshAlbumListView.getRefreshableView();
refreshAlbumListView.setOnRefreshListener(new OnRefreshListener<ListView>() {
@Override
public void onRefresh(PullToRefreshBase<ListView> refreshView) {
new GetDataTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
});
refreshAlbumListView.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
for (int i = 0; i < albumListView.getChildCount(); i++) {
Object child = albumListView.getChildAt(i);
if (child instanceof AlbumView) {
AlbumView albumView = (AlbumView) child;
if (albumView.isMaximized()) {
albumView.maximizeOrMinimize();
}
}
if (child instanceof SongView) {
SongView songView = (SongView) child;
if (songView.isMaximized()) {
songView.maximizeOrMinimize();
}
}
}
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
}
});
header = LayoutInflater.from(this).inflate(R.layout.select_album_header, albumListView, false);
albumListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
albumListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (position >= 0) {
MusicDirectory.Entry entry = (MusicDirectory.Entry) parent.getItemAtPosition(position);
if (entry != null && entry.isDirectory()) {
Intent intent = new Intent(SelectAlbumActivity.this, SelectAlbumActivity.class);
intent.putExtra(Constants.INTENT_EXTRA_NAME_ID, entry.getId());
intent.putExtra(Constants.INTENT_EXTRA_NAME_IS_ALBUM, entry.isDirectory());
intent.putExtra(Constants.INTENT_EXTRA_NAME_NAME, entry.getTitle());
intent.putExtra(Constants.INTENT_EXTRA_NAME_PARENT_ID, entry.getParent());
startActivityForResultWithoutTransition(SelectAlbumActivity.this, intent);
} else if (entry != null && entry.isVideo()) {
playVideo(entry);
} else {
enableButtons();
}
}
}
});
albumListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
if (view instanceof AlbumView) {
AlbumView albumView = (AlbumView) view;
if (!albumView.isMaximized()) {
albumView.maximizeOrMinimize();
return true;
} else {
return false;
}
}
if (view instanceof SongView) {
SongView songView = (SongView) view;
songView.maximizeOrMinimize();
return true;
}
return false;
}
});
selectButton = (ImageView) findViewById(R.id.select_album_select);
playNowButton = (ImageView) findViewById(R.id.select_album_play_now);
playNextButton = (ImageView) findViewById(R.id.select_album_play_next);
playLastButton = (ImageView) findViewById(R.id.select_album_play_last);
pinButton = (ImageView) findViewById(R.id.select_album_pin);
unpinButton = (ImageView) findViewById(R.id.select_album_unpin);
downloadButton = (ImageView) findViewById(R.id.select_album_download);
deleteButton = (ImageView) findViewById(R.id.select_album_delete);
moreButton = (ImageView) findViewById(R.id.select_album_more);
emptyView = findViewById(R.id.select_album_empty);
selectButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
selectAllOrNone();
}
});
playNowButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
playNow(false, false);
}
});
playNextButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
download(true, false, false, true, false, getSelectedSongs(albumListView));
selectAll(false, false);
}
});
playLastButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
playNow(false, true);
}
});
pinButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
downloadBackground(true);
selectAll(false, false);
}
});
unpinButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
unpin();
selectAll(false, false);
}
});
downloadButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
downloadBackground(false);
selectAll(false, false);
}
});
deleteButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
delete();
selectAll(false, false);
}
});
registerForContextMenu(albumListView);
enableButtons();
String id = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_ID);
boolean isAlbum = getIntent().getBooleanExtra(Constants.INTENT_EXTRA_NAME_IS_ALBUM, false);
String name = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_NAME);
String parentId = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_PARENT_ID);
String playlistId = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID);
String podcastChannelId = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_PODCAST_CHANNEL_ID);
String playlistName = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_NAME);
String shareId = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_SHARE_ID);
String shareName = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_SHARE_NAME);
String albumListType = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TYPE);
String genreName = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_GENRE_NAME);
int albumListTitle = getIntent().getIntExtra(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TITLE, 0);
int getStarredTracks = getIntent().getIntExtra(Constants.INTENT_EXTRA_NAME_STARRED, 0);
int getVideos = getIntent().getIntExtra(Constants.INTENT_EXTRA_NAME_VIDEOS, 0);
int getRandomTracks = getIntent().getIntExtra(Constants.INTENT_EXTRA_NAME_RANDOM, 0);
int albumListSize = getIntent().getIntExtra(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, 0);
int albumListOffset = getIntent().getIntExtra(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_OFFSET, 0);
View browseMenuItem = findViewById(R.id.menu_browse);
menuDrawer.setActiveView(browseMenuItem);
if (playlistId != null) {
getPlaylist(playlistId, playlistName);
} else if (podcastChannelId != null) {
getPodcastEpisodes(podcastChannelId);
} else if (shareId != null) {
getShare(shareId, shareName);
} else if (albumListType != null) {
getAlbumList(albumListType, albumListTitle, albumListSize, albumListOffset);
} else if (genreName != null) {
getSongsForGenre(genreName, albumListSize, albumListOffset);
} else if (getStarredTracks != 0) {
getStarred();
} else if (getVideos != 0) {
getVideos();
} else if (getRandomTracks != 0) {
getRandom(albumListSize);
} else {
if (!Util.isOffline(SelectAlbumActivity.this) && Util.getShouldUseId3Tags(SelectAlbumActivity.this)) {
if (isAlbum) {
getAlbum(id, name, parentId);
} else {
getArtist(id, name);
}
} else {
getMusicDirectory(id, name, parentId);
}
}
}
Aggregations