예제 #1
0
        protected override async void OnResume()
        {
            base.OnResume();

            if (Presenter != null && Settings.IsUserAuthenticated)
            {
                if (Intent.GetBooleanExtra(DisplayNotificationsIntentKey, false))
                {
                    Intent.RemoveExtra(DisplayNotificationsIntentKey);
                    AniListNotificationsDialog.Create(this, Presenter.GetNotificationsEnumerable(),
                                                      _unreadNotificationCount, () => SetNotificationCount(0));
                }
                else
                {
                    await Presenter.GetUserNotificationCount();
                }
            }

            if (Settings.EnableNotificationService && Settings.IsUserAuthenticated)
            {
                AniDroidJobManager.EnableAniListNotificationJob(this);
            }
            else
            {
                AniDroidJobManager.DisableAniListNotificationJob(this);
            }
        }
예제 #2
0
        private void SetupNavigation()
        {
            var navHeader = _navigationView.GetHeaderView(0);

            _notificationImageView = navHeader.FindViewById <BadgeImageView>(Resource.Id.Navigation_NotificationIcon);

            var userNameViewContainer = navHeader.FindViewById <LinearLayout>(Resource.Id.Navigation_UserNameContainer);
            var userNameView          = navHeader.FindViewById <TextView>(Resource.Id.Navigation_UserName);

            if (!Settings.IsUserAuthenticated)
            {
                navHeader.FindViewById(Resource.Id.Navigation_NotificationIcon).Visibility = ViewStates.Gone;

                userNameViewContainer.Click += (sender, args) =>
                {
                    _navClosedAction = () =>
                    {
                        LoginActivity.StartActivity(this);
                    };
                    _navigationDrawer.CloseDrawer(GravityCompat.Start);
                };
            }
            else
            {
                var user = Settings.LoggedInUser;

                userNameView.Text            = user?.Name ?? "User Error";
                userNameViewContainer.Click += (sender, args) =>
                {
                    _navClosedAction = () =>
                                       AniListNotificationsDialog.Create(this, Presenter.GetNotificationsEnumerable(),
                                                                         _unreadNotificationCount, () => SetNotificationCount(0));
                    _navigationDrawer.CloseDrawer(GravityCompat.Start);
                };

                if (!string.IsNullOrWhiteSpace(user?.Avatar?.Large))
                {
                    var profileImageView = navHeader.FindViewById <ImageView>(Resource.Id.Navigation_ProfileImage);
                    profileImageView.Visibility = ViewStates.Visible;
                    ImageLoader.LoadImage(profileImageView, user.Avatar.Large);
                    profileImageView.Click += (sender, args) =>
                    {
                        _navClosedAction = () => UserActivity.StartActivity(this, user.Id);
                        _navigationDrawer.CloseDrawer(GravityCompat.Start);
                    };
                }

                if (!string.IsNullOrWhiteSpace(user?.BannerImage))
                {
                    var bannerView = navHeader.FindViewById <ImageView>(Resource.Id.Navigation_ProfileBannerImage);
                    bannerView.Visibility = ViewStates.Visible;
                    ImageLoader.LoadImage(bannerView, user.BannerImage);
                }
            }

            _navigationView.SetNavigationItemSelectedListener(this);
            _navigationDrawer.DrawerClosed += OnDrawerClosed;
        }