Search in sources :

Example 1 with TabActivityBackgroundTask

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();
}
Also used : TabActivityBackgroundTask(org.moire.ultrasonic.util.TabActivityBackgroundTask) MusicService(org.moire.ultrasonic.service.MusicService) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Genre(org.moire.ultrasonic.domain.Genre) GenreAdapter(org.moire.ultrasonic.view.GenreAdapter)

Example 2 with TabActivityBackgroundTask

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();
}
Also used : Playlist(org.moire.ultrasonic.domain.Playlist) TabActivityBackgroundTask(org.moire.ultrasonic.util.TabActivityBackgroundTask) MusicService(org.moire.ultrasonic.service.MusicService) PlaylistAdapter(org.moire.ultrasonic.view.PlaylistAdapter) List(java.util.List) CacheCleaner(org.moire.ultrasonic.util.CacheCleaner)

Example 3 with TabActivityBackgroundTask

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();
}
Also used : TabActivityBackgroundTask(org.moire.ultrasonic.util.TabActivityBackgroundTask) MusicService(org.moire.ultrasonic.service.MusicService) List(java.util.List) ShareAdapter(org.moire.ultrasonic.view.ShareAdapter) Share(org.moire.ultrasonic.domain.Share)

Example 4 with TabActivityBackgroundTask

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();
}
Also used : TabActivityBackgroundTask(org.moire.ultrasonic.util.TabActivityBackgroundTask) MusicService(org.moire.ultrasonic.service.MusicService) Lyrics(org.moire.ultrasonic.domain.Lyrics) TextView(android.widget.TextView)

Example 5 with TabActivityBackgroundTask

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();
}
Also used : TabActivityBackgroundTask(org.moire.ultrasonic.util.TabActivityBackgroundTask) PodcastsChannelsAdapter(org.moire.ultrasonic.view.PodcastsChannelsAdapter) PodcastsChannel(org.moire.ultrasonic.domain.PodcastsChannel) MusicService(org.moire.ultrasonic.service.MusicService) List(java.util.List)

Aggregations

MusicService (org.moire.ultrasonic.service.MusicService)10 TabActivityBackgroundTask (org.moire.ultrasonic.util.TabActivityBackgroundTask)10 List (java.util.List)5 ArrayList (java.util.ArrayList)4 Share (org.moire.ultrasonic.domain.Share)2 Intent (android.content.Intent)1 Editable (android.text.Editable)1 ListAdapter (android.widget.ListAdapter)1 TextView (android.widget.TextView)1 Artist (org.moire.ultrasonic.domain.Artist)1 ChatMessage (org.moire.ultrasonic.domain.ChatMessage)1 Genre (org.moire.ultrasonic.domain.Genre)1 Indexes (org.moire.ultrasonic.domain.Indexes)1 Lyrics (org.moire.ultrasonic.domain.Lyrics)1 Entry (org.moire.ultrasonic.domain.MusicDirectory.Entry)1 MusicFolder (org.moire.ultrasonic.domain.MusicFolder)1 Playlist (org.moire.ultrasonic.domain.Playlist)1 PodcastsChannel (org.moire.ultrasonic.domain.PodcastsChannel)1 SearchCriteria (org.moire.ultrasonic.domain.SearchCriteria)1 SearchResult (org.moire.ultrasonic.domain.SearchResult)1