Skip to content

Commit 0da437f

Browse files
committed
Better signature and more optimal return
1 parent 6f82494 commit 0da437f

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

com.unity.mobile.notifications/Runtime/Android/Plugins/com/unity/androidnotifications/UnityNotificationManager.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -281,18 +281,16 @@ public void deleteNotificationChannel(String id) {
281281
}
282282
}
283283

284-
// Get all notification channels.
285-
// This function will only be called for devices which are low than Android O.
286-
public Object[] getNotificationChannels() {
284+
public NotificationChannelWrapper[] getNotificationChannels() {
287285
SharedPreferences prefs = mContext.getSharedPreferences(NOTIFICATION_CHANNELS_SHARED_PREFS, Context.MODE_PRIVATE);
288-
Set<String> channelIdsSet = prefs.getStringSet(NOTIFICATION_CHANNELS_SHARED_PREFS_KEY, new HashSet<String>());
289-
290-
ArrayList<NotificationChannelWrapper> channels = new ArrayList<>();
286+
Set<String> channelIdsSet = prefs.getStringSet(NOTIFICATION_CHANNELS_SHARED_PREFS_KEY, new HashSet());
291287

288+
NotificationChannelWrapper[] channels = new NotificationChannelWrapper[channelIdsSet.size()];
289+
int i = 0;
292290
for (String k : channelIdsSet) {
293-
channels.add(getNotificationChannel(k));
291+
channels[i++] = getNotificationChannel(k);
294292
}
295-
return channels.toArray();
293+
return channels;
296294
}
297295

298296
// This is called from Unity managed code to call AlarmManager to set a broadcast intent for sending a notification.

0 commit comments

Comments
 (0)