private async void GetDrawerInfo()
        {
            var profile = await _profileDrawerControllerService.GetUserProfile();

            RunOnUiThread(() =>
            {
                if (profile != null)
                {
                    //set up profile picture, logout button and favorites if the user is logged in
                    LoggedIn = true;
                    NavView.FindViewById(Resource.Id.drawerNonAuthenticatedHeader).Visibility = ViewStates.Gone;
                    NavView.FindViewById(Resource.Id.drawerLogout).Visibility = ViewStates.Visible;
                    var authHeader        = NavView.FindViewById(Resource.Id.drawerAuthenticatedHeader);
                    authHeader.Visibility = ViewStates.Visible;
                    Picasso.With(this).Load(profile.ProfileImageUrl)
                    .Into(authHeader.FindViewById <ImageView>(Resource.Id.drawerAuthenticatedHeader_Avatar));

                    authHeader.Tag = profile.ProfileId;
                    authHeader.SetOnClickListener(this);

                    authHeader.FindViewById <TextView>(Resource.Id.drawerUser_Fullname).Text =
                        profile.ProfileFirstName + " " + profile.ProfileLastName;
                    authHeader.FindViewById <TextView>(Resource.Id.drawerUser_Handle).Text = profile.ProfileHandle;

                    //Setting up auth tab layout
                    //MainTabLayout.Visibility = ViewStates.Visible;
                    Fab.Visibility = ViewStates.Visible;
                    //TODO: Change these to real fragments later
                    if (Fragments.Count == 1)
                    {
                        Fragments.Add(NotificationFragment.NewInstance());
                        Fragments.Add(NotificationFragment.NewInstance());
                    }
                    MainFragAdapter.NotifyDataSetChanged();
                    SetTabIcons();
                }
                else
                {
                    //set up icon and hide tab layout when user is not logged in
                    LoggedIn       = false;
                    Fab.Visibility = ViewStates.Gone;
                    NavView.FindViewById(Resource.Id.drawerLogout).Visibility = ViewStates.Gone;
                    NavView.FindViewById(Resource.Id.drawerNonAuthenticatedHeader).Visibility = ViewStates.Visible;
                    NavView.FindViewById(Resource.Id.drawerAuthenticatedHeader).Visibility    = ViewStates.Gone;

                    NavView.FindViewById <ImageView>(Resource.Id.drawerNonAuthenticatedHeader_Avatar)
                    .SetImageDrawable(
                        ViewUtil.GetSVGDrawable(this, "profile_empty", 200, Resource.Color.Upward_dark_grey));


                    MainTabLayout.Visibility = ViewStates.Gone;
                }
                PreferenceManager.GetDefaultSharedPreferences(ApplicationContext).Edit()
                .PutBoolean(Constants.PREF_SIGNED_IN_KEY, LoggedIn).Commit();
            });
        }
示例#2
0
        void LoadFragment(int id)
        {
            try
            {
                Android.Support.V4.App.Fragment fragment = null;
                switch (id)
                {
                case Resource.Id.navigation_home:
                    fragment = HomeFragment.NewInstance();
                    break;

                case Resource.Id.navigation_credit:
                    fragment = CreditFragment.NewInstance();
                    break;

                case Resource.Id.navigation_debit:
                    fragment = DebitFragment.NewInstance();
                    break;

                case Resource.Id.navigation_notifications:
                    fragment = NotificationFragment.NewInstance();
                    break;
                }

                if (fragment == null)
                {
                    return;
                }

                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.content_frame, fragment)
                .Commit();
            }
            catch (Exception ex)
            {
                clsGLB.ShowMessage(ex.Message, this, MessageTitle.ERROR);
            }
        }