private ArrayList getData() { Java.Util.Random r = new Java.Util.Random(); ArrayList result = new ArrayList(); for (int i = 0; i < 8; i++) { DataEntity entity = new DataEntity(); entity.value = r.NextInt(10) + 1; result.Add(entity); } return result; }
private ArrayList getData(){ Java.Util.Random numberGenerator = new Java.Util.Random(); ArrayList result = new ArrayList(8); for (int i = 0; i < 8; i++){ DataEntity entity = new DataEntity(); entity.value = numberGenerator.NextInt(10) + 1; entity.category = "Item " + i; result.Add(entity); } return result; }
private ArrayList getData(){ Java.Util.Random numberGenerator = new Java.Util.Random(); ArrayList result = new ArrayList(8); for (int i = 0; i < 20; i++){ ScatterDataEntity entity = new ScatterDataEntity(); entity.value1 = numberGenerator.NextDouble() * 10; entity.value2 = numberGenerator.NextDouble() * 10; result.Add(entity); } return result; }
private ArrayList getData() { Java.Util.Random numberGenerator = new Java.Util.Random(); ArrayList result = new ArrayList(8); for (int i = 0; i < 8; i++) { DataEntity entity = new DataEntity(); entity.value = numberGenerator.NextInt(10) + 1; entity.category = "Item " + i; result.Add(entity); } return(result); }
private ArrayList getData() { Java.Util.Random r = new Java.Util.Random(); ArrayList result = new ArrayList(); for (int i = 0; i < 8; i++) { DataEntity entity = new DataEntity(); entity.value = r.NextInt(10) + 1; result.Add(entity); } return(result); }
private ArrayList getData() { Java.Util.Random numberGenerator = new Java.Util.Random(); ArrayList result = new ArrayList(8); for (int i = 0; i < 20; i++) { ScatterDataEntity entity = new ScatterDataEntity(); entity.value1 = numberGenerator.NextDouble() * 10; entity.value2 = numberGenerator.NextDouble() * 10; result.Add(entity); } return(result); }
private ArrayList getData(){ Java.Util.Random numberGenerator = new Java.Util.Random(); ArrayList result = new ArrayList(8); int startingMonth =0; for (int i = 0; i < 8; i++){ DataEntity entity = new DataEntity(); entity.value = numberGenerator.NextInt(10) + 1; Calendar date = Calendar.Instance; date.Set(CalendarField.Month, startingMonth++); entity.date = date; if (i == 2 || i == 6){ continue; } result.Add(entity); } return result; }
private ArrayList getData() { Java.Util.Random numberGenerator = new Java.Util.Random(); ArrayList result = new ArrayList(8); int startingMonth = 0; for (int i = 0; i < 8; i++) { DataEntity entity = new DataEntity(); entity.value = numberGenerator.NextInt(10) + 1; Calendar date = Calendar.Instance; date.Set(Calendar.Month, startingMonth++); entity.date = date; if (i == 2 || i == 6) { continue; } result.Add(entity); } return(result); }
private ArrayList getData() { ArrayList data = new ArrayList(); int size = 10; Java.Util.Random r = new Java.Util.Random(); for (int i = 1; i <= size; ++i) { OhlcData ohlc = new OhlcData(); ohlc.category = i.ToString(); ohlc.high = r.NextInt(100); if (ohlc.high < 2) { ohlc.high = 2; } ohlc.low = r.NextInt(ohlc.high - 1); ohlc.open = ohlc.low + r.NextInt(ohlc.high - ohlc.low); ohlc.close = ohlc.low + r.NextInt(ohlc.high - ohlc.low); data.Add(ohlc); } return data; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); var toolbar = FindViewById<Toolbar>(Resource.Id.toolbar1); //Toolbar will now take on default Action Bar characteristics SetActionBar(toolbar); //You can now use and reference the ActionBar ActionBar.Title = "Bayes' Wizard"; _assumeTextView = FindViewById<TextView>(Resource.Id.theAssumption); _assumeTextView.SetBackgroundResource(Resource.Drawable.bubbleright); string[] theEvent = Resources.GetStringArray(Resource.Array.theEvent); string[] theTest = Resources.GetStringArray(Resource.Array.theTest); Java.Util.Random rand = new Java.Util.Random(); int x = rand.NextInt(theEvent.Length); _event = theEvent[x]; _test = theTest[x]; _assumption = Resources.GetString(Resource.String.Iassume) + " [" + _event + "]" + Resources.GetString(Resource.String.because) + " [" + _test + "]."; _editor = FindViewById<EditText>(Resource.Id.editText1); _editor.KeyPress += _editor_KeyPress; _editor.TextChanged += UpdateText; Button askButton = FindViewById<Button>(Resource.Id.askBayes); askButton.Click += AskButton_Click; Button contButton1 = FindViewById<Button>(Resource.Id.cont1); contButton1.Click += ContButton1_Click; _probSeek = FindViewById<SeekBar>(Resource.Id.seek1); _probSeek.ProgressChanged += SeekProb_ProgressChanged; _probEdit = FindViewById<EditText>(Resource.Id.prob1); _probEdit.KeyPress += EditProb_KeyPress; Refresh(); }
public virtual void OnReceived(IDictionary <string, object> parameters) { System.Diagnostics.Debug.WriteLine($"{DomainTag} - OnReceived"); if ((parameters.TryGetValue(SilentKey, out var silent) && (silent.ToString() == "true" || silent.ToString() == "1")) || (IsInForeground() && (!(!parameters.ContainsKey(ChannelIdKey) && parameters.TryGetValue(PriorityKey, out var imp) && ($"{imp}" == "high" || $"{imp}" == "max")) || (!parameters.ContainsKey(PriorityKey) && !parameters.ContainsKey(ChannelIdKey) && PushNotificationManager.DefaultNotificationChannelImportance != NotificationImportance.High && PushNotificationManager.DefaultNotificationChannelImportance != NotificationImportance.Max)))) { return; } Context context = Application.Context; var notifyId = 0; var title = context.ApplicationInfo.LoadLabel(context.PackageManager); var message = string.Empty; var tag = string.Empty; var notificationNumber = 0; var showWhenVisible = PushNotificationManager.ShouldShowWhen; var soundUri = PushNotificationManager.SoundUri; var largeIconResource = PushNotificationManager.LargeIconResource; var smallIconResource = PushNotificationManager.IconResource; var notificationColor = PushNotificationManager.Color; var chanId = PushNotificationManager.DefaultNotificationChannelId; if (!string.IsNullOrEmpty(PushNotificationManager.NotificationContentTextKey) && parameters.TryGetValue(PushNotificationManager.NotificationContentTextKey, out var notificationContentText)) { message = notificationContentText.ToString(); } else if (parameters.TryGetValue(AlertKey, out var alert)) { message = $"{alert}"; } else if (parameters.TryGetValue(BodyKey, out var body)) { message = $"{body}"; } else if (parameters.TryGetValue(MessageKey, out var messageContent)) { message = $"{messageContent}"; } else if (parameters.TryGetValue(SubtitleKey, out var subtitle)) { message = $"{subtitle}"; } else if (parameters.TryGetValue(TextKey, out var text)) { message = $"{text}"; } if (!string.IsNullOrEmpty(PushNotificationManager.NotificationContentTitleKey) && parameters.TryGetValue(PushNotificationManager.NotificationContentTitleKey, out var notificationContentTitle)) { title = notificationContentTitle.ToString(); } else if (parameters.TryGetValue(TitleKey, out var titleContent)) { if (!string.IsNullOrEmpty(message)) { title = $"{titleContent}"; } else { message = $"{titleContent}"; } } if (parameters.TryGetValue(IdKey, out var id)) { try { notifyId = Convert.ToInt32(id); } catch (Exception ex) { // Keep the default value of zero for the notify_id, but log the conversion problem. System.Diagnostics.Debug.WriteLine($"Failed to convert {id} to an integer {ex}"); } } if (parameters.TryGetValue(NumberKey, out var num)) { try { notificationNumber = Convert.ToInt32(num); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine($"Failed to convert {num} to an integer {ex}"); } } if (parameters.TryGetValue(ShowWhenKey, out var shouldShowWhen)) { showWhenVisible = $"{shouldShowWhen}".ToLower() == "true"; } if (parameters.TryGetValue(TagKey, out var tagContent)) { tag = tagContent.ToString(); } try { if (parameters.TryGetValue(SoundKey, out var sound)) { var soundName = sound.ToString(); var soundResId = context.Resources.GetIdentifier(soundName, "raw", context.PackageName); if (soundResId == 0 && soundName.IndexOf('.') != -1) { soundName = soundName.Substring(0, soundName.LastIndexOf('.')); soundResId = context.Resources.GetIdentifier(soundName, "raw", context.PackageName); } soundUri = new Android.Net.Uri.Builder() .Scheme(ContentResolver.SchemeAndroidResource) .Path($"{context.PackageName}/{soundResId}") .Build(); } } catch (Resources.NotFoundException ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } if (soundUri == null) { soundUri = RingtoneManager.GetDefaultUri(RingtoneType.Notification); } try { if (parameters.TryGetValue(IconKey, out var icon) && icon != null) { try { smallIconResource = context.Resources.GetIdentifier(icon.ToString(), "drawable", Application.Context.PackageName); if (smallIconResource == 0) { smallIconResource = context.Resources.GetIdentifier($"{icon}", "mipmap", Application.Context.PackageName); } } catch (Resources.NotFoundException ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } if (smallIconResource == 0) { smallIconResource = context.ApplicationInfo.Icon; } else { var name = context.Resources.GetResourceName(smallIconResource); if (name == null) { smallIconResource = context.ApplicationInfo.Icon; } } } catch (Resources.NotFoundException ex) { smallIconResource = context.ApplicationInfo.Icon; System.Diagnostics.Debug.WriteLine(ex.ToString()); } try { if (parameters.TryGetValue(LargeIconKey, out object largeIcon) && largeIcon != null) { largeIconResource = context.Resources.GetIdentifier($"{largeIcon}", "drawable", Application.Context.PackageName); if (largeIconResource == 0) { largeIconResource = context.Resources.GetIdentifier($"{largeIcon}", "mipmap", Application.Context.PackageName); } } if (largeIconResource > 0) { string name = context.Resources.GetResourceName(largeIconResource); if (name == null) { largeIconResource = 0; } } } catch (Resources.NotFoundException ex) { largeIconResource = 0; System.Diagnostics.Debug.WriteLine(ex.ToString()); } if (parameters.TryGetValue(ColorKey, out var color) && color != null) { try { notificationColor = Color.ParseColor(color.ToString()); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine($"{DomainTag} - Failed to parse color {ex}"); } } Intent resultIntent = typeof(Activity).IsAssignableFrom(PushNotificationManager.NotificationActivityType) ? new Intent(Application.Context, PushNotificationManager.NotificationActivityType) : (PushNotificationManager.DefaultNotificationActivityType == null ? context.PackageManager.GetLaunchIntentForPackage(context.PackageName) : new Intent(Application.Context, PushNotificationManager.DefaultNotificationActivityType)); var extras = new Bundle(); foreach (var p in parameters) { extras.PutString(p.Key, p.Value.ToString()); } if (extras != null) { extras.PutInt(ActionNotificationIdKey, notifyId); extras.PutString(ActionNotificationTagKey, tag); resultIntent.PutExtras(extras); } if (PushNotificationManager.NotificationActivityFlags != null) { resultIntent.SetFlags(PushNotificationManager.NotificationActivityFlags.Value); } var requestCode = new Java.Util.Random().NextInt(); var pendingIntent = PendingIntent.GetActivity(context, requestCode, resultIntent, PendingIntentFlags.UpdateCurrent); if (parameters.TryGetValue(ChannelIdKey, out var channelId) && channelId != null) { chanId = $"{channelId}"; } var notificationBuilder = new NotificationCompat.Builder(context, chanId) .SetSmallIcon(smallIconResource) .SetContentTitle(title) .SetContentText(message) .SetAutoCancel(true) .SetWhen(Java.Lang.JavaSystem.CurrentTimeMillis()) .SetContentIntent(pendingIntent); if (notificationNumber > 0) { notificationBuilder.SetNumber(notificationNumber); } if (Build.VERSION.SdkInt >= BuildVersionCodes.JellyBeanMr1) { notificationBuilder.SetShowWhen(showWhenVisible); } if (largeIconResource > 0) { Bitmap largeIconBitmap = BitmapFactory.DecodeResource(context.Resources, largeIconResource); notificationBuilder.SetLargeIcon(largeIconBitmap); } if (parameters.TryGetValue(FullScreenIntentKey, out var fullScreenIntent) && ($"{fullScreenIntent}" == "true" || $"{fullScreenIntent}" == "1")) { var fullScreenPendingIntent = PendingIntent.GetActivity(context, requestCode, resultIntent, PendingIntentFlags.UpdateCurrent); notificationBuilder.SetFullScreenIntent(fullScreenPendingIntent, true); notificationBuilder.SetCategory(NotificationCompat.CategoryCall); parameters[PriorityKey] = "high"; } var deleteIntent = new Intent(context, typeof(PushNotificationDeletedReceiver)); deleteIntent.PutExtras(extras); var pendingDeleteIntent = PendingIntent.GetBroadcast(context, requestCode, deleteIntent, PendingIntentFlags.UpdateCurrent); notificationBuilder.SetDeleteIntent(pendingDeleteIntent); if (Build.VERSION.SdkInt < BuildVersionCodes.O) { if (parameters.TryGetValue(PriorityKey, out var priority) && priority != null) { var priorityValue = $"{priority}"; if (!string.IsNullOrEmpty(priorityValue)) { switch (priorityValue.ToLower()) { case "max": notificationBuilder.SetPriority(NotificationCompat.PriorityMax); notificationBuilder.SetVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 }); break; case "high": notificationBuilder.SetPriority(NotificationCompat.PriorityHigh); notificationBuilder.SetVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 }); break; case "default": notificationBuilder.SetPriority(NotificationCompat.PriorityDefault); notificationBuilder.SetVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 }); break; case "low": notificationBuilder.SetPriority(NotificationCompat.PriorityLow); break; case "min": notificationBuilder.SetPriority(NotificationCompat.PriorityMin); break; default: notificationBuilder.SetPriority(NotificationCompat.PriorityDefault); notificationBuilder.SetVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 }); break; } } else { notificationBuilder.SetVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 }); } } else { notificationBuilder.SetVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 }); } try { notificationBuilder.SetSound(soundUri); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine($"{DomainTag} - Failed to set sound {ex}"); } } // Try to resolve (and apply) localized parameters ResolveLocalizedParameters(notificationBuilder, parameters); if (notificationColor != null) { notificationBuilder.SetColor(notificationColor.Value); } if (Build.VERSION.SdkInt >= BuildVersionCodes.JellyBean) { // Using BigText notification style to support long message var style = new NotificationCompat.BigTextStyle(); style.BigText(message); notificationBuilder.SetStyle(style); } var category = string.Empty; if (parameters.TryGetValue(CategoryKey, out var categoryContent)) { category = categoryContent.ToString(); } if (parameters.TryGetValue(ActionKey, out var actionContent)) { category = actionContent.ToString(); } var notificationCategories = CrossPushNotification.Current?.GetUserNotificationCategories(); if (notificationCategories != null && notificationCategories.Length > 0) { foreach (var userCat in notificationCategories) { if (userCat != null && userCat.Actions != null && userCat.Actions.Count > 0) { foreach (var action in userCat.Actions) { var aRequestCode = Guid.NewGuid().GetHashCode(); if (userCat.Category.Equals(category, StringComparison.CurrentCultureIgnoreCase)) { Intent actionIntent = null; PendingIntent pendingActionIntent = null; if (action.Type == NotificationActionType.Foreground) { actionIntent = typeof(Activity).IsAssignableFrom(PushNotificationManager.NotificationActivityType) ? new Intent(Application.Context, PushNotificationManager.NotificationActivityType) : (PushNotificationManager.DefaultNotificationActivityType == null ? context.PackageManager.GetLaunchIntentForPackage(context.PackageName) : new Intent(Application.Context, PushNotificationManager.DefaultNotificationActivityType)); if (PushNotificationManager.NotificationActivityFlags != null) { actionIntent.SetFlags(PushNotificationManager.NotificationActivityFlags.Value); } extras.PutString(ActionIdentifierKey, action.Id); actionIntent.PutExtras(extras); pendingActionIntent = PendingIntent.GetActivity(context, aRequestCode, actionIntent, PendingIntentFlags.UpdateCurrent); } else { actionIntent = new Intent(context, typeof(PushNotificationActionReceiver)); extras.PutString(ActionIdentifierKey, action.Id); actionIntent.PutExtras(extras); pendingActionIntent = PendingIntent.GetBroadcast(context, aRequestCode, actionIntent, PendingIntentFlags.UpdateCurrent); } notificationBuilder.AddAction(context.Resources.GetIdentifier(action.Icon, "drawable", Application.Context.PackageName), action.Title, pendingActionIntent); } } } } } OnBuildNotification(notificationBuilder, parameters); var notificationManager = (NotificationManager)context.GetSystemService(Context.NotificationService); notificationManager.Notify(tag, notifyId, notificationBuilder.Build()); }
private void Sfschedule_VisibleDatesChanged(object sender, VisibleDatesChangedEventArgs e) { appointmentCollection = new ScheduleAppointmentCollection(); var visibleDates = e.VisibleDates; var rand = new Java.Util.Random(); var endCalendar = Calendar.Instance; var startCalendar = Calendar.Instance; var breakStartValue = Calendar.Instance; var breakEndValue = Calendar.Instance; var break1StartValue = Calendar.Instance; var break2StartValue = Calendar.Instance; for (int i = 0; i < visibleDates.Count; i++) { if (visibleDates[i].Get(CalendarField.DayOfWeek) == 1 || visibleDates[i].Get(CalendarField.DayOfWeek) == 7) { sfschedule.DayViewSettings.NonAccessibleBlocks = null; } else { sfschedule.DayViewSettings.NonAccessibleBlocks = nonAccessibleBlocks; } if (visibleDates[i].Get(CalendarField.DayOfWeek) == 1 || visibleDates[i].Get(CalendarField.DayOfWeek) == 7) { continue; } // Periods Appointments for (int j = 0; j < startTimeCollection.Count; j++) { startCalendar.Set(visibleDates[i].Get(CalendarField.Year), visibleDates[i].Get(CalendarField.Month), visibleDates[i].Get(CalendarField.Date), startTimeCollection[j].Get(CalendarField.HourOfDay), startTimeCollection[j].Get(CalendarField.Minute), startTimeCollection[j].Get(CalendarField.Second)); endCalendar.Set(visibleDates[i].Get(CalendarField.Year), visibleDates[i].Get(CalendarField.Month), visibleDates[i].Get(CalendarField.Date), endTimeCollection[j].Get(CalendarField.HourOfDay), endTimeCollection[j].Get(CalendarField.Minute), endTimeCollection[j].Get(CalendarField.Second)); var subject = subjectCollection[rand.NextInt(subjectCollection.Count)]; appointmentCollection.Add(new ScheduleAppointment() { StartTime = (Calendar)startCalendar.Clone(), EndTime = (Calendar)endCalendar.Clone(), Subject = subject + " (" + startTimeCollection[j].Get(CalendarField.HourOfDay).ToString() + ":00 - " + endTimeCollection[j].Get(CalendarField.HourOfDay).ToString() + ":00" + ") \n\n" + GetStaff(subject), Color = GetColors(subject), }); } // Break Timings breakStartValue.Set(visibleDates[i].Get(CalendarField.Year), visibleDates[i].Get(CalendarField.Month), visibleDates[i].Get(CalendarField.Date), 11, 01, 0); breakEndValue.Set(visibleDates[i].Get(CalendarField.Year), visibleDates[i].Get(CalendarField.Month), visibleDates[i].Get(CalendarField.Date), 11, 10, 0); appointmentCollection.Add(new ScheduleAppointment() { StartTime = (Calendar)breakStartValue.Clone(), EndTime = (Calendar)breakEndValue.Clone(), Color = Color.LightGray }); break1StartValue.Set(visibleDates[i].Get(CalendarField.Year), visibleDates[i].Get(CalendarField.Month), visibleDates[i].Get(CalendarField.Date), 15, 01, 0); break2StartValue.Set(visibleDates[i].Get(CalendarField.Year), visibleDates[i].Get(CalendarField.Month), visibleDates[i].Get(CalendarField.Date), 15, 10, 0); appointmentCollection.Add(new ScheduleAppointment() { StartTime = (Calendar)break1StartValue.Clone(), EndTime = (Calendar)break2StartValue.Clone(), Color = Color.LightGray }); } sfschedule.ItemsSource = appointmentCollection; }
public void OnReceived(IDictionary <string, object> parameters) { System.Diagnostics.Debug.WriteLine($"{DomainTag} - OnReceived"); if ((parameters.TryGetValue(SilentKey, out object silent) && (silent.ToString() == "true" || silent.ToString() == "1"))) { return; } Context context = Application.Context; int notifyId = 0; string title = context.ApplicationInfo.LoadLabel(context.PackageManager); var message = string.Empty; var tag = string.Empty; if (!string.IsNullOrEmpty(FirebasePushNotificationManager.NotificationContentTextKey) && parameters.TryGetValue(FirebasePushNotificationManager.NotificationContentTextKey, out object notificationContentText)) { message = notificationContentText.ToString(); } else if (parameters.TryGetValue(AlertKey, out object alert)) { message = $"{alert}"; } else if (parameters.TryGetValue(BodyKey, out object body)) { message = $"{body}"; } else if (parameters.TryGetValue(MessageKey, out object messageContent)) { message = $"{messageContent}"; } else if (parameters.TryGetValue(SubtitleKey, out object subtitle)) { message = $"{subtitle}"; } else if (parameters.TryGetValue(TextKey, out object text)) { message = $"{text}"; } if (!string.IsNullOrEmpty(FirebasePushNotificationManager.NotificationContentTitleKey) && parameters.TryGetValue(FirebasePushNotificationManager.NotificationContentTitleKey, out object notificationContentTitle)) { title = notificationContentTitle.ToString(); } else if (parameters.TryGetValue(TitleKey, out object titleContent)) { if (!string.IsNullOrEmpty(message)) { title = $"{titleContent}"; } else { message = $"{titleContent}"; } } if (parameters.TryGetValue(IdKey, out object id)) { try { notifyId = Convert.ToInt32(id); } catch (Exception ex) { // Keep the default value of zero for the notify_id, but log the conversion problem. System.Diagnostics.Debug.WriteLine($"Failed to convert {id} to an integer {ex}"); } } if (parameters.TryGetValue(TagKey, out object tagContent)) { tag = tagContent.ToString(); } try { if (parameters.TryGetValue(SoundKey, out object sound)) { var soundName = sound.ToString(); int soundResId = context.Resources.GetIdentifier(soundName, "raw", context.PackageName); if (soundResId == 0 && soundName.IndexOf(".") != -1) { soundName = soundName.Substring(0, soundName.LastIndexOf('.')); soundResId = context.Resources.GetIdentifier(soundName, "raw", context.PackageName); } FirebasePushNotificationManager.SoundUri = new Android.Net.Uri.Builder() .Scheme(ContentResolver.SchemeAndroidResource) .Path($"{context.PackageName}/{soundResId}") .Build(); } } catch (Resources.NotFoundException ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } if (FirebasePushNotificationManager.SoundUri == null) { FirebasePushNotificationManager.SoundUri = RingtoneManager.GetDefaultUri(RingtoneType.Notification); } try { if (parameters.TryGetValue(IconKey, out object icon) && icon != null) { try { FirebasePushNotificationManager.IconResource = context.Resources.GetIdentifier(icon.ToString(), "drawable", Application.Context.PackageName); } catch (Resources.NotFoundException ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } if (FirebasePushNotificationManager.IconResource == 0) { FirebasePushNotificationManager.IconResource = context.ApplicationInfo.Icon; } else { string name = context.Resources.GetResourceName(FirebasePushNotificationManager.IconResource); if (name == null) { FirebasePushNotificationManager.IconResource = context.ApplicationInfo.Icon; } } } catch (Resources.NotFoundException ex) { FirebasePushNotificationManager.IconResource = context.ApplicationInfo.Icon; System.Diagnostics.Debug.WriteLine(ex.ToString()); } if (parameters.TryGetValue(ColorKey, out object color) && color != null) { try { FirebasePushNotificationManager.Color = Color.ParseColor(color.ToString()); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine($"{DomainTag} - Failed to parse color {ex}"); } } Intent resultIntent = typeof(Activity).IsAssignableFrom(FirebasePushNotificationManager.NotificationActivityType) ? new Intent(Application.Context, FirebasePushNotificationManager.NotificationActivityType) : (FirebasePushNotificationManager.DefaultNotificationActivityType == null ? context.PackageManager.GetLaunchIntentForPackage(context.PackageName) : new Intent(Application.Context, FirebasePushNotificationManager.DefaultNotificationActivityType)); Bundle extras = new Bundle(); foreach (var p in parameters) { extras.PutString(p.Key, p.Value.ToString()); } if (extras != null) { extras.PutInt(ActionNotificationIdKey, notifyId); extras.PutString(ActionNotificationTagKey, tag); resultIntent.PutExtras(extras); } if (FirebasePushNotificationManager.NotificationActivityFlags != null) { resultIntent.SetFlags(FirebasePushNotificationManager.NotificationActivityFlags.Value); } int requestCode = new Java.Util.Random().NextInt(); var pendingIntent = PendingIntent.GetActivity(context, requestCode, resultIntent, PendingIntentFlags.UpdateCurrent); var chanId = FirebasePushNotificationManager.DefaultNotificationChannelId; if (parameters.TryGetValue(ChannelIdKey, out object channelId) && channelId != null) { chanId = $"{channelId}"; } var notificationBuilder = new NotificationCompat.Builder(context, chanId) .SetSmallIcon(FirebasePushNotificationManager.IconResource) .SetContentTitle(title) .SetContentText(message) .SetAutoCancel(true) .SetContentIntent(pendingIntent); var deleteIntent = new Intent(context, typeof(PushNotificationDeletedReceiver)); var pendingDeleteIntent = PendingIntent.GetBroadcast(context, requestCode, deleteIntent, PendingIntentFlags.CancelCurrent); notificationBuilder.SetDeleteIntent(pendingDeleteIntent); if (Build.VERSION.SdkInt < Android.OS.BuildVersionCodes.O) { if (parameters.TryGetValue(PriorityKey, out object priority) && priority != null) { var priorityValue = $"{priority}"; if (!string.IsNullOrEmpty(priorityValue)) { switch (priorityValue.ToLower()) { case "max": notificationBuilder.SetPriority((int)Android.App.NotificationPriority.Max); notificationBuilder.SetVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 }); break; case "high": notificationBuilder.SetPriority((int)Android.App.NotificationPriority.High); notificationBuilder.SetVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 }); break; case "default": notificationBuilder.SetPriority((int)Android.App.NotificationPriority.Default); notificationBuilder.SetVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 }); break; case "low": notificationBuilder.SetPriority((int)Android.App.NotificationPriority.Low); break; case "min": notificationBuilder.SetPriority((int)Android.App.NotificationPriority.Min); break; default: notificationBuilder.SetPriority((int)Android.App.NotificationPriority.Default); notificationBuilder.SetVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 }); break; } } else { notificationBuilder.SetVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 }); } } else { notificationBuilder.SetVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 }); } try { notificationBuilder.SetSound(FirebasePushNotificationManager.SoundUri); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine($"{DomainTag} - Failed to set sound {ex}"); } } // Try to resolve (and apply) localized parameters ResolveLocalizedParameters(notificationBuilder, parameters); if (FirebasePushNotificationManager.Color != null) { notificationBuilder.SetColor(FirebasePushNotificationManager.Color.Value); } if (Build.VERSION.SdkInt >= BuildVersionCodes.JellyBean) { // Using BigText notification style to support long message var style = new NotificationCompat.BigTextStyle(); style.BigText(message); notificationBuilder.SetStyle(style); } string category = string.Empty; if (parameters.TryGetValue(CategoryKey, out object categoryContent)) { category = categoryContent.ToString(); } if (parameters.TryGetValue(ActionKey, out object actionContent)) { category = actionContent.ToString(); } var notificationCategories = CrossFirebasePushNotification.Current?.GetUserNotificationCategories(); if (notificationCategories != null && notificationCategories.Length > 0) { IntentFilter intentFilter = null; foreach (var userCat in notificationCategories) { if (userCat != null && userCat.Actions != null && userCat.Actions.Count > 0) { foreach (var action in userCat.Actions) { var aRequestCode = Guid.NewGuid().GetHashCode(); if (userCat.Category.Equals(category, StringComparison.CurrentCultureIgnoreCase)) { Intent actionIntent = null; PendingIntent pendingActionIntent = null; if (action.Type == NotificationActionType.Foreground) { actionIntent = typeof(Activity).IsAssignableFrom(FirebasePushNotificationManager.NotificationActivityType) ? new Intent(Application.Context, FirebasePushNotificationManager.NotificationActivityType) : (FirebasePushNotificationManager.DefaultNotificationActivityType == null ? context.PackageManager.GetLaunchIntentForPackage(context.PackageName) : new Intent(Application.Context, FirebasePushNotificationManager.DefaultNotificationActivityType)); if (FirebasePushNotificationManager.NotificationActivityFlags != null) { actionIntent.SetFlags(FirebasePushNotificationManager.NotificationActivityFlags.Value); } extras.PutString(ActionIdentifierKey, action.Id); actionIntent.PutExtras(extras); pendingActionIntent = PendingIntent.GetActivity(context, aRequestCode, actionIntent, PendingIntentFlags.UpdateCurrent); } else { actionIntent = new Intent(context, typeof(PushNotificationActionReceiver)); extras.PutString(ActionIdentifierKey, action.Id); actionIntent.PutExtras(extras); pendingActionIntent = PendingIntent.GetBroadcast(context, aRequestCode, actionIntent, PendingIntentFlags.UpdateCurrent); } notificationBuilder.AddAction(new NotificationCompat.Action.Builder(context.Resources.GetIdentifier(action.Icon, "drawable", Application.Context.PackageName), action.Title, pendingActionIntent).Build()); } } } } } OnBuildNotification(notificationBuilder, parameters); NotificationManager notificationManager = (NotificationManager)context.GetSystemService(Context.NotificationService); notificationManager.Notify(tag, notifyId, notificationBuilder.Build()); }
public override View GetSampleContent(Context context) { handler = new Handler(); LayoutInflater layoutInflater = LayoutInflater.From(context); view = layoutInflater.Inflate(Resource.Layout.pulltorefresh, null); Calendar cal = Calendar.GetInstance(Java.Util.TimeZone.Default); SimpleDateFormat dateformat = new SimpleDateFormat("EEEE, MMMM dd "); String strDate = dateformat.Format(cal.Time); linearLayout = (LinearLayout)view; linearLayout.SetBackgroundColor(Color.ParseColor("#039be5")); linearLayoutChild = (LinearLayout)view.FindViewById(Resource.Id.pullscroller); dataSource = GetData(); TextView textView3 = (TextView)view.FindViewById(Resource.Id.text); String s = "" + dataSource[0].Temperature + (char)0x00B0 + "/12"; SpannableString ss1 = new SpannableString(s); ss1.SetSpan(new RelativeSizeSpan(2f), 0, 4, SpanTypes.ExclusiveExclusive); textView3.SetText(ss1, TextView.BufferType.Normal); ImageView imageView = (ImageView)view.FindViewById(Resource.Id.imageview); imageView.SetImageResource(dataSource[0].Type); TextView textView6 = (TextView)view.FindViewById(Resource.Id.text1); textView6.Text = strDate; for (int i = 0; i < dataSource.Count; i++) { LinearLayout lay = (LinearLayout)layoutInflater.Inflate(Resource.Layout.pulltorefreshtemplate, null); textView = (TextView)lay.FindViewById(Resource.Id.text3); textView.Text = dataSource[i].Day; textView1 = (TextView)lay.FindViewById(Resource.Id.text4); textView1.Text = "" + (int)dataSource[i].Temperature + (char)0x00B0; imageView = (ImageView)lay.FindViewById(Resource.Id.imageview1); imageView.SetImageResource(dataSource[i].Type); if (i == 0) { textView.SetTextColor(Color.ParseColor("#fbb03b")); textView1.SetTextColor(Color.ParseColor("#fbb03b")); imageView.SetImageResource(dataSource[i].SelectedType); selectedData = dataSource[i]; selectedLayout = lay; } setOnClick(lay, i); linearLayoutChild.AddView(lay); } pull = new SfPullToRefresh(context); pull.RefreshContentThreshold = 0; pull.PullableContent = linearLayout; pull.Refreshing += (sender, e) => { if (selectedLayout != null) { run = new Java.Lang.Runnable(() => { Java.Util.Random rnd = new Java.Util.Random(); int i = rnd.NextInt(6 - 0 + 1) + 0; imageView3 = (ImageView)linearLayout.FindViewById(Resource.Id.imageview); imageView3.SetImageResource(dataSource[i].Type); degreetext = (TextView)linearLayout.FindViewById(Resource.Id.text); String s1 = "" + dataSource[i].Temperature + (char)0x00B0 + "/12"; SpannableString ss3 = new SpannableString(s1); ss3.SetSpan(new RelativeSizeSpan(2f), 0, 4, SpanTypes.ExclusiveExclusive); degreetext.SetText(ss3, TextView.BufferType.Normal); e.Refreshed = true; }); handler.PostDelayed(run, 3000); } }; return(pull); }
private ArrayList getData() { ArrayList data = new ArrayList(); int size = 10; Java.Util.Random r = new Java.Util.Random(); int month = 1; for (int i = 1; i <= size; ++i) { FinancialDataClass ohlc = new FinancialDataClass(); //ohlc.category = Integer.toString(i); ohlc.high = 150 + r.NextInt(50); ohlc.low = ohlc.high - (r.NextInt(20) + 10); ohlc.open = ohlc.low + r.NextInt((int)ohlc.high - (int)ohlc.low); ohlc.close = ohlc.low + r.NextInt((int)ohlc.high - (int)ohlc.low); Calendar date = Calendar.Instance; date.Set(Calendar.Month, month++); ohlc.date = date; data.Add(ohlc); } return data; }
public void OnReceived(IDictionary <string, object> parameters) { System.Diagnostics.Debug.WriteLine($"{DomainTag} - OnReceived"); if (parameters.TryGetValue(SilentKey, out object silent) && (silent.ToString() == "true" || silent.ToString() == "1")) { return; } int notifyId = 0; int summaryNotifyId = 786; string title = context.ApplicationInfo.LoadLabel(context.PackageManager); var message = string.Empty; var tag = string.Empty; var image = string.Empty; if (!string.IsNullOrEmpty(FirebasePushNotificationManager.NotificationContentTextKey) && parameters.TryGetValue(FirebasePushNotificationManager.NotificationContentTextKey, out object notificationContentText)) { message = notificationContentText.ToString(); } else if (parameters.TryGetValue(AlertKey, out object alert)) { message = $"{alert}"; } else if (parameters.TryGetValue(BodyKey, out object body)) { message = $"{body}"; } else if (parameters.TryGetValue(MessageKey, out object messageContent)) { message = $"{messageContent}"; } else if (parameters.TryGetValue(SubtitleKey, out object subtitle)) { message = $"{subtitle}"; } else if (parameters.TryGetValue(TextKey, out object text)) { message = $"{text}"; } if (!string.IsNullOrEmpty(FirebasePushNotificationManager.NotificationContentTitleKey) && parameters.TryGetValue(FirebasePushNotificationManager.NotificationContentTitleKey, out object notificationContentTitle)) { title = notificationContentTitle.ToString(); } else if (parameters.TryGetValue(TitleKey, out object titleContent)) { if (!string.IsNullOrEmpty(message)) { title = $"{titleContent}"; } else { message = $"{titleContent}"; } } if (parameters.TryGetValue(IdKey, out object id)) { try { notifyId = Convert.ToInt32(id); } catch (Exception ex) { // Keep the default value of zero for the notify_id, but log the conversion problem. System.Diagnostics.Debug.WriteLine($"Failed to convert {id} to an integer {ex}"); } } if (parameters.TryGetValue(TagKey, out object tagContent)) { tag = tagContent.ToString(); } if (parameters.TryGetValue(ImageKey, out object imageContent)) { image = imageContent.ToString(); } try { if (parameters.TryGetValue(IconKey, out object icon) && icon != null) { try { FirebasePushNotificationManager.IconResource = context.Resources.GetIdentifier(icon.ToString(), "drawable", Application.Context.PackageName); } catch (Resources.NotFoundException ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } if (FirebasePushNotificationManager.IconResource == 0) { FirebasePushNotificationManager.IconResource = context.ApplicationInfo.Icon; } else { string name = context.Resources.GetResourceName(FirebasePushNotificationManager.IconResource); if (name == null) { FirebasePushNotificationManager.IconResource = context.ApplicationInfo.Icon; } } } catch (Resources.NotFoundException ex) { FirebasePushNotificationManager.IconResource = context.ApplicationInfo.Icon; System.Diagnostics.Debug.WriteLine(ex.ToString()); } if (parameters.TryGetValue(ColorKey, out object color) && color != null) { try { FirebasePushNotificationManager.Color = Color.ParseColor(color.ToString()); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine($"{DomainTag} - Failed to parse color {ex}"); } } Intent resultIntent = typeof(Activity).IsAssignableFrom(FirebasePushNotificationManager.NotificationActivityType) ? new Intent(Application.Context, FirebasePushNotificationManager.NotificationActivityType) : (FirebasePushNotificationManager.DefaultNotificationActivityType == null ? context.PackageManager.GetLaunchIntentForPackage(context.PackageName) : new Intent(Application.Context, FirebasePushNotificationManager.DefaultNotificationActivityType)); Bundle extras = new Bundle(); foreach (var p in parameters) { extras.PutString(p.Key, p.Value.ToString()); } if (extras != null) { extras.PutInt(ActionNotificationIdKey, notifyId); extras.PutString(ActionNotificationTagKey, tag); resultIntent.PutExtras(extras); } if (FirebasePushNotificationManager.NotificationActivityFlags != null) { resultIntent.SetFlags(FirebasePushNotificationManager.NotificationActivityFlags.Value); } int requestCode = new Java.Util.Random().NextInt(); var notificationStr = appPreferences.GetNotifications(); List <NotificationModel> notificationList = JsonConvert.DeserializeObject <List <NotificationModel> >(notificationStr); notificationList.Add(new NotificationModel { NotifiyId = notifyId, Title = title, Message = message }); appPreferences.SaveNotification(notificationList); var pendingIntent = PendingIntent.GetActivity(context, requestCode, resultIntent, PendingIntentFlags.UpdateCurrent); var deleteIntent = new Intent(context, typeof(PushNotificationDeletedReceiver)); deleteIntent.PutExtras(extras); var pendingDeleteIntent = PendingIntent.GetBroadcast(context, requestCode, deleteIntent, PendingIntentFlags.CancelCurrent); var chanId = FirebasePushNotificationManager.DefaultNotificationChannelId; if (parameters.TryGetValue(ChannelIdKey, out object channelId) && channelId != null) { chanId = $"{channelId}"; } // Image Notification if (!string.IsNullOrEmpty(image)) { URL url = new URL(image); Bitmap bitmap = BitmapFactory.DecodeStream(url.OpenConnection().InputStream); NotificationCompat.BigPictureStyle notifyImageStyle = new NotificationCompat.BigPictureStyle(); notifyImageStyle.BigPicture(bitmap); notifyImageStyle.BigLargeIcon(bitmap); var notification = new NotificationCompat.Builder(context, chanId) .SetSmallIcon(FirebasePushNotificationManager.IconResource) .SetContentTitle(title) .SetContentText(message) .SetStyle(notifyImageStyle) .SetAutoCancel(true) .SetDefaults((int)NotificationDefaults.Lights) .SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Notification)) .SetContentIntent(pendingIntent) .SetDeleteIntent(pendingDeleteIntent); SetNotificationPriority(notification, parameters); ResolveLocalizedParameters(notification, parameters); SetNotificationAction(notification, parameters, extras); OnBuildNotification(notification, parameters); if (CrossFirebaseEssentials.Notifications.CanShowNotification) { notificationManager.Notify(104, notification.Build()); } return; } // Group Notification string groupKey = string.Format("{0}{1}", context.ApplicationInfo.LoadLabel(context.PackageManager), "Notification"); var groupList = notificationList.GroupBy(x => x.Title).ToList(); for (int i = 0; i < groupList.Count; i++) { var lstNotification = groupList[i].ToList(); NotificationCompat.InboxStyle notifyInboxStyle = new NotificationCompat.InboxStyle(); foreach (var item in lstNotification) { notifyInboxStyle.AddLine(item.Message); } var notification = new NotificationCompat.Builder(context, chanId) .SetSmallIcon(FirebasePushNotificationManager.IconResource) .SetContentTitle(groupList[i].Key) .SetContentText(lstNotification.LastOrDefault().Message) .SetStyle(notifyInboxStyle) .SetAutoCancel(true) .SetGroup(groupKey) .SetDefaults((int)NotificationDefaults.Lights) .SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Notification)) .SetContentIntent(pendingIntent) .SetDeleteIntent(pendingDeleteIntent); SetNotificationPriority(notification, parameters); ResolveLocalizedParameters(notification, parameters); SetNotificationAction(notification, parameters, extras); OnBuildNotification(notification, parameters); if (CrossFirebaseEssentials.Notifications.CanShowNotification) { notificationManager.Notify(i, notification.Build()); } } NotificationCompat.InboxStyle summaryInboxStyle = new NotificationCompat.InboxStyle() .SetSummaryText(string.Format("{0} new messages", groupList.Count)) .SetBigContentTitle(context.ApplicationInfo.LoadLabel(context.PackageManager)); foreach (var item in groupList) { var lstNotification = item.ToList(); summaryInboxStyle.AddLine(string.Format("{0} {1}", item.Key, lstNotification.LastOrDefault().Message)); } var summaryNotification = new NotificationCompat.Builder(context, chanId) .SetSmallIcon(FirebasePushNotificationManager.IconResource) .SetAutoCancel(true) .SetStyle(summaryInboxStyle) .SetGroup(groupKey) .SetGroupAlertBehavior(NotificationCompat.GroupAlertChildren) .SetGroupSummary(true) .SetDefaults((int)NotificationDefaults.Lights) .SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Notification)) .SetContentIntent(pendingIntent) .SetDeleteIntent(pendingDeleteIntent); SetNotificationPriority(summaryNotification, parameters); ResolveLocalizedParameters(summaryNotification, parameters); SetNotificationAction(summaryNotification, parameters, extras); OnBuildNotification(summaryNotification, parameters); if (CrossFirebaseEssentials.Notifications.CanShowNotification) { notificationManager.Notify(summaryNotifyId, summaryNotification.Build()); } }
/// <summary> /// Returns a randomly initialized tensor with values draft from the /// uniform distribution between minValue and maxValue. /// </summary> public static Edu.Stanford.Nlp.Neural.SimpleTensor Random(int numRows, int numCols, int numSlices, double minValue, double maxValue, Java.Util.Random rand) { Edu.Stanford.Nlp.Neural.SimpleTensor tensor = new Edu.Stanford.Nlp.Neural.SimpleTensor(numRows, numCols, numSlices); for (int i = 0; i < numSlices; ++i) { tensor.slices[i] = SimpleMatrix.Random(numRows, numCols, minValue, maxValue, rand); } return(tensor); }