Exemplo n.º 1
0
        public override void OnCreate()
        {
            base.OnCreate();

            //  Register
            RegisterActivityLifecycleCallbacks(this);

            //  Restore settings from store
            SettingsStore.Load();

            //  Setup proxy for communication
            SetupProxy();

            //  Setup notifications manager
            SetupNotificationsManager();
        }
Exemplo n.º 2
0
        protected void SetupProxy()
        {
            //
            var proxy = ProxyFactory.GetProxyInstace();

            proxy.OnUserUpdated += (s, authInfo) =>
            {
                AuthenticationManager.CurrentSession = authInfo;
            };

            proxy.OnRefreshToken += (s, authInfo) =>
            {
                AuthenticationManager.CurrentSession = authInfo;
            };

            proxy.OnLogin += async(s, authInfo) =>
            {
                //  Set current session
                AuthenticationManager.CurrentSession = authInfo;

                //  Load user preferences
                await UserPreferences.Load();
            };

            proxy.OnSignOut += (s, authInfo) =>
            {
                //  Destroy user authentication session
                AuthenticationManager.Destroy();

                //  Clear settings store
                SettingsStore.Clear();

                //
                if (CurrentActivity != null)
                {
                    //  Finish current activity
                    CurrentActivity.Finish();
                }

                //  Start the activity
                Intent intent = new Intent(this, typeof(LoginActivity));
                intent.SetFlags(ActivityFlags.ClearTask | ActivityFlags.SingleTop | ActivityFlags.NewTask);
                StartActivity(intent);
            };
        }
Exemplo n.º 3
0
 public static T Get <T>(Type pageType) where T : class
 {
     return(SettingsStore.GetAs <T>(pageType.ToString()));
 }
Exemplo n.º 4
0
 public static void ClearData(Type pageType)
 {
     SettingsStore.Remove(pageType.ToString());
 }
Exemplo n.º 5
0
 public static bool HasData(Type pageType)
 {
     return(SettingsStore.Contains(pageType.ToString()));
 }
Exemplo n.º 6
0
 public static void Destroy()
 {
     SettingsStore.Remove(AuthSettingKey);
 }
Exemplo n.º 7
0
 public void OnActivityPaused(Activity activity)
 {
     //  Save all changes before leaving
     SettingsStore.Save();
 }