com.google.android.exoplayer2.database.DatabaseProvider Java Examples

The following examples show how to use com.google.android.exoplayer2.database.DatabaseProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CacheFileMetadataIndex.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * Deletes index data for the specified cache.
 *
 * <p>This method may be slow and shouldn't normally be called on the main thread.
 *
 * @param databaseProvider Provides the database in which the index is stored.
 * @param uid The cache UID.
 * @throws DatabaseIOException If an error occurs deleting the index data.
 */
@WorkerThread
public static void delete(DatabaseProvider databaseProvider, long uid)
    throws DatabaseIOException {
  String hexUid = Long.toHexString(uid);
  try {
    String tableName = getTableName(hexUid);
    SQLiteDatabase writableDatabase = databaseProvider.getWritableDatabase();
    writableDatabase.beginTransactionNonExclusive();
    try {
      VersionTable.removeVersion(
          writableDatabase, VersionTable.FEATURE_CACHE_FILE_METADATA, hexUid);
      dropTable(writableDatabase, tableName);
      writableDatabase.setTransactionSuccessful();
    } finally {
      writableDatabase.endTransaction();
    }
  } catch (SQLException e) {
    throw new DatabaseIOException(e);
  }
}
 
Example #2
Source File: CachedContentIndex.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private static void delete(DatabaseProvider databaseProvider, String hexUid)
    throws DatabaseIOException {
  try {
    String tableName = getTableName(hexUid);
    SQLiteDatabase writableDatabase = databaseProvider.getWritableDatabase();
    writableDatabase.beginTransaction();
    try {
      VersionTable.removeVersion(
          writableDatabase, VersionTable.FEATURE_CACHE_CONTENT_METADATA, hexUid);
      dropTable(writableDatabase, tableName);
      writableDatabase.setTransactionSuccessful();
    } finally {
      writableDatabase.endTransaction();
    }
  } catch (SQLException e) {
    throw new DatabaseIOException(e);
  }
}
 
Example #3
Source File: CacheFileMetadataIndex.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Deletes index data for the specified cache.
 *
 * @param databaseProvider Provides the database in which the index is stored.
 * @param uid The cache UID.
 * @throws DatabaseIOException If an error occurs deleting the index data.
 */
public static void delete(DatabaseProvider databaseProvider, long uid)
    throws DatabaseIOException {
  String hexUid = Long.toHexString(uid);
  try {
    String tableName = getTableName(hexUid);
    SQLiteDatabase writableDatabase = databaseProvider.getWritableDatabase();
    writableDatabase.beginTransaction();
    try {
      VersionTable.removeVersion(
          writableDatabase, VersionTable.FEATURE_CACHE_FILE_METADATA, hexUid);
      dropTable(writableDatabase, tableName);
      writableDatabase.setTransactionSuccessful();
    } finally {
      writableDatabase.endTransaction();
    }
  } catch (SQLException e) {
    throw new DatabaseIOException(e);
  }
}
 
Example #4
Source File: SimpleCache.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs the cache. The cache will delete any unrecognized files from the cache directory.
 * Hence the directory cannot be used to store other files.
 *
 * @param cacheDir A dedicated cache directory.
 * @param evictor The evictor to be used. For download use cases where cache eviction should not
 *     occur, use {@link NoOpCacheEvictor}.
 * @param databaseProvider Provides the database in which the cache index is stored, or {@code
 *     null} to use a legacy index. Using a database index is highly recommended for performance
 *     reasons.
 * @param legacyIndexSecretKey A 16 byte AES key for reading, and optionally writing, the legacy
 *     index. Not used by the database index, however should still be provided when using the
 *     database index in cases where upgrading from the legacy index may be necessary.
 * @param legacyIndexEncrypt Whether to encrypt when writing to the legacy index. Must be {@code
 *     false} if {@code legacyIndexSecretKey} is {@code null}. Not used by the database index.
 * @param preferLegacyIndex Whether to use the legacy index even if a {@code databaseProvider} is
 *     provided. Should be {@code false} in nearly all cases. Setting this to {@code true} is only
 *     useful for downgrading from the database index back to the legacy index.
 */
