示例#1
0
        ///// <summary>
        ///// 手势结束
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="e"></param>
        //private void GestureListener_GestureCompleted(object sender, Microsoft.Phone.Controls.GestureEventArgs e)
        //{
        //    if (isVerticalDrag || AppSetting.HightDragSensitivity)
        //    {
        //        var scrollviewer = AppSetting.FindChildOfType<ScrollViewer>(FanListBox);
        //        if (scrollviewer == null)
        //        {
        //            return;
        //        }
        //        //到底部
        //        if (Math.Abs(scrollviewer.VerticalOffset - scrollviewer.ScrollableHeight) < 2)
        //        {
        //            GetNextPage();
        //        }
        //        //顶部
        //        else if (scrollviewer.VerticalOffset < 0.000001)
        //        {
        //            GetLastest();
        //        }
        //    }
        //}

        ///// <summary>
        ///// 手势开始
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="e"></param>
        //private void GestureListener_GestureBegin(object sender, Microsoft.Phone.Controls.GestureEventArgs e)
        //{
        //    while (TouchPanel.IsGestureAvailable)
        //    {
        //        GestureSample gs = TouchPanel.ReadGesture();
        //        if (gs.GestureType == GestureType.VerticalDrag)
        //        {
        //            isVerticalDrag = true;
        //        }
        //    }
        //}

        #endregion 操作事件

        #region 公共方法

        /// <summary>
        /// 初始化控件,首页和提及调用此方法
        /// </summary>
        /// <param name="beforeLoading"></param>
        /// <param name="afterCallback"></param>
        public void Init(Action beforeLoading = null, Action <object> afterCallback = null)
        {
            if (_statusApi == null)
            {
                _statusApi = new Statuses(OauthHelper.OAuth());
            }

            if (IsInited)
            {
                return;
            }

            if (beforeLoading != null)
            {
                BeforeLoadingCallback = beforeLoading;
                beforeLoading();
            }

            if (afterCallback != null)
            {
                AfterLoadedCallback = afterCallback;
            }

            PollType = EPollType.Default;

            IsPolling = true;

            switch (Timeline)
            {
            case ETimeline.Home:
                _statusApi.GetHomeTimeLine(GetTimelineEnd, null, null, null, AppSetting.PageCount, 0, "default");
                break;

            case ETimeline.Reply:
                _statusApi.GetReplies(GetTimelineEnd, null, null, AppSetting.PageCount, 0, "default");
                break;

            case ETimeline.Public:
                _statusApi.GetPublicTimeline(GetTimelineEnd, AppSetting.PageCount, null, null, "default");
                break;
            }
        }