Commit b5e4523b by eguven Committed by Oliver Woodman

Remove index modifier methods from DownloadIndex interface

PiperOrigin-RevId: 239045412
parent d85ee01a
...@@ -29,7 +29,6 @@ import com.google.android.exoplayer2.offline.ActionFile; ...@@ -29,7 +29,6 @@ import com.google.android.exoplayer2.offline.ActionFile;
import com.google.android.exoplayer2.offline.DefaultDownloadIndex; import com.google.android.exoplayer2.offline.DefaultDownloadIndex;
import com.google.android.exoplayer2.offline.DownloadAction; import com.google.android.exoplayer2.offline.DownloadAction;
import com.google.android.exoplayer2.offline.DownloadHelper; 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.DownloadManager;
import com.google.android.exoplayer2.offline.DownloadService; import com.google.android.exoplayer2.offline.DownloadService;
import com.google.android.exoplayer2.offline.DownloadState; import com.google.android.exoplayer2.offline.DownloadState;
...@@ -68,7 +67,7 @@ public class DownloadTracker implements DownloadManager.Listener { ...@@ -68,7 +67,7 @@ public class DownloadTracker implements DownloadManager.Listener {
private final DataSource.Factory dataSourceFactory; private final DataSource.Factory dataSourceFactory;
private final CopyOnWriteArraySet<Listener> listeners; private final CopyOnWriteArraySet<Listener> listeners;
private final HashMap<Uri, DownloadState> trackedDownloadStates; private final HashMap<Uri, DownloadState> trackedDownloadStates;
private final DownloadIndex downloadIndex; private final DefaultDownloadIndex downloadIndex;
private final Handler indexHandler; private final Handler indexHandler;
@Nullable private StartDownloadDialogHelper startDownloadDialogHelper; @Nullable private StartDownloadDialogHelper startDownloadDialogHelper;
......
...@@ -183,7 +183,12 @@ public final class DefaultDownloadIndex implements DownloadIndex { ...@@ -183,7 +183,12 @@ public final class DefaultDownloadIndex implements DownloadIndex {
return new DownloadStateCursorImpl(cursor); 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 { public void putDownloadState(DownloadState downloadState) throws DatabaseIOException {
ensureInitialized(); ensureInitialized();
Assertions.checkState(downloadState.state != DownloadState.STATE_REMOVED); Assertions.checkState(downloadState.state != DownloadState.STATE_REMOVED);
...@@ -212,7 +217,11 @@ public final class DefaultDownloadIndex implements DownloadIndex { ...@@ -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 { public void removeDownloadState(String id) throws DatabaseIOException {
ensureInitialized(); ensureInitialized();
try { try {
......
...@@ -41,18 +41,4 @@ public interface DownloadIndex { ...@@ -41,18 +41,4 @@ public interface DownloadIndex {
*/ */
DownloadStateCursor getDownloadStates(@DownloadState.State int... states) throws IOException; 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;
} }
...@@ -48,7 +48,7 @@ public final class DownloadIndexUtil { ...@@ -48,7 +48,7 @@ public final class DownloadIndexUtil {
*/ */
public static void upgradeActionFile( public static void upgradeActionFile(
ActionFile actionFile, ActionFile actionFile,
DownloadIndex downloadIndex, DefaultDownloadIndex downloadIndex,
@Nullable DownloadIdProvider downloadIdProvider) @Nullable DownloadIdProvider downloadIdProvider)
throws IOException { throws IOException {
if (downloadIdProvider == null) { if (downloadIdProvider == null) {
...@@ -72,7 +72,8 @@ public final class DownloadIndexUtil { ...@@ -72,7 +72,8 @@ public final class DownloadIndexUtil {
* @throws IOException If an error occurs storing the state in the {@link DownloadIndex}. * @throws IOException If an error occurs storing the state in the {@link DownloadIndex}.
*/ */
public static void addAction( 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); DownloadState downloadState = downloadIndex.getDownloadState(id != null ? id : action.id);
if (downloadState != null) { if (downloadState != null) {
downloadState = downloadState.mergeAction(action); downloadState = downloadState.mergeAction(action);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment