Ejemplo n.º 1
0
        private void AddHooks(object obj)
        {
            if (navInstance == null)
            {
                navInstance = Resources.FindObjectsOfTypeAll <SettingsNavigationController>().First();
            }
            Action <FinishAction> del = null;

            needsInit.Add(obj as CustomSetting);
            del = delegate(FinishAction finishAction)
            {
                try
                {
                    if (obj is CustomSetting)
                    {
                        CustomSetting customSetting = (obj as CustomSetting);
                        if (finishAction == FinishAction.Apply || finishAction == FinishAction.Ok)
                        {
                            customSetting.ApplySettings();
                        }
                        if (finishAction == FinishAction.Cancel)
                        {
                            customSetting.CancelSettings();
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"[SettingsUI] Crash when trying to apply or cancel settings UI! Exception: {ex.ToString()}");
                }
                navInstance.didFinishEvent -= del;
            };
            navInstance.didFinishEvent += del;
        }
Ejemplo n.º 2
0
        private void AddHooks(object obj)
        {
            if (navInstance == null)
            {
                navInstance = Resources.FindObjectsOfTypeAll <SettingsNavigationController>().First();
            }
            Action <FinishAction> del = null;

            needsInit.Add(obj as CustomSetting);
            del = delegate(FinishAction finishAction){
                if (obj is CustomSetting)
                {
                    CustomSetting customSetting = (obj as CustomSetting);
                    if (finishAction == FinishAction.Apply || finishAction == FinishAction.Ok)
                    {
                        customSetting.ApplySettings();
                    }
                    if (finishAction == FinishAction.Cancel)
                    {
                        customSetting.CancelSettings();
                    }
                    navInstance.didFinishEvent -= del;
                }
            };
            navInstance.didFinishEvent += del;
        }
Ejemplo n.º 3
0
        private void AddHooks(object obj)
        {
            if (navInstance == null)
            {
                navInstance = Resources.FindObjectsOfTypeAll <SettingsNavigationController>().First();
            }
            Action <FinishAction> del = null;

            needsInit.Add(obj as CustomSetting);
            del = delegate(FinishAction finishAction)
            {
                try
                {
                    if (obj is CustomSetting)
                    {
                        CustomSetting customSetting = (obj as CustomSetting);

                        // Only call our apply/cancel callbacks if the setting was properly initialized
                        if (customSetting.IsInitialized)
                        {
                            switch (finishAction)
                            {
                            case FinishAction.Apply:
                            case FinishAction.Ok:
                                customSetting.ApplySettings();
                                break;

                            case FinishAction.Cancel:
                                customSetting.CancelSettings();
                                break;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Plugin.Log(ex.ToString(), IPA.Logging.Logger.Level.Error);
                }
                if (finishAction != FinishAction.Cancel)
                {
                    navInstance.didFinishEvent -= del;
                }
            };
            navInstance.didFinishEvent += del;
        }