From d4f5c9c721d5bba4a35c8c979633d2b7ddeb6148 Mon Sep 17 00:00:00 2001 From: eguven Date: Tue, 26 Mar 2019 22:45:03 +0000 Subject: [PATCH] Remove DownloadHelper.getRemoveAction PiperOrigin-RevId: 240444051 --- .../android/exoplayer2/demo/DownloadTracker.java | 11 ++++++----- .../android/exoplayer2/offline/DownloadHelper.java | 9 --------- .../exoplayer2/offline/DownloadHelperTest.java | 11 ----------- 3 files changed, 6 insertions(+), 25 deletions(-) diff --git a/demos/main/src/main/java/com/google/android/exoplayer2/demo/DownloadTracker.java b/demos/main/src/main/java/com/google/android/exoplayer2/demo/DownloadTracker.java index 46e700c812..73e881208d 100644 --- a/demos/main/src/main/java/com/google/android/exoplayer2/demo/DownloadTracker.java +++ b/demos/main/src/main/java/com/google/android/exoplayer2/demo/DownloadTracker.java @@ -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( diff --git a/library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadHelper.java b/library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadHelper.java index ae22200329..dccc15f020 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadHelper.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadHelper.java @@ -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() { diff --git a/library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadHelperTest.java b/library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadHelperTest.java index a78b229043..8fd3bebef6 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadHelperTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadHelperTest.java @@ -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 prepareException = new AtomicReference<>(null); ConditionVariable preparedCondition = new ConditionVariable();