コード例 #1
0
        private bool GetRandomFantasy()
        {
            bool didGet = false;

            try
            {
                if (_notificationBody != null)
                {
                    if (_notificationImage != null)
                    {
                        ApplyRelevantImageResource(ConstantsAndTypes.NotificationCategories.Fantasy);
                    }
                    else
                    {
                        Log.Error(TAG, "GetRandomFantasy");
                    }
                    if (_notificationText != null)
                    {
                        if (GlobalData.StructuredPlanFantasies != null)
                        {
                            if (GlobalData.StructuredPlanFantasies.Count > 0)
                            {
                                Random random = new Random();
                                var    index  = random.Next(GlobalData.StructuredPlanFantasies.Count);
                                var    fanta  = GlobalData.StructuredPlanFantasies[index];
                                _notificationText.Text = _activity.GetString(Resource.String.MainNotHelpFantasyAbout) + " " + fanta.OfWhat.Trim() + "\n" + _activity.GetString(Resource.String.MainNotHelpTryTo) + " " + StringHelper.ActionTypeForConstant(fanta.Action) + " " + _activity.GetString(Resource.String.WordOfLabel) + " " + fanta.ActionOf.Trim();
                                didGet = true;
                            }
                        }
                    }
                    else
                    {
                        Log.Error(TAG, "GetRandomFantasy");
                    }
                }
                else
                {
                    Log.Error(TAG, "GetRandomFantasy");
                }
            }
            catch (Exception e)
            {
                Log.Error(TAG, "GetRandomFantasy");
                if (GlobalData.ShowErrorDialog)
                {
                    ErrorDisplay.ShowErrorAlert(_activity, e, _activity.GetString(Resource.String.ErrorGetRandomFantasy), "MainNotificationHelper.GetRandomFantasy");
                }
            }

            return(didGet);
        }
コード例 #2
0
        private bool GetRandomRelationship()
        {
            bool didGet = false;

            try
            {
                if (_notificationBody != null)
                {
                    if (_notificationImage != null)
                    {
                        ApplyRelevantImageResource(ConstantsAndTypes.NotificationCategories.Relationships);
                    }
                    else
                    {
                        Log.Error(TAG, "GetRandomRelationship");
                    }
                    if (_notificationText != null)
                    {
                        if (GlobalData.StructuredPlanRelationships != null)
                        {
                            if (GlobalData.StructuredPlanRelationships.Count > 0)
                            {
                                Random random = new Random();
                                var    index  = random.Next(GlobalData.StructuredPlanRelationships.Count);
                                var    relat  = GlobalData.StructuredPlanRelationships[index];
                                _notificationText.Text = _activity.GetString(Resource.String.MainNotHelpRelationshipWith) + " " + relat.WithWhom.Trim() + " (" + StringHelper.RelationshipTypeForConstant(relat.Type) + ")\n" + _activity.GetString(Resource.String.MainNotHelpTryTo) + " " + StringHelper.ActionTypeForConstant(relat.Action) + " " + _activity.GetString(Resource.String.WordOfLabel) + " " + relat.ActionOf.Trim();
                                didGet = true;
                            }
                        }
                    }
                    else
                    {
                        Log.Error(TAG, "GetRandomRelationship");
                    }
                }
                else
                {
                    Log.Error(TAG, "GetRandomRelationship");
                }
            }
            catch (Exception e)
            {
                Log.Error(TAG, "GetRandomRelationship");
                if (GlobalData.ShowErrorDialog)
                {
                    ErrorDisplay.ShowErrorAlert(_activity, e, _activity.GetString(Resource.String.ErrorGetRandomRelationship), "MainNotificationHelper.GetRandomRelationship");
                }
            }

            return(didGet);
        }