public SimpleCache(
    File cacheDir,
    CacheEvictor evictor,
    @Nullable DatabaseProvider databaseProvider,
    @Nullable byte[] legacyIndexSecretKey,
    boolean legacyIndexEncrypt,
    boolean preferLegacyIndex) {
  this(
      cacheDir,
      evictor,
      new CachedContentIndex(
          databaseProvider,
          cacheDir,
          legacyIndexSecretKey,
          legacyIndexEncrypt,
          preferLegacyIndex),
      databaseProvider != null && !preferLegacyIndex
          ? new CacheFileMetadataIndex(databaseProvider)
          : null);
}
 
Example #5
Source File: SimpleCache.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs the cache. The cache will delete any unrecognized files from the cache directory.
 * Hence the directory cannot be used to store other files.
 *
 * @param cacheDir A dedicated cache directory.
 * @param evictor The evictor to be used. For download use cases where cache eviction should not
 *     occur, use {@link NoOpCacheEvictor}.
 * @param databaseProvider Provides the database in which the cache index is stored, or {@code
 *     null} to use a legacy index. Using a database index is highly recommended for performance
 *     reasons.
 * @param legacyIndexSecretKey A 16 byte AES key for reading, and optionally writing, the legacy
 *     index. Not used by the database index, however should still be provided when using the
 *     database index in cases where upgrading from the legacy index may be necessary.
 * @param legacyIndexEncrypt Whether to encrypt when writing to the legacy index. Must be {@code
 *     false} if {@code legacyIndexSecretKey} is {@code null}. Not used by the database index.
 * @param preferLegacyIndex Whether to use the legacy index even if a {@code databaseProvider} is
 *     provided. Should be {@code false} in nearly all cases. Setting this to {@code true} is only
 *     useful for downgrading from the database index back to the legacy index.
 */
public SimpleCache(
    File cacheDir,
    CacheEvictor evictor,
    @Nullable DatabaseProvider databaseProvider,
    @Nullable byte[] legacyIndexSecretKey,
    boolean legacyIndexEncrypt,
    boolean preferLegacyIndex) {
  this(
      cacheDir,
      evictor,
      new CachedContentIndex(
          databaseProvider,
          cacheDir,
          legacyIndexSecretKey,
          legacyIndexEncrypt,
          preferLegacyIndex),
      databaseProvider != null && !preferLegacyIndex
          ? new CacheFileMetadataIndex(databaseProvider)
          : null);
}
 
Example #6
Source File: CachedContentIndex.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
private static void delete(DatabaseProvider databaseProvider, String hexUid)
    throws DatabaseIOException {
  try {
    String tableName = getTableName(hexUid);
    SQLiteDatabase writableDatabase = databaseProvider.getWritableDatabase();
    writableDatabase.beginTransactionNonExclusive();
    try {
      VersionTable.removeVersion(
          writableDatabase, VersionTable.FEATURE_CACHE_CONTENT_METADATA, hexUid);
      dropTable(writableDatabase, tableName);
      writableDatabase.setTransactionSuccessful();
    } finally {
      writableDatabase.endTransaction();
    }
  } catch (SQLException e) {
    throw new DatabaseIOException(e);
  }
}
 
Example #7
Source File: SimpleCache.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs the cache. The cache will delete any unrecognized files from the cache directory.
 * Hence the directory cannot be used to store other files.
 *
 * @param cacheDir A dedicated cache directory.
 * @param evictor The evictor to be used. For download use cases where cache eviction should not
 *     occur, use {@link NoOpCacheEvictor}.
 * @param databaseProvider Provides the database in which the cache index is stored, or {@code
 *     null} to use a legacy index. Using a database index is highly recommended for performance
 *     reasons.
 * @param legacyIndexSecretKey A 16 byte AES key for reading, and optionally writing, the legacy
 *     index. Not used by the database index, however should still be provided when using the
 *     database index in cases where upgrading from the legacy index may be necessary.
 * @param legacyIndexEncrypt Whether to encrypt when writing to the legacy index. Must be {@code
 *     false} if {@code legacyIndexSecretKey} is {@code null}. Not used by the database index.
 * @param preferLegacyIndex Whether to use the legacy index even if a {@code databaseProvider} is
 *     provided. Should be {@code false} in nearly all cases. Setting this to {@code true} is only
 *     useful for downgrading from the database index back to the legacy index.
 */
