Remove index modifier methods from DownloadIndex interface

PiperOrigin-RevId: 239045412
This commit is contained in:
eguven 2019-03-18 20:08:37 +00:00 committed by Oliver Woodman
parent d85ee01ae7
commit b5e4523b58
4 changed files with 15 additions and 20 deletions

View file

@ -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<Listener> listeners;
private final HashMap<Uri, DownloadState> trackedDownloadStates;
private final DownloadIndex downloadIndex;
private final DefaultDownloadIndex downloadIndex;
private final Handler indexHandler;
@Nullable private StartDownloadDialogHelper startDownloadDialogHelper;

View file

@ -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 {

View file

@ -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;
}

View file

@ -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);