Exemplo n.º 1
0
 public PursuitPage()
 {
     InitializeComponent();
     xTapNotify.IsChecked = PursuitUtils.JudgePursuit();
     this.Loaded         += new RoutedEventHandler(PursuitPage_Loaded);
     InitPrusuitInfos();
 }
Exemplo n.º 2
0
        /// <summary>
        /// 递归操作所有追剧
        /// </summary>
        /// <param name="pursuit"></param>
        /// <param name="callBack"></param>
        private void OperatePursuit(int index, PursuitInfo pursuit, bool isSub, bool isDeleted, Action <bool> callBack)
        {
            var channelId = pursuit.ChannelId;

            PursuitUtils.PursuitChannel(channelId, isSub, (o, ee) =>
            {
                Dispatcher.BeginInvoke(() =>
                {
                    if (ee.IsSucess)
                    {
                        if (isDeleted)
                        {
                            PursuitViewModel.Instance.RemoveEntity(pursuit);
                            if (xPursuitListBox.Items.Count > 0)
                            {
                                var p = xPursuitListBox.Items[0] as PursuitInfo;
                                OperatePursuit(0, p, isSub, isDeleted, callBack);
                            }
                            else
                            {
                                callBack(true);
                            }
                        }
                        else
                        {
                            index++;
                            if (index < xPursuitListBox.Items.Count)
                            {
                                var p = xPursuitListBox.Items[index] as PursuitInfo;
                                OperatePursuit(index, p, isSub, isDeleted, callBack);
                            }
                            else
                            {
                                callBack(true);
                            }
                        }
                    }
                    else
                    {
                        callBack(false);
                    }
                });
            });
        }
Exemplo n.º 3
0
        /// <summary>
        /// 打开追剧
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void xTapNotify_Checked(object sender, RoutedEventArgs e)
        {
            if (!_operateCheck)
            {
                return;
            }
            var isInit = string.IsNullOrEmpty(
                Utils.GetIOSData(PursuitUtils.HttpNotifyChannelName, string.Empty)) ? false : true;

            if (!isInit)
            {
                PursuitUtils.InitHttpNotify();
            }
            if (PursuitViewModel.Instance.DataInfos.Count > 0)
            {
                Utils.SetIOSData(PursuitUtils.ISHttpNotifyName, "1");
                xLoadingWait.Visibility = Visibility.Visible;
                OperatePursuit(0, PursuitViewModel.Instance.DataInfos[0], true, false, result =>
                {
                    xLoadingWait.Visibility = Visibility.Collapsed;
                    var response            = string.Empty;
                    if (result)
                    {
                        Utils.SetIOSData(PursuitUtils.ISHttpNotifyName, "1");
                        response = "打开追剧完成";
                    }
                    else
                    {
                        Utils.SetIOSData(PursuitUtils.ISHttpNotifyName, "0");
                        _operateCheck        = false;
                        xTapNotify.IsChecked = false;
                        _operateCheck        = true;
                        response             = "打开追剧未完成,请检查网络";
                    }
                    xPopDialog.ContentText  = response;
                    xPopDialog.IsShowEnable = true;
                });
            }
            else
            {
                Utils.SetIOSData(PursuitUtils.ISHttpNotifyName, "1");
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 删除追剧
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PursuitItem_PursuitDeleteEvent(object sender, RoutedEventArgs e)
        {
            var pursuit = sender as PursuitItem;

            if (pursuit != null)
            {
                var channelId = pursuit.ChannelId;
                xLoadingWait.Visibility = Visibility.Visible;
                PursuitUtils.PursuitChannel(channelId, false, (o, ee) =>
                {
                    var response = ee.IsSucess ? "删除成功" : "删除未成功,请检查网络";
                    Dispatcher.BeginInvoke(() => {
                        if (ee.IsSucess)
                        {
                            PursuitViewModel.Instance.RemoveByChannelId(channelId);
                        }
                        xLoadingWait.Visibility = Visibility.Collapsed;
                        xPopDialog.ContentText  = response;
                        xPopDialog.IsShowEnable = true;
                    });
                });
            }
        }