Skip to content

Commit cc34734

Browse files
committed
Refactored initNotificationChannels
1 parent 6dcde96 commit cc34734

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

  • app/src/main/java/org/schabi/newpipe

app/src/main/java/org/schabi/newpipe/App.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import java.io.IOException;
3333
import java.io.InterruptedIOException;
3434
import java.net.SocketException;
35-
import java.util.Arrays;
35+
import java.util.ArrayList;
3636
import java.util.Collections;
3737
import java.util.List;
3838

@@ -225,45 +225,44 @@ protected void initACRA() {
225225
private void initNotificationChannels() {
226226
// Keep the importance below DEFAULT to avoid making noise on every notification update for
227227
// the main and update channels
228-
final NotificationChannelCompat mainChannel = new NotificationChannelCompat
228+
final List<NotificationChannelCompat> notificationChannelCompats = new ArrayList<>();
229+
notificationChannelCompats.add(new NotificationChannelCompat
229230
.Builder(getString(R.string.notification_channel_id),
230231
NotificationManagerCompat.IMPORTANCE_LOW)
231232
.setName(getString(R.string.notification_channel_name))
232233
.setDescription(getString(R.string.notification_channel_description))
233-
.build();
234+
.build());
234235

235-
final NotificationChannelCompat appUpdateChannel = new NotificationChannelCompat
236+
notificationChannelCompats.add(new NotificationChannelCompat
236237
.Builder(getString(R.string.app_update_notification_channel_id),
237238
NotificationManagerCompat.IMPORTANCE_LOW)
238239
.setName(getString(R.string.app_update_notification_channel_name))
239240
.setDescription(getString(R.string.app_update_notification_channel_description))
240-
.build();
241+
.build());
241242

242-
final NotificationChannelCompat hashChannel = new NotificationChannelCompat
243+
notificationChannelCompats.add(new NotificationChannelCompat
243244
.Builder(getString(R.string.hash_channel_id),
244245
NotificationManagerCompat.IMPORTANCE_HIGH)
245246
.setName(getString(R.string.hash_channel_name))
246247
.setDescription(getString(R.string.hash_channel_description))
247-
.build();
248+
.build());
248249

249-
final NotificationChannelCompat errorReportChannel = new NotificationChannelCompat
250+
notificationChannelCompats.add(new NotificationChannelCompat
250251
.Builder(getString(R.string.error_report_channel_id),
251252
NotificationManagerCompat.IMPORTANCE_LOW)
252253
.setName(getString(R.string.error_report_channel_name))
253254
.setDescription(getString(R.string.error_report_channel_description))
254-
.build();
255+
.build());
255256

256-
257-
final NotificationChannelCompat newStreamsChannel = new NotificationChannelCompat
257+
notificationChannelCompats.add(new NotificationChannelCompat
258258
.Builder(getString(R.string.streams_notification_channel_id),
259259
NotificationManagerCompat.IMPORTANCE_DEFAULT)
260260
.setName(getString(R.string.streams_notification_channel_name))
261261
.setDescription(getString(R.string.streams_notification_channel_description))
262-
.build();
262+
.build());
263263

264264
final NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
265-
notificationManager.createNotificationChannelsCompat(Arrays.asList(mainChannel,
266-
appUpdateChannel, hashChannel, errorReportChannel, newStreamsChannel));
265+
notificationManager.createNotificationChannelsCompat(notificationChannelCompats);
267266
}
268267

269268
protected boolean isDisposedRxExceptionsReported() {

0 commit comments

Comments
 (0)