Beispiel #1
0
        // PUBLIC BUILDER METHODS

        /// <summary>
        /// show fps meter, this regisers the frame callback that
        /// collects the fps info and pushes it to the ui
        /// </summary>
        /// <param name="context">Context.</param>
        public void Show(Context context)
        {
            if (OverlayPermRequest(context))
            {
                //once permission is granted then you must call show() again
                return;
            }

            //are we running?  if so, call tinyCoach.show() and return
            if (tinyCoach != null)
            {
                tinyCoach.Show();
                return;
            }

            // set device's frame rate info into the config
            SetFrameRate(context);

            // create the presenter that updates the view
            tinyCoach = new TinyCoach((Application)context.ApplicationContext, fpsConfig);

            // create our choreographer callback and register it
            fpsFrameCallback = new FpsFrameCallback(fpsConfig, tinyCoach);
            Choreographer.Instance.PostFrameCallback(fpsFrameCallback);

            //set activity background/foreground listener
            Foreground.Init((Application)context.ApplicationContext).AddListener(foregroundListener);
        }
Beispiel #2
0
        /// <summary>
        /// stops the frame callback and foreground listener
        /// nulls out static variables
        /// called from FPSLibrary in a static context
        /// </summary>
        /// <param name="context">Context.</param>
        internal static void Hide(Context context)
        {
            // tell callback to stop registering itself
            fpsFrameCallback.Enabled = false;

            Foreground.SharedInstance(context).RemoveListener(foregroundListener);
            // remove the view from the window
            tinyCoach.Destroy();

            // null it all out
            tinyCoach        = null;
            fpsFrameCallback = null;
            fpsConfig        = null;
        }
Beispiel #3
0
 public FpsFrameCallback(FpsConfig fpsConfig, TinyCoach tinyCoach)
 {
     this.fpsConfig = fpsConfig;
     this.tinyCoach = tinyCoach;
     dataSet        = new List <long>();
 }