public SimpleCache(
    File cacheDir,
    CacheEvictor evictor,
    @Nullable DatabaseProvider databaseProvider,
    @Nullable byte[] legacyIndexSecretKey,
    boolean legacyIndexEncrypt,
    boolean preferLegacyIndex) {
  this(
      cacheDir,
      evictor,
      new CachedContentIndex(
          databaseProvider,
          cacheDir,
          legacyIndexSecretKey,
          legacyIndexEncrypt,
          preferLegacyIndex),
      databaseProvider != null && !preferLegacyIndex
          ? new CacheFileMetadataIndex(databaseProvider)
          : null);
}
 
Example #8
Source File: CachedContentIndex.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private static void delete(DatabaseProvider databaseProvider, String hexUid)
    throws DatabaseIOException {
  try {
    String tableName = getTableName(hexUid);
    SQLiteDatabase writableDatabase = databaseProvider.getWritableDatabase();
    writableDatabase.beginTransaction();
    try {
      VersionTable.removeVersion(
          writableDatabase, VersionTable.FEATURE_CACHE_CONTENT_METADATA, hexUid);
      dropTable(writableDatabase, tableName);
      writableDatabase.setTransactionSuccessful();
    } finally {
      writableDatabase.endTransaction();
    }
  } catch (SQLException e) {
    throw new DatabaseIOException(e);
  }
}
 
Example #9
Source File: CacheFileMetadataIndex.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Deletes index data for the specified cache.
 *
 * @param databaseProvider Provides the database in which the index is stored.
 * @param uid The cache UID.
 * @throws DatabaseIOException If an error occurs deleting the index data.
 */
public static void delete(DatabaseProvider databaseProvider, long uid)
    throws DatabaseIOException {
  String hexUid = Long.toHexString(uid);
  try {
    String tableName = getTableName(hexUid);
    SQLiteDatabase writableDatabase = databaseProvider.getWritableDatabase();
    writableDatabase.beginTransaction();
    try {
      VersionTable.removeVersion(
          writableDatabase, VersionTable.FEATURE_CACHE_FILE_METADATA, hexUid);
      dropTable(writableDatabase, tableName);
      writableDatabase.setTransactionSuccessful();
    } finally {
      writableDatabase.endTransaction();
    }
  } catch (SQLException e) {
    throw new DatabaseIOException(e);
  }
}
 
Example #10
Source File: CachedContentIndex.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an instance supporting database storage only.
 *
 * @param databaseProvider Provides the database in which the index is stored.
 */
public CachedContentIndex(DatabaseProvider databaseProvider) {
  this(
      databaseProvider,
      /* legacyStorageDir= */ null,
      /* legacyStorageSecretKey= */ null,
      /* legacyStorageEncrypt= */ false,
      /* preferLegacyStorage= */ false);
}
 
Example #11
Source File: CachedContentIndex.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an instance supporting either or both of database and legacy storage.
 *
 * @param databaseProvider Provides the database in which the index is stored, or {@code null} to
 *     use only legacy storage.
 * @param legacyStorageDir The directory in which any legacy storage is stored, or {@code null} to
 *     use only database storage.
 * @param legacyStorageSecretKey A 16 byte AES key for reading, and optionally writing, legacy
 *     storage.
 * @param legacyStorageEncrypt Whether to encrypt when writing to legacy storage. Must be false if
 *     {@code legacyStorageSecretKey} is null.
 * @param preferLegacyStorage Whether to use prefer legacy storage if both storage types are
 *     enabled. This option is only useful for downgrading from database storage back to legacy
 *     storage.
 */
