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();
}
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();
}
Aggregations