Remove DownloadHelper.getRemoveAction

PiperOrigin-RevId: 240444051
This commit is contained in:
eguven 2019-03-26 22:45:03 +00:00 committed by Toni
parent 9d99f92146
commit d4f5c9c721
3 changed files with 6 additions and 25 deletions

View File

@ -106,10 +106,10 @@ public class DownloadTracker implements DownloadManager.Listener {
Uri uri,
String extension,
RenderersFactory renderersFactory) {
if (isDownloaded(uri)) {
DownloadAction removeAction =
getDownloadHelper(uri, extension, renderersFactory).getRemoveAction();
startServiceWithAction(removeAction);
DownloadState downloadState = downloadStates.get(uri);
if (downloadState != null) {
DownloadService.startWithRemoveDownload(
context, DemoDownloadService.class, downloadState.id, /* foreground= */ false);
} else {
if (startDownloadDialogHelper != null) {
startDownloadDialogHelper.release();
@ -153,7 +153,8 @@ public class DownloadTracker implements DownloadManager.Listener {
}
private void startServiceWithAction(DownloadAction action) {
DownloadService.startWithAction(context, DemoDownloadService.class, action, false);
DownloadService.startWithAction(
context, DemoDownloadService.class, action, /* foreground= */ false);
}
private DownloadHelper getDownloadHelper(

View File

@ -606,15 +606,6 @@ public final class DownloadHelper {
return DownloadAction.createDownloadAction(downloadType, uri, streamKeys, cacheKey, data);
}
/**
* Builds a {@link DownloadAction} for removing the media. May be called in any state.
*
* @return The built {@link DownloadAction}.
*/
public DownloadAction getRemoveAction() {
return DownloadAction.createRemoveAction(downloadType, uri, cacheKey);
}
// Initialization of array of Lists.
@SuppressWarnings("unchecked")
private void onMediaPrepared() {

View File

@ -26,7 +26,6 @@ import com.google.android.exoplayer2.RenderersFactory;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.offline.DownloadHelper.Callback;
import com.google.android.exoplayer2.source.MediaPeriod;
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
import com.google.android.exoplayer2.source.MediaSourceEventListener.EventDispatcher;
import com.google.android.exoplayer2.source.TrackGroup;
import com.google.android.exoplayer2.source.TrackGroupArray;
@ -411,16 +410,6 @@ public class DownloadHelperTest {
new StreamKey(/* periodIndex= */ 1, /* groupIndex= */ 1, /* trackIndex= */ 0));
}
@Test
public void getRemoveAction_returnsRemoveAction() {
DownloadAction removeAction = downloadHelper.getRemoveAction();
assertThat(removeAction.type).isEqualTo(TEST_DOWNLOAD_TYPE);
assertThat(removeAction.uri).isEqualTo(testUri);
assertThat(removeAction.customCacheKey).isEqualTo(TEST_CACHE_KEY);
assertThat(removeAction.isRemoveAction).isTrue();
}
private static void prepareDownloadHelper(DownloadHelper downloadHelper) throws Exception {
AtomicReference<Exception> prepareException = new AtomicReference<>(null);
ConditionVariable preparedCondition = new ConditionVariable();