Move functionality from DemoApplication to DemoUtil

https://developer.android.com/reference/android/app/Application recommends
against subclassing application.

PiperOrigin-RevId: 322163812
This commit is contained in:
andrewlewis 2020-07-20 17:47:29 +01:00 committed by Oliver Woodman
parent 97cc355baf
commit 9594aa45ff
8 changed files with 123 additions and 89 deletions

View File

@ -63,6 +63,7 @@ android {
} }
dependencies { dependencies {
compileOnly 'org.checkerframework:checker-qual:' + checkerframeworkVersion
implementation 'androidx.annotation:annotation:' + androidxAnnotationVersion implementation 'androidx.annotation:annotation:' + androidxAnnotationVersion
implementation 'androidx.appcompat:appcompat:' + androidxAppCompatVersion implementation 'androidx.appcompat:appcompat:' + androidxAppCompatVersion
implementation 'androidx.multidex:multidex:' + androidxMultidexVersion implementation 'androidx.multidex:multidex:' + androidxMultidexVersion

View File

@ -35,7 +35,7 @@
android:largeHeap="true" android:largeHeap="true"
android:allowBackup="false" android:allowBackup="false"
android:requestLegacyExternalStorage="true" android:requestLegacyExternalStorage="true"
android:name="com.google.android.exoplayer2.demo.DemoApplication" android:name="androidx.multidex.MultiDexApplication"
tools:ignore="UnusedAttribute"> tools:ignore="UnusedAttribute">
<activity android:name="com.google.android.exoplayer2.demo.SampleChooserActivity" <activity android:name="com.google.android.exoplayer2.demo.SampleChooserActivity"

View File

@ -15,7 +15,7 @@
*/ */
package com.google.android.exoplayer2.demo; package com.google.android.exoplayer2.demo;
import static com.google.android.exoplayer2.demo.DemoApplication.DOWNLOAD_NOTIFICATION_CHANNEL_ID; import static com.google.android.exoplayer2.demo.DemoUtil.DOWNLOAD_NOTIFICATION_CHANNEL_ID;
import android.app.Notification; import android.app.Notification;
import android.content.Context; import android.content.Context;
@ -50,10 +50,9 @@ public class DemoDownloadService extends DownloadService {
protected DownloadManager getDownloadManager() { protected DownloadManager getDownloadManager() {
// This will only happen once, because getDownloadManager is guaranteed to be called only once // This will only happen once, because getDownloadManager is guaranteed to be called only once
// in the life cycle of the process. // in the life cycle of the process.
DemoApplication application = (DemoApplication) getApplication(); DownloadManager downloadManager = DemoUtil.getDownloadManager(/* context= */ this);
DownloadManager downloadManager = application.getDownloadManager();
DownloadNotificationHelper downloadNotificationHelper = DownloadNotificationHelper downloadNotificationHelper =
application.getDownloadNotificationHelper(); DemoUtil.getDownloadNotificationHelper(/* context= */ this);
downloadManager.addListener( downloadManager.addListener(
new TerminalStateNotificationHelper( new TerminalStateNotificationHelper(
this, downloadNotificationHelper, FOREGROUND_NOTIFICATION_ID + 1)); this, downloadNotificationHelper, FOREGROUND_NOTIFICATION_ID + 1));
@ -68,10 +67,13 @@ public class DemoDownloadService extends DownloadService {
@Override @Override
@NonNull @NonNull
protected Notification getForegroundNotification(@NonNull List<Download> downloads) { protected Notification getForegroundNotification(@NonNull List<Download> downloads) {
return ((DemoApplication) getApplication()) return DemoUtil.getDownloadNotificationHelper(/* context= */ this)
.getDownloadNotificationHelper()
.buildProgressNotification( .buildProgressNotification(
R.drawable.ic_download, /* contentIntent= */ null, /* message= */ null, downloads); /* context= */ this,
R.drawable.ic_download,
/* contentIntent= */ null,
/* message= */ null,
downloads);
} }
/** /**
@ -101,12 +103,14 @@ public class DemoDownloadService extends DownloadService {
if (download.state == Download.STATE_COMPLETED) { if (download.state == Download.STATE_COMPLETED) {
notification = notification =
notificationHelper.buildDownloadCompletedNotification( notificationHelper.buildDownloadCompletedNotification(
context,
R.drawable.ic_download_done, R.drawable.ic_download_done,
/* contentIntent= */ null, /* contentIntent= */ null,
Util.fromUtf8Bytes(download.request.data)); Util.fromUtf8Bytes(download.request.data));
} else if (download.state == Download.STATE_FAILED) { } else if (download.state == Download.STATE_FAILED) {
notification = notification =
notificationHelper.buildDownloadFailedNotification( notificationHelper.buildDownloadFailedNotification(
context,
R.drawable.ic_download_done, R.drawable.ic_download_done,
/* contentIntent= */ null, /* contentIntent= */ null,
Util.fromUtf8Bytes(download.request.data)); Util.fromUtf8Bytes(download.request.data));

View File

@ -15,7 +15,7 @@
*/ */
package com.google.android.exoplayer2.demo; package com.google.android.exoplayer2.demo;
import androidx.multidex.MultiDexApplication; import android.content.Context;
import com.google.android.exoplayer2.DefaultRenderersFactory; import com.google.android.exoplayer2.DefaultRenderersFactory;
import com.google.android.exoplayer2.RenderersFactory; import com.google.android.exoplayer2.RenderersFactory;
import com.google.android.exoplayer2.database.DatabaseProvider; import com.google.android.exoplayer2.database.DatabaseProvider;
@ -38,53 +38,34 @@ import com.google.android.exoplayer2.util.Util;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
/** /** Utility methods for the demo app. */
* Placeholder application to facilitate overriding Application methods for debugging and testing. public final class DemoUtil {
*/
public class DemoApplication extends MultiDexApplication {
public static final String DOWNLOAD_NOTIFICATION_CHANNEL_ID = "download_channel"; public static final String DOWNLOAD_NOTIFICATION_CHANNEL_ID = "download_channel";
private static final String TAG = "DemoApplication"; private static final String TAG = "DemoUtil";
private static final String DOWNLOAD_ACTION_FILE = "actions"; private static final String DOWNLOAD_ACTION_FILE = "actions";
private static final String DOWNLOAD_TRACKER_ACTION_FILE = "tracked_actions"; private static final String DOWNLOAD_TRACKER_ACTION_FILE = "tracked_actions";
private static final String DOWNLOAD_CONTENT_DIRECTORY = "downloads"; private static final String DOWNLOAD_CONTENT_DIRECTORY = "downloads";
private HttpDataSource.Factory httpDataSourceFactory; private static DataSource.@MonotonicNonNull Factory dataSourceFactory;
private DatabaseProvider databaseProvider; private static HttpDataSource.@MonotonicNonNull Factory httpDataSourceFactory;
private File downloadDirectory; private static @MonotonicNonNull DatabaseProvider databaseProvider;
private Cache downloadCache; private static @MonotonicNonNull File downloadDirectory;
private DownloadManager downloadManager; private static @MonotonicNonNull Cache downloadCache;
private DownloadTracker downloadTracker; private static @MonotonicNonNull DownloadManager downloadManager;
private DownloadNotificationHelper downloadNotificationHelper; private static @MonotonicNonNull DownloadTracker downloadTracker;
private static @MonotonicNonNull DownloadNotificationHelper downloadNotificationHelper;
@Override
public void onCreate() {
super.onCreate();
CronetEngineWrapper cronetEngineWrapper = new CronetEngineWrapper(/* context= */ this);
String userAgent = Util.getUserAgent(this, "ExoPlayerDemo");
httpDataSourceFactory =
new CronetDataSourceFactory(
cronetEngineWrapper,
Executors.newSingleThreadExecutor(),
/* transferListener= */ null,
userAgent);
}
/** Returns a {@link DataSource.Factory}. */
public DataSource.Factory buildDataSourceFactory() {
DefaultDataSourceFactory upstreamFactory =
new DefaultDataSourceFactory(/* context= */ this, httpDataSourceFactory);
return buildReadOnlyCacheDataSource(upstreamFactory, getDownloadCache());
}
/** Returns whether extension renderers should be used. */ /** Returns whether extension renderers should be used. */
public boolean useExtensionRenderers() { public static boolean useExtensionRenderers() {
return "withDecoderExtensions".equals(BuildConfig.FLAVOR); return "withDecoderExtensions".equals(BuildConfig.FLAVOR);
} }
public RenderersFactory buildRenderersFactory(boolean preferExtensionRenderer) { public static RenderersFactory buildRenderersFactory(
Context context, boolean preferExtensionRenderer) {
@DefaultRenderersFactory.ExtensionRendererMode @DefaultRenderersFactory.ExtensionRendererMode
int extensionRendererMode = int extensionRendererMode =
useExtensionRenderers() useExtensionRenderers()
@ -92,61 +73,96 @@ public class DemoApplication extends MultiDexApplication {
? DefaultRenderersFactory.EXTENSION_RENDERER_MODE_PREFER ? DefaultRenderersFactory.EXTENSION_RENDERER_MODE_PREFER
: DefaultRenderersFactory.EXTENSION_RENDERER_MODE_ON) : DefaultRenderersFactory.EXTENSION_RENDERER_MODE_ON)
: DefaultRenderersFactory.EXTENSION_RENDERER_MODE_OFF; : DefaultRenderersFactory.EXTENSION_RENDERER_MODE_OFF;
return new DefaultRenderersFactory(/* context= */ this) return new DefaultRenderersFactory(context.getApplicationContext())
.setExtensionRendererMode(extensionRendererMode); .setExtensionRendererMode(extensionRendererMode);
} }
public DownloadNotificationHelper getDownloadNotificationHelper() { public static synchronized HttpDataSource.Factory getHttpDataSourceFactory(Context context) {
if (httpDataSourceFactory == null) {
context = context.getApplicationContext();
CronetEngineWrapper cronetEngineWrapper = new CronetEngineWrapper(context);
String userAgent = Util.getUserAgent(context, "ExoPlayerDemo");
httpDataSourceFactory =
new CronetDataSourceFactory(
cronetEngineWrapper,
Executors.newSingleThreadExecutor(),
/* transferListener= */ null,
userAgent);
}
return httpDataSourceFactory;
}
/** Returns a {@link DataSource.Factory}. */
public static synchronized DataSource.Factory buildDataSourceFactory(Context context) {
if (dataSourceFactory == null) {
context = context.getApplicationContext();
DefaultDataSourceFactory upstreamFactory =
new DefaultDataSourceFactory(context, getHttpDataSourceFactory(context));
dataSourceFactory = buildReadOnlyCacheDataSource(upstreamFactory, getDownloadCache(context));
}
return dataSourceFactory;
}
public static synchronized DownloadNotificationHelper getDownloadNotificationHelper(
Context context) {
if (downloadNotificationHelper == null) { if (downloadNotificationHelper == null) {
downloadNotificationHelper = downloadNotificationHelper =
new DownloadNotificationHelper(this, DOWNLOAD_NOTIFICATION_CHANNEL_ID); new DownloadNotificationHelper(context, DOWNLOAD_NOTIFICATION_CHANNEL_ID);
} }
return downloadNotificationHelper; return downloadNotificationHelper;
} }
public DownloadManager getDownloadManager() { public static synchronized DownloadManager getDownloadManager(Context context) {
initDownloadManager(); ensureDownloadManagerInitialized(context);
return downloadManager; return downloadManager;
} }
public DownloadTracker getDownloadTracker() { public static synchronized DownloadTracker getDownloadTracker(Context context) {
initDownloadManager(); ensureDownloadManagerInitialized(context);
return downloadTracker; return downloadTracker;
} }
private synchronized Cache getDownloadCache() { private static synchronized Cache getDownloadCache(Context context) {
if (downloadCache == null) { if (downloadCache == null) {
File downloadContentDirectory = new File(getDownloadDirectory(), DOWNLOAD_CONTENT_DIRECTORY); File downloadContentDirectory =
new File(getDownloadDirectory(context), DOWNLOAD_CONTENT_DIRECTORY);
downloadCache = downloadCache =
new SimpleCache(downloadContentDirectory, new NoOpCacheEvictor(), getDatabaseProvider()); new SimpleCache(
downloadContentDirectory, new NoOpCacheEvictor(), getDatabaseProvider(context));
} }
return downloadCache; return downloadCache;
} }
private synchronized void initDownloadManager() { private static synchronized void ensureDownloadManagerInitialized(Context context) {
if (downloadManager == null) { if (downloadManager == null) {
DefaultDownloadIndex downloadIndex = new DefaultDownloadIndex(getDatabaseProvider()); DefaultDownloadIndex downloadIndex = new DefaultDownloadIndex(getDatabaseProvider(context));
upgradeActionFile( upgradeActionFile(
DOWNLOAD_ACTION_FILE, downloadIndex, /* addNewDownloadsAsCompleted= */ false); context, DOWNLOAD_ACTION_FILE, downloadIndex, /* addNewDownloadsAsCompleted= */ false);
upgradeActionFile( upgradeActionFile(
DOWNLOAD_TRACKER_ACTION_FILE, downloadIndex, /* addNewDownloadsAsCompleted= */ true); context,
DOWNLOAD_TRACKER_ACTION_FILE,
downloadIndex,
/* addNewDownloadsAsCompleted= */ true);
downloadManager = downloadManager =
new DownloadManager( new DownloadManager(
/* context= */ this, context,
getDatabaseProvider(), getDatabaseProvider(context),
getDownloadCache(), getDownloadCache(context),
httpDataSourceFactory, getHttpDataSourceFactory(context),
Executors.newFixedThreadPool(/* nThreads= */ 6)); Executors.newFixedThreadPool(/* nThreads= */ 6));
downloadTracker = downloadTracker =
new DownloadTracker(/* context= */ this, buildDataSourceFactory(), downloadManager); new DownloadTracker(context, buildDataSourceFactory(context), downloadManager);
} }
} }
private void upgradeActionFile( private static synchronized void upgradeActionFile(
String fileName, DefaultDownloadIndex downloadIndex, boolean addNewDownloadsAsCompleted) { Context context,
String fileName,
DefaultDownloadIndex downloadIndex,
boolean addNewDownloadsAsCompleted) {
try { try {
ActionFileUpgradeUtil.upgradeAndDelete( ActionFileUpgradeUtil.upgradeAndDelete(
new File(getDownloadDirectory(), fileName), new File(getDownloadDirectory(context), fileName),
/* downloadIdProvider= */ null, /* downloadIdProvider= */ null,
downloadIndex, downloadIndex,
/* deleteOnFailure= */ true, /* deleteOnFailure= */ true,
@ -156,18 +172,18 @@ public class DemoApplication extends MultiDexApplication {
} }
} }
private DatabaseProvider getDatabaseProvider() { private static synchronized DatabaseProvider getDatabaseProvider(Context context) {
if (databaseProvider == null) { if (databaseProvider == null) {
databaseProvider = new ExoDatabaseProvider(this); databaseProvider = new ExoDatabaseProvider(context);
} }
return databaseProvider; return databaseProvider;
} }
private File getDownloadDirectory() { private static synchronized File getDownloadDirectory(Context context) {
if (downloadDirectory == null) { if (downloadDirectory == null) {
downloadDirectory = getExternalFilesDir(null); downloadDirectory = context.getExternalFilesDir(/* type= */ null);
if (downloadDirectory == null) { if (downloadDirectory == null) {
downloadDirectory = getFilesDir(); downloadDirectory = context.getFilesDir();
} }
} }
return downloadDirectory; return downloadDirectory;
@ -181,4 +197,6 @@ public class DemoApplication extends MultiDexApplication {
.setCacheWriteDataSinkFactory(null) .setCacheWriteDataSinkFactory(null)
.setFlags(CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR); .setFlags(CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR);
} }
private DemoUtil() {}
} }

View File

@ -315,7 +315,7 @@ public class PlayerActivity extends AppCompatActivity
boolean preferExtensionDecoders = boolean preferExtensionDecoders =
intent.getBooleanExtra(IntentUtil.PREFER_EXTENSION_DECODERS_EXTRA, false); intent.getBooleanExtra(IntentUtil.PREFER_EXTENSION_DECODERS_EXTRA, false);
RenderersFactory renderersFactory = RenderersFactory renderersFactory =
((DemoApplication) getApplication()).buildRenderersFactory(preferExtensionDecoders); DemoUtil.buildRenderersFactory(/* context= */ this, preferExtensionDecoders);
trackSelector = new DefaultTrackSelector(/* context= */ this, trackSelectionFactory); trackSelector = new DefaultTrackSelector(/* context= */ this, trackSelectionFactory);
trackSelector.setParameters(trackSelectorParameters); trackSelector.setParameters(trackSelectorParameters);
@ -357,7 +357,7 @@ public class PlayerActivity extends AppCompatActivity
List<MediaItem> mediaItems = List<MediaItem> mediaItems =
IntentUtil.createMediaItemsFromIntent( IntentUtil.createMediaItemsFromIntent(
intent, ((DemoApplication) getApplication()).getDownloadTracker()); intent, DemoUtil.getDownloadTracker(/* context= */ this));
boolean hasAds = false; boolean hasAds = false;
for (int i = 0; i < mediaItems.size(); i++) { for (int i = 0; i < mediaItems.size(); i++) {
MediaItem mediaItem = mediaItems.get(i); MediaItem mediaItem = mediaItems.get(i);
@ -439,7 +439,7 @@ public class PlayerActivity extends AppCompatActivity
/** Returns a new DataSource factory. */ /** Returns a new DataSource factory. */
protected DataSource.Factory buildDataSourceFactory() { protected DataSource.Factory buildDataSourceFactory() {
return ((DemoApplication) getApplication()).buildDataSourceFactory(); return DemoUtil.buildDataSourceFactory(/* context= */ this);
} }
// User controls // User controls

View File

@ -114,9 +114,8 @@ public class SampleChooserActivity extends AppCompatActivity
Arrays.sort(uris); Arrays.sort(uris);
} }
DemoApplication application = (DemoApplication) getApplication(); useExtensionRenderers = DemoUtil.useExtensionRenderers();
useExtensionRenderers = application.useExtensionRenderers(); downloadTracker = DemoUtil.getDownloadTracker(/* context= */ this);
downloadTracker = application.getDownloadTracker();
loadSample(); loadSample();
// Start the download service if it should be running but it's not currently. // Start the download service if it should be running but it's not currently.
@ -247,8 +246,8 @@ public class SampleChooserActivity extends AppCompatActivity
.show(); .show();
} else { } else {
RenderersFactory renderersFactory = RenderersFactory renderersFactory =
((DemoApplication) getApplication()) DemoUtil.buildRenderersFactory(
.buildRenderersFactory(isNonNullAndChecked(preferExtensionDecodersMenuItem)); /* context= */ this, isNonNullAndChecked(preferExtensionDecodersMenuItem));
downloadTracker.toggleDownload( downloadTracker.toggleDownload(
getSupportFragmentManager(), playlistHolder.mediaItems.get(0), renderersFactory); getSupportFragmentManager(), playlistHolder.mediaItems.get(0), renderersFactory);
} }

View File

@ -31,7 +31,6 @@ public final class DownloadNotificationHelper {
private static final @StringRes int NULL_STRING_ID = 0; private static final @StringRes int NULL_STRING_ID = 0;
private final Context context;
private final NotificationCompat.Builder notificationBuilder; private final NotificationCompat.Builder notificationBuilder;
/** /**
@ -39,14 +38,14 @@ public final class DownloadNotificationHelper {
* @param channelId The id of the notification channel to use. * @param channelId The id of the notification channel to use.
*/ */
public DownloadNotificationHelper(Context context, String channelId) { public DownloadNotificationHelper(Context context, String channelId) {
context = context.getApplicationContext(); this.notificationBuilder =
this.context = context; new NotificationCompat.Builder(context.getApplicationContext(), channelId);
this.notificationBuilder = new NotificationCompat.Builder(context, channelId);
} }
/** /**
* Returns a progress notification for the given downloads. * Returns a progress notification for the given downloads.
* *
* @param context A context.
* @param smallIcon A small icon for the notification. * @param smallIcon A small icon for the notification.
* @param contentIntent An optional content intent to send when the notification is clicked. * @param contentIntent An optional content intent to send when the notification is clicked.
* @param message An optional message to display on the notification. * @param message An optional message to display on the notification.
@ -54,6 +53,7 @@ public final class DownloadNotificationHelper {
* @return The notification. * @return The notification.
*/ */
public Notification buildProgressNotification( public Notification buildProgressNotification(
Context context,
@DrawableRes int smallIcon, @DrawableRes int smallIcon,
@Nullable PendingIntent contentIntent, @Nullable PendingIntent contentIntent,
@Nullable String message, @Nullable String message,
@ -95,6 +95,7 @@ public final class DownloadNotificationHelper {
indeterminate = allDownloadPercentagesUnknown && haveDownloadedBytes; indeterminate = allDownloadPercentagesUnknown && haveDownloadedBytes;
} }
return buildNotification( return buildNotification(
context,
smallIcon, smallIcon,
contentIntent, contentIntent,
message, message,
@ -109,37 +110,47 @@ public final class DownloadNotificationHelper {
/** /**
* Returns a notification for a completed download. * Returns a notification for a completed download.
* *
* @param context A context.
* @param smallIcon A small icon for the notifications. * @param smallIcon A small icon for the notifications.
* @param contentIntent An optional content intent to send when the notification is clicked. * @param contentIntent An optional content intent to send when the notification is clicked.
* @param message An optional message to display on the notification. * @param message An optional message to display on the notification.
* @return The notification. * @return The notification.
*/ */
public Notification buildDownloadCompletedNotification( public Notification buildDownloadCompletedNotification(
@DrawableRes int smallIcon, @Nullable PendingIntent contentIntent, @Nullable String message) { Context context,
@DrawableRes int smallIcon,
@Nullable PendingIntent contentIntent,
@Nullable String message) {
int titleStringId = R.string.exo_download_completed; int titleStringId = R.string.exo_download_completed;
return buildEndStateNotification(smallIcon, contentIntent, message, titleStringId); return buildEndStateNotification(context, smallIcon, contentIntent, message, titleStringId);
} }
/** /**
* Returns a notification for a failed download. * Returns a notification for a failed download.
* *
* @param context A context.
* @param smallIcon A small icon for the notifications. * @param smallIcon A small icon for the notifications.
* @param contentIntent An optional content intent to send when the notification is clicked. * @param contentIntent An optional content intent to send when the notification is clicked.
* @param message An optional message to display on the notification. * @param message An optional message to display on the notification.
* @return The notification. * @return The notification.
*/ */
public Notification buildDownloadFailedNotification( public Notification buildDownloadFailedNotification(
@DrawableRes int smallIcon, @Nullable PendingIntent contentIntent, @Nullable String message) { Context context,
@DrawableRes int smallIcon,
@Nullable PendingIntent contentIntent,
@Nullable String message) {
@StringRes int titleStringId = R.string.exo_download_failed; @StringRes int titleStringId = R.string.exo_download_failed;
return buildEndStateNotification(smallIcon, contentIntent, message, titleStringId); return buildEndStateNotification(context, smallIcon, contentIntent, message, titleStringId);
} }
private Notification buildEndStateNotification( private Notification buildEndStateNotification(
Context context,
@DrawableRes int smallIcon, @DrawableRes int smallIcon,
@Nullable PendingIntent contentIntent, @Nullable PendingIntent contentIntent,
@Nullable String message, @Nullable String message,
@StringRes int titleStringId) { @StringRes int titleStringId) {
return buildNotification( return buildNotification(
context,
smallIcon, smallIcon,
contentIntent, contentIntent,
message, message,
@ -152,6 +163,7 @@ public final class DownloadNotificationHelper {
} }
private Notification buildNotification( private Notification buildNotification(
Context context,
@DrawableRes int smallIcon, @DrawableRes int smallIcon,
@Nullable PendingIntent contentIntent, @Nullable PendingIntent contentIntent,
@Nullable String message, @Nullable String message,

View File

@ -52,7 +52,7 @@ public final class DownloadNotificationUtil {
@Nullable String message, @Nullable String message,
List<Download> downloads) { List<Download> downloads) {
return new DownloadNotificationHelper(context, channelId) return new DownloadNotificationHelper(context, channelId)
.buildProgressNotification(smallIcon, contentIntent, message, downloads); .buildProgressNotification(context, smallIcon, contentIntent, message, downloads);
} }
/** /**
@ -72,7 +72,7 @@ public final class DownloadNotificationUtil {
@Nullable PendingIntent contentIntent, @Nullable PendingIntent contentIntent,
@Nullable String message) { @Nullable String message) {
return new DownloadNotificationHelper(context, channelId) return new DownloadNotificationHelper(context, channelId)
.buildDownloadCompletedNotification(smallIcon, contentIntent, message); .buildDownloadCompletedNotification(context, smallIcon, contentIntent, message);
} }
/** /**
@ -92,6 +92,6 @@ public final class DownloadNotificationUtil {
@Nullable PendingIntent contentIntent, @Nullable PendingIntent contentIntent,
@Nullable String message) { @Nullable String message) {
return new DownloadNotificationHelper(context, channelId) return new DownloadNotificationHelper(context, channelId)
.buildDownloadFailedNotification(smallIcon, contentIntent, message); .buildDownloadFailedNotification(context, smallIcon, contentIntent, message);
} }
} }