Skip to content

Commit 508e654

Browse files
Merge branch 'NotificationHelper'
2 parents 34a7061 + 3cf64b5 commit 508e654

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

helpers/src/main/java/ezhard/studio/helpers/NotificationHelper.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,35 @@ private void createNotificationChannel(String channelId, String channelName, Str
6363
}
6464
}
6565
}
66+
public enum NotificationPriority{
67+
DEFAULT(NotificationCompat.PRIORITY_DEFAULT),
68+
MIN(NotificationCompat.PRIORITY_MIN),
69+
LOW(NotificationCompat.PRIORITY_LOW),
70+
HIGH(NotificationCompat.PRIORITY_HIGH),
71+
MAX(NotificationCompat.PRIORITY_MAX);
6672

73+
private int priority;
74+
NotificationPriority(int priority) {
75+
this.priority = priority;
76+
}
77+
78+
public int getPriority() {
79+
return priority;
80+
}
81+
}
6782
/**
6883
* Displays a notification.
69-
*
84+
*
7085
* @param icon The icon resource ID of the notification.
7186
* @param text The text content of the notification.
7287
* @param notificationId The ID of the notification.
88+
* @param priority The priority of the notification.
7389
*/
74-
public void showNotification(int icon, String text, int notificationId) {
90+
public void showNotification(int icon, String text, int notificationId, NotificationPriority priority) {
7591
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, channelId)
7692
.setSmallIcon(icon)
7793
.setContentText(text)
78-
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
94+
.setPriority(priority.getPriority())
7995
.setAutoCancel(true);
8096

8197
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);

0 commit comments

Comments
 (0)