// 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); }
/// <summary> /// Its not strictly necessary to use this method - _usually_ invoking /// get with a Context gives us a path to retrieve the Application and /// initialise, but sometimes(e.g. in test harness) the ApplicationContext /// is != the Application, and the docs make no guarantees. /// </summary> /// <param name="application">application</param> /// <returns>return an initialised Foreground instance</returns> public static Foreground Init(Application application) { if (instance == null) { instance = new Foreground(); application.RegisterActivityLifecycleCallbacks(instance); } return(instance); }
/// <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; }