From b5e4523b584f8abcd054ededafd3aa3474f11229 Mon Sep 17 00:00:00 2001 From: eguven Date: Mon, 18 Mar 2019 20:08:37 +0000 Subject: [PATCH] Remove index modifier methods from DownloadIndex interface PiperOrigin-RevId: 239045412 --- .../android/exoplayer2/demo/DownloadTracker.java | 3 +-- .../exoplayer2/offline/DefaultDownloadIndex.java | 13 +++++++++++-- .../android/exoplayer2/offline/DownloadIndex.java | 14 -------------- .../exoplayer2/offline/DownloadIndexUtil.java | 5 +++-- 4 files changed, 15 insertions(+), 20 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 6cac50db81..6fd186cd9e 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 @@ -29,7 +29,6 @@ import com.google.android.exoplayer2.offline.ActionFile; import com.google.android.exoplayer2.offline.DefaultDownloadIndex; import com.google.android.exoplayer2.offline.DownloadAction; import com.google.android.exoplayer2.offline.DownloadHelper; -import com.google.android.exoplayer2.offline.DownloadIndex; import com.google.android.exoplayer2.offline.DownloadManager; import com.google.android.exoplayer2.offline.DownloadService; import com.google.android.exoplayer2.offline.DownloadState; @@ -68,7 +67,7 @@ public class DownloadTracker implements DownloadManager.Listener { private final DataSource.Factory dataSourceFactory; private final CopyOnWriteArraySet listeners; private final HashMap trackedDownloadStates; - private final DownloadIndex downloadIndex; + private final DefaultDownloadIndex downloadIndex; private final Handler indexHandler; @Nullable private StartDownloadDialogHelper startDownloadDialogHelper; diff --git a/library/core/src/main/java/com/google/android/exoplayer2/offline/DefaultDownloadIndex.java b/library/core/src/main/java/com/google/android/exoplayer2/offline/DefaultDownloadIndex.java index 5909c60d16..e84f90a811 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/offline/DefaultDownloadIndex.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/offline/DefaultDownloadIndex.java @@ -183,7 +183,12 @@ public final class DefaultDownloadIndex implements DownloadIndex { return new DownloadStateCursorImpl(cursor); } - @Override + /** + * Adds or replaces a {@link DownloadState}. + * + * @param downloadState The {@link DownloadState} to be added. + * @throws DatabaseIOException If an error occurs setting the state. + */ public void putDownloadState(DownloadState downloadState) throws DatabaseIOException { ensureInitialized(); Assertions.checkState(downloadState.state != DownloadState.STATE_REMOVED); @@ -212,7 +217,11 @@ public final class DefaultDownloadIndex implements DownloadIndex { } } - @Override + /** + * Removes the {@link DownloadState} with the given {@code id}. + * + * @throws DatabaseIOException If an error occurs removing the state. + */ public void removeDownloadState(String id) throws DatabaseIOException { ensureInitialized(); try { diff --git a/library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadIndex.java b/library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadIndex.java index 8d997e07ff..a9a4c69954 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadIndex.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadIndex.java @@ -41,18 +41,4 @@ public interface DownloadIndex { */ DownloadStateCursor getDownloadStates(@DownloadState.State int... states) throws IOException; - /** - * Adds or replaces a {@link DownloadState}. - * - * @param downloadState The {@link DownloadState} to be added. - * @throws IOException If an error occurs setting the state. - */ - void putDownloadState(DownloadState downloadState) throws IOException; - - /** - * Removes the {@link DownloadState} with the given {@code id}. - * - * @throws IOException If an error occurs removing the state. - */ - void removeDownloadState(String id) throws IOException; } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadIndexUtil.java b/library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadIndexUtil.java index ef1418b24f..524e71e9e2 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadIndexUtil.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadIndexUtil.java @@ -48,7 +48,7 @@ public final class DownloadIndexUtil { */ public static void upgradeActionFile( ActionFile actionFile, - DownloadIndex downloadIndex, + DefaultDownloadIndex downloadIndex, @Nullable DownloadIdProvider downloadIdProvider) throws IOException { if (downloadIdProvider == null) { @@ -72,7 +72,8 @@ public final class DownloadIndexUtil { * @throws IOException If an error occurs storing the state in the {@link DownloadIndex}. */ public static void addAction( - DownloadIndex downloadIndex, @Nullable String id, DownloadAction action) throws IOException { + DefaultDownloadIndex downloadIndex, @Nullable String id, DownloadAction action) + throws IOException { DownloadState downloadState = downloadIndex.getDownloadState(id != null ? id : action.id); if (downloadState != null) { downloadState = downloadState.mergeAction(action);