コード例 #1
0
        public async void GetNotifications()
        {
            try
            {
                if (FragmentBottomNavigator.Models != null)
                {
                    var(countNotifications, countMessages) = await ApiRequest.GetCountNotifications(this).ConfigureAwait(false);

                    NavigationTabBar.Model tabNotifications = FragmentBottomNavigator.Models.First(a => a.Title == GetText(Resource.String.Lbl_Notifications));
                    NavigationTabBar.Model tabMessages      = FragmentBottomNavigator.Models.First(a => a.Title == GetText(Resource.String.Lbl_messages));
                    if (tabNotifications != null && countNotifications != 0 && countNotifications != CountNotificationsStatic)
                    {
                        RunOnUiThread(() =>
                        {
                            try
                            {
                                CountNotificationsStatic    = countNotifications;
                                tabNotifications.BadgeTitle = countNotifications.ToString();
                                tabNotifications.UpdateBadgeTitle(countNotifications.ToString());
                                tabNotifications.ShowBadge();
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(e);
                            }
                        });
                    }

                    if (tabMessages != null && countMessages != 0 && countMessages != CountMessagesStatic)
                    {
                        RunOnUiThread(() =>
                        {
                            try
                            {
                                CountMessagesStatic    = countMessages;
                                tabMessages.BadgeTitle = countMessages.ToString();
                                tabMessages.UpdateBadgeTitle(countMessages.ToString());
                                tabMessages.ShowBadge();
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(e);
                            }
                        });
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
コード例 #2
0
        private void NavigationTabBarOnStartTabSelected(object sender, NavigationTabBar.StartTabSelectedEventArgs e)
        {
            try
            {
                switch (e.P1)
                {
                case 0:
                    PageNumber = 0;
                    ShowFragment0();
                    Context?.TracksCounter?.CheckTracksCounter();
                    break;

                case 1:
                    if (AppSettings.ShowTrending)
                    {
                        PageNumber = 1;
                        ShowFragment1();
                        Context?.TracksCounter?.CheckTracksCounter();
                        AdsGoogle.Ad_Interstitial(Context);
                    }
                    else
                    {
                        PageNumber = 2;
                        NavigationTabBar.Model tabNotifications = Models.FirstOrDefault(a => a.Title == Context.GetText(Resource.String.Lbl_Notifications));
                        tabNotifications?.HideBadge();
                        ShowFragment2();
                        Context?.TracksCounter?.CheckTracksCounter();
                        AdsGoogle.Ad_RewardedVideo(Context);
                    }

                    break;

                case 2:
                    PageNumber = 2;
                    if (AppSettings.ShowTrending)
                    {
                        NavigationTabBar.Model tabNotifications = Models.FirstOrDefault(a => a.Title == Context.GetText(Resource.String.Lbl_Notifications));
                        tabNotifications?.HideBadge();
                        ShowFragment2();
                        Context?.TracksCounter?.CheckTracksCounter();
                        AdsGoogle.Ad_Interstitial(Context);
                    }
                    else
                    {
                        PageNumber = 3;
                        NavigationTabBar.Model tabMessages = Models.FirstOrDefault(a => a.Title == Context.GetText(Resource.String.Lbl_messages));
                        tabMessages?.HideBadge();
                        Context.ShowChat();
                    }

                    break;

                case 3:
                    if (AppSettings.ShowTrending)
                    {
                        PageNumber = 3;
                        NavigationTabBar.Model tabMessages = Models.FirstOrDefault(a => a.Title == Context.GetText(Resource.String.Lbl_messages));
                        tabMessages?.HideBadge();
                        Context.ShowChat();
                    }
                    else
                    {
                        PageNumber = 4;
                        ShowFragment4();
                    }
                    break;

                case 4:
                    PageNumber = 4;
                    ShowFragment4();
                    break;

                default:
                    PageNumber = 0;
                    ShowFragment0();
                    break;
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }