FollowUser() static private méthode

static private FollowUser ( TraktUser user ) : void
user TraktPlugin.TraktAPI.DataStructures.TraktUser
Résultat void
Exemple #1
0
        protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType)
        {
            // wait for any background action to finish
            if (GUIBackgroundTask.Instance.IsBusy)
            {
                return;
            }

            switch (controlId)
            {
            // Facade
            case (50):
                if (actionType == Action.ActionType.ACTION_SELECT_ITEM)
                {
                    var selectedUser = Facade.SelectedListItem.TVTag as TraktUserSummary;
                    if (selectedUser == null)
                    {
                        break;
                    }

                    if (!selectedUser.IsPrivate)
                    {
                        GUIUserProfile.CurrentUser = selectedUser.Username;
                        GUIWindowManager.ActivateWindow((int)TraktGUIWindows.UserProfile);
                    }
                    else
                    {
                        if (GUIUtils.ShowYesNoDialog(Translation.Network, string.Format(Translation.SendFollowRequest, selectedUser.Username), true))
                        {
                            GUINetwork.FollowUser(selectedUser);
                            GUINetwork.ClearCache();
                        }
                    }
                }
                break;

            // Layout Button
            case (2):
                CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex);
                break;

            default:
                break;
            }
            base.OnClicked(controlId, control, actionType);
        }
Exemple #2
0
        protected override void OnShowContextMenu()
        {
            if (GUIBackgroundTask.Instance.IsBusy)
            {
                return;
            }

            var selectedItem = this.Facade.SelectedListItem;

            if (selectedItem == null)
            {
                return;
            }

            var selectedUser = selectedItem.TVTag as TraktUserSummary;

            if (selectedUser == null)
            {
                return;
            }

            var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }

            dlg.Reset();
            dlg.SetHeading(GUIUtils.PluginName());

            GUIListItem listItem = null;

            // Follow User
            // Only show menu item if user has an account as this is an unprotected area.
            if (!string.IsNullOrEmpty(TraktSettings.UserAccessToken) && !((selectedItem as GUIUserListItem).IsFollowed))
            {
                listItem = new GUIListItem(Translation.FollowUser);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.FollowUser;
            }

            // User Profile
            if (!selectedUser.IsPrivate)
            {
                listItem = new GUIListItem(Translation.UserProfile);
                dlg.Add(listItem);
                listItem.ItemId = (int)ContextMenuItem.UserProfile;
            }

            // Change Layout
            listItem = new GUIListItem(Translation.ChangeLayout);
            dlg.Add(listItem);
            listItem.ItemId = (int)ContextMenuItem.ChangeLayout;

            // Show Context Menu
            dlg.DoModal(GUIWindowManager.ActiveWindow);
            if (dlg.SelectedId < 0)
            {
                return;
            }

            switch (dlg.SelectedId)
            {
            case ((int)ContextMenuItem.FollowUser):
                if (GUIUtils.ShowYesNoDialog(Translation.Network, string.Format(Translation.SendFollowRequest, selectedItem.Label), true))
                {
                    GUINetwork.FollowUser(selectedUser);
                    GUINetwork.ClearCache();
                    (selectedItem as GUIUserListItem).IsFollowed = true;
                }
                break;

            case ((int)ContextMenuItem.UserProfile):
                GUIUserProfile.CurrentUser = selectedUser.Username;
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.UserProfile);
                break;

            case ((int)ContextMenuItem.ChangeLayout):
                CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex);
                break;
            }

            base.OnShowContextMenu();
        }