public CachedContentIndex(
    @Nullable DatabaseProvider databaseProvider,
    @Nullable File legacyStorageDir,
    @Nullable byte[] legacyStorageSecretKey,
    boolean legacyStorageEncrypt,
    boolean preferLegacyStorage) {
  Assertions.checkState(databaseProvider != null || legacyStorageDir != null);
  keyToContent = new HashMap<>();
  idToKey = new SparseArray<>();
  removedIds = new SparseBooleanArray();
  newIds = new SparseBooleanArray();
  Storage databaseStorage =
      databaseProvider != null ? new DatabaseStorage(databaseProvider) : null;
  Storage legacyStorage =
      legacyStorageDir != null
          ? new LegacyStorage(
              new File(legacyStorageDir, FILE_NAME_ATOMIC),
              legacyStorageSecretKey,
              legacyStorageEncrypt)
          : null;
  if (databaseStorage == null || (legacyStorage != null && preferLegacyStorage)) {
    storage = legacyStorage;
    previousStorage = databaseStorage;
  } else {
    storage = databaseStorage;
    previousStorage = legacyStorage;
  }
}
 
Example #12
Source File: CachedContentIndex.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates an instance supporting either or both of database and legacy storage.
 *
 * @param databaseProvider Provides the database in which the index is stored, or {@code null} to
 *     use only legacy storage.
 * @param legacyStorageDir The directory in which any legacy storage is stored, or {@code null} to
 *     use only database storage.
 * @param legacyStorageSecretKey A 16 byte AES key for reading, and optionally writing, legacy
 *     storage.
 * @param legacyStorageEncrypt Whether to encrypt when writing to legacy storage. Must be false if
 *     {@code legacyStorageSecretKey} is null.
 * @param preferLegacyStorage Whether to use prefer legacy storage if both storage types are
 *     enabled. This option is only useful for downgrading from database storage back to legacy
 *     storage.
 */
public CachedContentIndex(
    @Nullable DatabaseProvider databaseProvider,
    @Nullable File legacyStorageDir,
    @Nullable byte[] legacyStorageSecretKey,
    boolean legacyStorageEncrypt,
    boolean preferLegacyStorage) {
  Assertions.checkState(databaseProvider != null || legacyStorageDir != null);
  keyToContent = new HashMap<>();
  idToKey = new SparseArray<>();
  removedIds = new SparseBooleanArray();
  newIds = new SparseBooleanArray();
  Storage databaseStorage =
      databaseProvider != null ? new DatabaseStorage(databaseProvider) : null;
  Storage legacyStorage =
      legacyStorageDir != null
          ? new LegacyStorage(
              new File(legacyStorageDir, FILE_NAME_ATOMIC),
              legacyStorageSecretKey,
              legacyStorageEncrypt)
          : null;
  if (databaseStorage == null || (legacyStorage != null && preferLegacyStorage)) {
    storage = legacyStorage;
    previousStorage = databaseStorage;
  } else {
    storage = databaseStorage;
    previousStorage = legacyStorage;
  }
}
 
Example #13
Source File: CachedContentIndex.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates an instance supporting database storage only.
 *
 * @param databaseProvider Provides the database in which the index is stored.
 */
public CachedContentIndex(DatabaseProvider databaseProvider) {
  this(
      databaseProvider,
      /* legacyStorageDir= */ null,
      /* legacyStorageSecretKey= */ null,
      /* legacyStorageEncrypt= */ false,
      /* preferLegacyStorage= */ false);
}
 
Example #14
Source File: SimpleCache.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs the cache. The cache will delete any unrecognized files from the directory. Hence
 * the directory cannot be used to store other files.
 *
 * @param cacheDir A dedicated cache directory.
 * @param evictor The evictor to be used. For download use cases where cache eviction should not
 *     occur, use {@link NoOpCacheEvictor}.
 * @param databaseProvider Provides the database in which the cache index is stored.
 */
public SimpleCache(File cacheDir, CacheEvictor evictor, DatabaseProvider databaseProvider) {
  this(
      cacheDir,
      evictor,
      databaseProvider,
      /* legacyIndexSecretKey= */ null,
      /* legacyIndexEncrypt= */ false,
      /* preferLegacyIndex= */ false);
}
 
Example #15
Source File: SimpleCache.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs the cache. The cache will delete any unrecognized files from the directory. Hence
 * the directory cannot be used to store other files.
 *
 * @param cacheDir A dedicated cache directory.
 * @param evictor The evictor to be used. For download use cases where cache eviction should not
 *     occur, use {@link NoOpCacheEvictor}.
 * @param databaseProvider Provides the database in which the cache index is stored.
 */
