use of org.moire.ultrasonic.util.TabActivityBackgroundTask in project ultrasonic by ultrasonic.
the class SelectGenreActivity method load.
private void load() {
BackgroundTask<List<Genre>> task = new TabActivityBackgroundTask<List<Genre>>(this, true) {
@Override
protected List<Genre> doInBackground() throws Throwable {
MusicService musicService = MusicServiceFactory.getMusicService(SelectGenreActivity.this);
List<Genre> genres = new ArrayList<Genre>();
try {
genres = musicService.getGenres(SelectGenreActivity.this, this);
} catch (Exception x) {
Log.e(TAG, "Failed to load genres", x);
}
return genres;
}
@Override
protected void done(List<Genre> result) {
emptyView.setVisibility(result == null || result.isEmpty() ? View.VISIBLE : View.GONE);
if (result != null) {
genreListView.setAdapter(new GenreAdapter(SelectGenreActivity.this, result));
}
}
};
task.execute();
}
use of org.moire.ultrasonic.util.TabActivityBackgroundTask in project ultrasonic by ultrasonic.
the class SelectPlaylistActivity method load.
private void load() {
BackgroundTask<List<Playlist>> task = new TabActivityBackgroundTask<List<Playlist>>(this, true) {
@Override
protected List<Playlist> doInBackground() throws Throwable {
MusicService musicService = MusicServiceFactory.getMusicService(SelectPlaylistActivity.this);
boolean refresh = getIntent().getBooleanExtra(Constants.INTENT_EXTRA_NAME_REFRESH, false);
List<Playlist> playlists = musicService.getPlaylists(refresh, SelectPlaylistActivity.this, this);
if (!Util.isOffline(SelectPlaylistActivity.this))
new CacheCleaner(SelectPlaylistActivity.this, getDownloadService()).cleanPlaylists(playlists);
return playlists;
}
@Override
protected void done(List<Playlist> result) {
playlistsListView.setAdapter(playlistAdapter = new PlaylistAdapter(SelectPlaylistActivity.this, result));
emptyTextView.setVisibility(result.isEmpty() ? View.VISIBLE : View.GONE);
}
};
task.execute();
}
use of org.moire.ultrasonic.util.TabActivityBackgroundTask in project ultrasonic by ultrasonic.
the class ShareActivity method load.
private void load() {
BackgroundTask<List<Share>> task = new TabActivityBackgroundTask<List<Share>>(this, true) {
@Override
protected List<Share> doInBackground() throws Throwable {
MusicService musicService = MusicServiceFactory.getMusicService(ShareActivity.this);
boolean refresh = getIntent().getBooleanExtra(Constants.INTENT_EXTRA_NAME_REFRESH, false);
return musicService.getShares(refresh, ShareActivity.this, this);
}
@Override
protected void done(List<Share> result) {
sharesListView.setAdapter(shareAdapter = new ShareAdapter(ShareActivity.this, result));
emptyTextView.setVisibility(result.isEmpty() ? View.VISIBLE : View.GONE);
}
};
task.execute();
}
use of org.moire.ultrasonic.util.TabActivityBackgroundTask in project ultrasonic by ultrasonic.
the class LyricsActivity method load.
private void load() {
BackgroundTask<Lyrics> task = new TabActivityBackgroundTask<Lyrics>(this, true) {
@Override
protected Lyrics doInBackground() throws Throwable {
String artist = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_ARTIST);
String title = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_TITLE);
MusicService musicService = MusicServiceFactory.getMusicService(LyricsActivity.this);
return musicService.getLyrics(artist, title, LyricsActivity.this, this);
}
@Override
protected void done(Lyrics result) {
TextView artistView = (TextView) findViewById(R.id.lyrics_artist);
TextView titleView = (TextView) findViewById(R.id.lyrics_title);
TextView textView = (TextView) findViewById(R.id.lyrics_text);
if (result != null && result.getArtist() != null) {
artistView.setText(result.getArtist());
titleView.setText(result.getTitle());
textView.setText(result.getText());
} else {
artistView.setText(R.string.lyrics_nomatch);
}
}
};
task.execute();
}
use of org.moire.ultrasonic.util.TabActivityBackgroundTask in project ultrasonic by ultrasonic.
the class PodcastsActivity method load.
private void load() {
BackgroundTask<List<PodcastsChannel>> task = new TabActivityBackgroundTask<List<PodcastsChannel>>(this, true) {
@Override
protected List<PodcastsChannel> doInBackground() throws Throwable {
MusicService musicService = MusicServiceFactory.getMusicService(PodcastsActivity.this);
List<PodcastsChannel> channels = musicService.getPodcastsChannels(false, PodcastsActivity.this, this);
/* TODO c'est quoi ce nettoyage de cache ?
if (!Util.isOffline(PodcastsActivity.this))
new CacheCleaner(PodcastsActivity.this, getDownloadService()).cleanPlaylists(playlists);
*/
return channels;
}
@Override
protected void done(List<PodcastsChannel> result) {
channelItemsListView.setAdapter(new PodcastsChannelsAdapter(currentActivity, result));
emptyTextView.setVisibility(result.isEmpty() ? View.VISIBLE : View.GONE);
}
};
task.execute();
}
Aggregations