Example #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            //preferenceHandler = new PreferenceHandler();
            var menuController = (MyMenuController)Storyboard.InstantiateViewController("MyMenuController");

            // create a slideout navigation controller with the top navigation controller and the menu view controller
            NavController = new NavController();
            Boolean     IsLogged   = PreferenceHandler.IsLoggedIn();
            UserDetails userDetail = PreferenceHandler.GetUserDetails();

            if (string.IsNullOrEmpty(PreferenceHandler.GetDomainKey()))
            {
                var ConfigurationController = Storyboard.InstantiateViewController("ConfigurationController") as ConfigurationController;
                NavController.PushViewController(ConfigurationController, true);
            }
            else
            {
                InvokeApi.SetDomainUrl(PreferenceHandler.GetDomainKey());
                if (string.IsNullOrEmpty(PreferenceHandler.GetConfig()))
                {
                    var ConfigurationController = Storyboard.InstantiateViewController("ConfigurationController") as ConfigurationController;
                    NavController.PushViewController(ConfigurationController, true);
                }
                else
                {
                    var config = JsonConvert.DeserializeObject <B2CConfiguration>(PreferenceHandler.GetConfig());
                    B2CConfigManager.GetInstance().Initialize(config);
                    if (IsLogged)
                    {
                        if (userDetail.RoleId == 2)
                        {
                            var FeedbackViewController = Storyboard.InstantiateViewController("FeedbackViewController") as FeedbackViewController;
                            NavController.PushViewController(FeedbackViewController, false);
                        }
                        else
                        {
                            var MapViewController = (MapViewController)Storyboard.InstantiateViewController("MapViewController");
                            NavController.PushViewController(MapViewController, false);
                        }
                    }
                    else
                    {
                        var ViewController = (ViewController)Storyboard.InstantiateViewController("ViewController");
                        NavController.PushViewController(ViewController, false);
                    }
                }
            }
            SidebarController                = new SidebarNavigation.SidebarController(this, NavController, menuController);
            SidebarController.MenuWidth      = (IsLogged ? 250 : 0);
            SidebarController.ReopenOnRotate = false;
            SidebarController.MenuLocation   = SidebarNavigation.MenuLocations.Left;
        }
Example #2
0
        protected override void OnResume()
        {
            base.OnResume();

            Task startupWork = new Task(() =>
            {
                Log.Debug(TAG, "Performing some startup work that takes a bit of time.");
                Task.Delay(3000);  // Simulate a bit of startup work.
                Log.Debug(TAG, "Working in the background - important stuff.");
            });

            startupWork.ContinueWith(async t =>
            {
                Log.Debug(TAG, "Work is finished.");


                if (string.IsNullOrEmpty(PreferenceHandler.GetDomainKey()))
                {
                    StartActivity(new Intent(Application.Context, typeof(ConfigActivity)));
                    Finish();
                }
                else
                {
                    InvokeApi.SetDomainUrl(PreferenceHandler.GetDomainKey());
                    if (string.IsNullOrEmpty(PreferenceHandler.GetConfig()))
                    {
                        StartActivity(new Intent(Application.Context, typeof(ConfigActivity)));
                        Finish();
                    }
                    else
                    {
                        var config = JsonConvert.DeserializeObject <B2CConfiguration>(PreferenceHandler.GetConfig());
                        B2CConfigManager.GetInstance().Initialize(config);
                        if (PreferenceHandler.IsLoggedIn())
                        {
                            await Utils.Utils.RefreshToken(this);
                            Intent intent = new Intent(Application.Context, typeof(AdminDashboardActivity));
                            intent.PutExtra(MainActivity.KEY_USER_ROLE, (int)Constants.USER_ROLE.ADMIN);
                            StartActivity(intent);
                            Finish();
                        }
                        else
                        {
                            StartActivity(new Intent(Application.Context, typeof(LoginActivity)));
                            Finish();
                        }
                    }
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());

            startupWork.Start();
        }