use of net.rdrei.android.scdl2.api.PendingDownload in project scdl by passy.
the class ShareIntentResolver method resolvePendingDownload.
/**
* Resolves the intent to a PendingDownload describing the ID and type of the download.
*
* @return PendingDownload containing the resolved track or playlist ID together with its type.
* @throws ShareIntentResolverException
*/
public PendingDownload resolvePendingDownload() throws ShareIntentResolverException {
final String id;
final String url = resolve();
final Matcher idMatcher = URL_ID_PATTERN.matcher(url);
final Matcher playlistMatcher = URL_PLAYLIST_PATTERN.matcher(url);
if (!Config.Features.PLAYLIST_DOWNLOADS && playlistMatcher.find()) {
throw new UnsupportedPlaylistUrlException(mActivity.getString(R.string.track_error_unsupported_playlist));
}
if (idMatcher.find()) {
id = idMatcher.group(1);
} else {
throw new ShareIntentResolverException(String.format("Could not parse ID from URL '%s'.", url));
}
return new PendingDownload(id, MediaDownloadType.TRACK);
}
use of net.rdrei.android.scdl2.api.PendingDownload in project scdl by passy.
the class AbstractMediaStateLoaderTaskTest method testCallForPlayList.
@Test
public void testCallForPlayList() throws Exception {
final PendingDownload pendingDownload = new PendingDownload("1234", MediaDownloadType.PLAYLIST);
final AbstractMediaStateLoaderTask task = new AbstractMediaStateLoaderTask(mContext, pendingDownload);
task.call();
verify(mPlaylistService).getPlaylist("1234");
verifyZeroInteractions(mTrackService);
}
use of net.rdrei.android.scdl2.api.PendingDownload in project scdl by passy.
the class ShareIntentResolverTest method testResolveSoundcloudDataUrlToId.
@Test
public void testResolveSoundcloudDataUrlToId() throws ShareIntentResolverException {
ShadowIntent intent = Robolectric.shadowOf(mIntent);
intent.setData(Uri.parse("soundcloud://tracks/76738498"));
final ShareIntentResolver resolver = TestHelper.getInjector().getInstance(ShareIntentResolver.class);
final PendingDownload result = resolver.resolvePendingDownload();
assertThat(result.getId(), equalTo("76738498"));
assertThat(result.getType(), equalTo(MediaDownloadType.TRACK));
}
use of net.rdrei.android.scdl2.api.PendingDownload in project scdl by passy.
the class ShareIntentResolverTest method testResolveToId.
@Test
public void testResolveToId() throws ShareIntentResolverException {
ShadowIntent intent = Robolectric.shadowOf(mIntent);
intent.setData(Uri.parse("https://soundcloud.com/dj-newklear/newklear-contaminated-2"));
final ShareIntentResolver resolver = TestHelper.getInjector().getInstance(ShareIntentResolver.class);
final PendingDownload result = resolver.resolvePendingDownload();
assertThat(result.getId(), equalTo("44276907"));
assertThat(result.getType(), equalTo(MediaDownloadType.TRACK));
}
use of net.rdrei.android.scdl2.api.PendingDownload in project scdl by passy.
the class ShareIntentResolverTest method testNoSslResolveToId.
@Test
public void testNoSslResolveToId() throws ShareIntentResolverException {
ShadowIntent intent = Robolectric.shadowOf(mIntent);
intent.setData(Uri.parse("http://soundcloud.com/dj-newklear/newklear-contaminated-2"));
final ShareIntentResolver resolver = TestHelper.getInjector().getInstance(ShareIntentResolver.class);
final PendingDownload result = resolver.resolvePendingDownload();
assertThat(result.getId(), equalTo("44276907"));
assertThat(result.getType(), equalTo(MediaDownloadType.TRACK));
}
Aggregations