Ejemplo n.º 1
0
        public static NotificationBuilder FromInstance(NotificationInstance notif)
        {
            NotificationBuilder builder = new NotificationBuilder(notif.id, notif.title, notif.body);

            if (notif.smallIcon != null)
            {
                builder.setSmallIcon(notif.smallIcon.name);
            }
            if (notif.largeIcon != null)
            {
                builder.setLargeIcon(notif.largeIcon.name);
            }
            if ((notif.ticker != null) && (notif.ticker.Length > 0))
            {
                builder.setTicker(notif.ticker);
            }
            int defaultFlags = 0;

            if (notif.defaultSound)
            {
                defaultFlags |= 1;
            }
            else if (notif.soundFile != null)
            {
                builder.setSound(notif.soundFile.name);
            }
            if (notif.defaultVibrate)
            {
                defaultFlags |= 2;
            }
            else if (notif.vibroPattern != null)
            {
                long[] pattern = notif.vibroPattern.ToArray();
                builder.setVibrate(pattern);
            }
            if (defaultFlags > 0)
            {
                builder.setDefaults(defaultFlags);
            }
            if (notif.number > 0)
            {
                builder.setNumber(notif.number);
            }
            if ((notif.group != null) && (notif.group.Length > 0))
            {
                builder.setGroup(notif.group);
            }
            if ((notif.sortKey != null) && (notif.sortKey.Length > 0))
            {
                builder.setSortKey(notif.sortKey);
            }
            if (notif.hasColor)
            {
                builder.setColor("#" + ColorUtils.ToHtmlStringRGB(notif.color));
            }
            builder.setGroupId(notif.groupId);
            builder.setAutoCancel(notif.autoCancel);
            builder.setAlertOnlyOnce(notif.alertOnce);
            if (notif.isRepeating)
            {
                builder.setRepeating(true);
                long num2     = ((notif.intervalHours * 0xe10) + (notif.intervalMinutes * 60)) + notif.intervalSeconds;
                long interval = num2 * 0x3e8L;
                builder.setInterval(interval);
            }
            long num4 = ((notif.delayHours * 0xe10) + (notif.delayMinutes * 60)) + notif.delaySeconds;
            long delayMilliseconds = num4 * 0x3e8L;

            builder.setDelay(delayMilliseconds);
            return(builder);
        }