public SimpleCache(File cacheDir, CacheEvictor evictor, DatabaseProvider databaseProvider) {
  this(
      cacheDir,
      evictor,
      databaseProvider,
      /* legacyIndexSecretKey= */ null,
      /* legacyIndexEncrypt= */ false,
      /* preferLegacyIndex= */ false);
}
 
Example #16
Source File: SimpleCache.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs the cache. The cache will delete any unrecognized files from the directory. Hence
 * the directory cannot be used to store other files.
 *
 * @param cacheDir A dedicated cache directory.
 * @param evictor The evictor to be used. For download use cases where cache eviction should not
 *     occur, use {@link NoOpCacheEvictor}.
 * @param databaseProvider Provides the database in which the cache index is stored.
 */
public SimpleCache(File cacheDir, CacheEvictor evictor, DatabaseProvider databaseProvider) {
  this(
      cacheDir,
      evictor,
      databaseProvider,
      /* legacyIndexSecretKey= */ null,
      /* legacyIndexEncrypt= */ false,
      /* preferLegacyIndex= */ false);
}
 
Example #17
Source File: CachedContentIndex.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates an instance supporting database storage only.
 *
 * @param databaseProvider Provides the database in which the index is stored.
 */
public CachedContentIndex(DatabaseProvider databaseProvider) {
  this(
      databaseProvider,
      /* legacyStorageDir= */ null,
      /* legacyStorageSecretKey= */ null,
      /* legacyStorageEncrypt= */ false,
      /* preferLegacyStorage= */ false);
}
 
Example #18
Source File: CachedContentIndex.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates an instance supporting either or both of database and legacy storage.
 *
 * @param databaseProvider Provides the database in which the index is stored, or {@code null} to
 *     use only legacy storage.
 * @param legacyStorageDir The directory in which any legacy storage is stored, or {@code null} to
 *     use only database storage.
 * @param legacyStorageSecretKey A 16 byte AES key for reading, and optionally writing, legacy
 *     storage.
 * @param legacyStorageEncrypt Whether to encrypt when writing to legacy storage. Must be false if
 *     {@code legacyStorageSecretKey} is null.
 * @param preferLegacyStorage Whether to use prefer legacy storage if both storage types are
 *     enabled. This option is only useful for downgrading from database storage back to legacy
 *     storage.
 */
public CachedContentIndex(
    @Nullable DatabaseProvider databaseProvider,
    @Nullable File legacyStorageDir,
    @Nullable byte[] legacyStorageSecretKey,
    boolean legacyStorageEncrypt,
    boolean preferLegacyStorage) {
  Assertions.checkState(databaseProvider != null || legacyStorageDir != null);
  keyToContent = new HashMap<>();
  idToKey = new SparseArray<>();
  removedIds = new SparseBooleanArray();
  newIds = new SparseBooleanArray();
  Storage databaseStorage =
      databaseProvider != null ? new DatabaseStorage(databaseProvider) : null;
  Storage legacyStorage =
      legacyStorageDir != null
          ? new LegacyStorage(
              new File(legacyStorageDir, FILE_NAME_ATOMIC),
              legacyStorageSecretKey,
              legacyStorageEncrypt)
          : null;
  if (databaseStorage == null || (legacyStorage != null && preferLegacyStorage)) {
    storage = legacyStorage;
    previousStorage = databaseStorage;
  } else {
    storage = databaseStorage;
    previousStorage = legacyStorage;
  }
}
 
Example #19
Source File: CachedContentIndex.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public static void delete(DatabaseProvider databaseProvider, long uid)
    throws DatabaseIOException {
  delete(databaseProvider, Long.toHexString(uid));
}
 
Example #20
Source File: CachedContentIndex.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public DatabaseStorage(DatabaseProvider databaseProvider) {
  this.databaseProvider = databaseProvider;
  pendingUpdates = new SparseArray<>();
}
 
