Esempio n. 1
0
        /// <summary> Connects a model with a view </summary>
        /// <returns> A task that can be awaited on, that returns the fully setup presenter </returns>
        public static async Task <T> LoadModelIntoView <T>(this Presenter <T> self, T model)
        {
            AssertV2.IsNotNull(self.targetView, "presenter.targetView");
            var name = self.GetType().Name + "_((" + model.GetType().Name + "))";

            AppFlow.TrackEvent(EventConsts.catPresenter, "Load-start:" + name, self, model);
            await self.OnLoad(model);

            AppFlow.TrackEvent(EventConsts.catPresenter, "Load-done:" + name, self, model);
            return(model);
        }
Esempio n. 2
0
        public static StopwatchV2 MethodEntered([CallerMemberName] string methodName = null, params object[] args)
        {
#if DEBUG
            args = new StackFrame(1, true).AddTo(args);
#endif
            Log.d(" --> " + methodName, args);
            if (!methodName.IsNullOrEmpty())
            {
                AppFlow.TrackEvent(AppFlow.catMethod, methodName, args);
            }
            return(AssertV2.TrackTiming(methodName));
        }
Esempio n. 3
0
        public static IEnumerable <T> GetAllOfType <T>() where T : IAppFlow
        {
            IAppFlow i = AppFlow.instance(null);

            if (i is AppFlowMultipleTrackers m)
            {
                return(m.trackers.OfType <T>());
            }
            if (i is T)
            {
                return(new T[1] {
                    (T)i
                });
            }
            return(null);
        }
Esempio n. 4
0
        public static async Task <ActionMenu.Entry> ShowActionMenu(this ViewStack self, ActionMenu menu, string menuPrefabName = "ActionMenu/ActionMenu1")
        {
            var eventName = "ShowActionMenu " + menu.menuId;
            var timing    = Log.MethodEntered(eventName);
            var menuUiGo  = self.ShowView(menuPrefabName);
            var presenter = new ActionMenu.Presenter();

            presenter.targetView = menuUiGo;
            try {
                var selectedEntry = (await presenter.LoadModelIntoView(menu)).clickedEntry;
                menuUiGo.Destroy(); // Close the menu UI again
                AppFlow.TrackEvent(EventConsts.catMethod, eventName + " done: " + selectedEntry.name);
                Log.MethodDone(timing);
                return(selectedEntry);
            }
            catch (TaskCanceledException) { // If the user canceled the action selection:
                menuUiGo.Destroy();         // Close the menu UI again
                AppFlow.TrackEvent(EventConsts.catMethod, eventName + " canceled");
                Log.MethodDone(timing);
                return(null);
            }
        }