Search in sources :

Example 6 with Share

use of org.moire.ultrasonic.domain.Share in project ultrasonic by ultrasonic.

the class SelectAlbumActivity method getShare.

private void getShare(final String shareId, final CharSequence shareName) {
    setActionBarSubtitle(shareName);
    new LoadTask() {

        @Override
        protected MusicDirectory load(MusicService service) throws Exception {
            List<Share> shares = service.getShares(true, SelectAlbumActivity.this, this);
            MusicDirectory md = new MusicDirectory();
            for (Share share : shares) {
                if (share.getId().equals(shareId)) {
                    for (MusicDirectory.Entry entry : share.getEntries()) {
                        md.addChild(entry);
                    }
                    break;
                }
            }
            return md;
        }
    }.execute();
}
Also used : MusicDirectory(org.moire.ultrasonic.domain.MusicDirectory) MusicService(org.moire.ultrasonic.service.MusicService) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) Share(org.moire.ultrasonic.domain.Share)

Example 7 with Share

use of org.moire.ultrasonic.domain.Share in project ultrasonic by ultrasonic.

the class SubsonicTabActivity method share.

public void share() {
    BackgroundTask<Share> task = new TabActivityBackgroundTask<Share>(this, true) {

        @Override
        protected Share doInBackground() throws Throwable {
            List<String> ids = new ArrayList<String>();
            if (shareDetails.Entries.isEmpty()) {
                ids.add(getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_ID));
            } else {
                for (Entry entry : shareDetails.Entries) {
                    ids.add(entry.getId());
                }
            }
            MusicService musicService = MusicServiceFactory.getMusicService(SubsonicTabActivity.this);
            long timeInMillis = 0;
            if (shareDetails.Expiration != 0) {
                timeInMillis = shareDetails.Expiration;
            }
            List<Share> shares = musicService.createShare(ids, shareDetails.Description, timeInMillis, SubsonicTabActivity.this, this);
            return shares.get(0);
        }

        @Override
        protected void done(Share result) {
            Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("text/plain");
            intent.putExtra(Intent.EXTRA_TEXT, String.format("%s\n\n%s", Util.getShareGreeting(SubsonicTabActivity.this), result.getUrl()));
            startActivity(Intent.createChooser(intent, getResources().getString(R.string.share_via)));
        }
    };
    task.execute();
}
Also used : Entry(org.moire.ultrasonic.domain.MusicDirectory.Entry) TabActivityBackgroundTask(org.moire.ultrasonic.util.TabActivityBackgroundTask) MusicService(org.moire.ultrasonic.service.MusicService) ArrayList(java.util.ArrayList) Intent(android.content.Intent) Share(org.moire.ultrasonic.domain.Share)

Aggregations

Share (org.moire.ultrasonic.domain.Share)7 MusicService (org.moire.ultrasonic.service.MusicService)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Intent (android.content.Intent)2 LinkedList (java.util.LinkedList)2 MusicDirectory (org.moire.ultrasonic.domain.MusicDirectory)2 Entry (org.moire.ultrasonic.domain.MusicDirectory.Entry)2 TabActivityBackgroundTask (org.moire.ultrasonic.util.TabActivityBackgroundTask)2 AdapterView (android.widget.AdapterView)1 Collection (java.util.Collection)1 DownloadService (org.moire.ultrasonic.service.DownloadService)1 EntryByDiscAndTrackComparator (org.moire.ultrasonic.util.EntryByDiscAndTrackComparator)1 ModalBackgroundTask (org.moire.ultrasonic.util.ModalBackgroundTask)1 ShareAdapter (org.moire.ultrasonic.view.ShareAdapter)1