Example #21
Source File: CacheFileMetadataIndex.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
/** @param databaseProvider Provides the database in which the index is stored. */
public CacheFileMetadataIndex(DatabaseProvider databaseProvider) {
  this.databaseProvider = databaseProvider;
}
 
Example #22
Source File: CacheFileMetadataIndex.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
/** @param databaseProvider Provides the database in which the index is stored. */
public CacheFileMetadataIndex(DatabaseProvider databaseProvider) {
  this.databaseProvider = databaseProvider;
}
 
Example #23
Source File: CachedContentIndex.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public static void delete(DatabaseProvider databaseProvider, long uid)
    throws DatabaseIOException {
  delete(databaseProvider, Long.toHexString(uid));
}
 
Example #24
Source File: CachedContentIndex.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public DatabaseStorage(DatabaseProvider databaseProvider) {
  this.databaseProvider = databaseProvider;
  pendingUpdates = new SparseArray<>();
}
 
Example #25
Source File: CachedContentIndex.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
public static void delete(DatabaseProvider databaseProvider, long uid)
    throws DatabaseIOException {
  delete(databaseProvider, Long.toHexString(uid));
}
 
Example #26
Source File: CachedContentIndex.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
public DatabaseStorage(DatabaseProvider databaseProvider) {
  this.databaseProvider = databaseProvider;
  pendingUpdates = new SparseArray<>();
}
 
Example #27
Source File: CacheFileMetadataIndex.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
/** @param databaseProvider Provides the database in which the index is stored. */
public CacheFileMetadataIndex(DatabaseProvider databaseProvider) {
  this.databaseProvider = databaseProvider;
}
 
Example #28
Source File: DownloadManager.java    From MediaSDK with Apache License 2.0 3 votes vote down vote up
/**
 * Constructs a {@link DownloadManager}.
 *
 * @param context Any context.
 * @param databaseProvider Provides the SQLite database in which downloads are persisted.
 * @param cache A cache to be used to store downloaded data. The cache should be configured with
 *     an {@link CacheEvictor} that will not evict downloaded content, for example {@link
 *     NoOpCacheEvictor}.
 * @param upstreamFactory A {@link Factory} for creating {@link DataSource}s for downloading data.
 */
public DownloadManager(
    Context context, DatabaseProvider databaseProvider, Cache cache, Factory upstreamFactory) {
  this(
      context,
      new DefaultDownloadIndex(databaseProvider),
      new DefaultDownloaderFactory(new DownloaderConstructorHelper(cache, upstreamFactory)));
}
 
Example #29
Source File: DownloadManager.java    From Telegram-FOSS with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Constructs a {@link DownloadManager}.
 *
 * @param context Any context.
 * @param databaseProvider Provides the SQLite database in which downloads are persisted.
 * @param cache A cache to be used to store downloaded data. The cache should be configured with
 *     an {@link CacheEvictor} that will not evict downloaded content, for example {@link
 *     NoOpCacheEvictor}.
 * @param upstreamFactory A {@link Factory} for creating {@link DataSource}s for downloading data.
 */
public DownloadManager(
    Context context, DatabaseProvider databaseProvider, Cache cache, Factory upstreamFactory) {
  this(
      context,
      new DefaultDownloadIndex(databaseProvider),
      new DefaultDownloaderFactory(new DownloaderConstructorHelper(cache, upstreamFactory)));
}
 
Example #30
Source File: DownloadManager.java    From Telegram with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Constructs a {@link DownloadManager}.
 *
 * @param context Any context.
 * @param databaseProvider Provides the SQLite database in which downloads are persisted.
 * @param cache A cache to be used to store downloaded data. The cache should be configured with
 *     an {@link CacheEvictor} that will not evict downloaded content, for example {@link
 *     NoOpCacheEvictor}.
 * @param upstreamFactory A {@link Factory} for creating {@link DataSource}s for downloading data.
 */
public DownloadManager(
    Context context, DatabaseProvider databaseProvider, Cache cache, Factory upstreamFactory) {
  this(
      context,
      new DefaultDownloadIndex(databaseProvider),
      new DefaultDownloaderFactory(new DownloaderConstructorHelper(cache, upstreamFactory)));
}