public ReplyListViewForDefaultViewModel(CancellationTokenSource cts, int threadId, ListView replyListView, Action beforeLoad, Action <int, int> afterLoad, Action <int> listViewScroll)
        {
            _threadId       = threadId;
            _replyListView  = replyListView;
            _beforeLoad     = beforeLoad;
            _afterLoad      = afterLoad;
            _listViewScroll = listViewScroll;
            _ds             = new ReplyListService();

            AddToFavoritesCommand = new DelegateCommand();
            AddToFavoritesCommand.ExecuteAction = async(p) =>
            {
                await SendService.SendAddToFavoritesActionAsync(cts, threadId, _ds.GetThreadTitle(threadId));
            };

            RefreshReplyCommand = new DelegateCommand();
            RefreshReplyCommand.ExecuteAction = (p) =>
            {
                _ds.ClearReplyData(_threadId);
                LoadData(1);
            };

            LoadPrevPageDataCommand = new DelegateCommand();
            LoadPrevPageDataCommand.ExecuteAction = (p) =>
            {
                if (_startPageNo > 1)
                {
                    _ds.ClearReplyData(_threadId);
                    LoadData(_startPageNo - 1);
                }
            };

            LoadLastPageDataCommand = new DelegateCommand();
            LoadLastPageDataCommand.ExecuteAction = (p) =>
            {
                _ds.ClearReplyData(_threadId);
                LoadLastData(cts);
            };

            CopyUrlCommand = new DelegateCommand();
            CopyUrlCommand.ExecuteAction = (p) =>
            {
                string url         = $"http://www.hi-pda.com/forum/viewthread.php?tid={_threadId}";
                var    dataPackage = new DataPackage();
                dataPackage.SetText(url);
                Clipboard.SetContent(dataPackage);
            };

            OpenInBrowserCommand = new DelegateCommand();
            OpenInBrowserCommand.ExecuteAction = async(p) =>
            {
                var url = $"http://www.hi-pda.com/forum/viewthread.php?tid={_threadId}";
                Uri uri = new Uri(url, UriKind.Absolute);
                await Launcher.LaunchUriAsync(uri);
            };

            LoadData(_startPageNo);
        }
 public void LoadPrevPageData()
 {
     if (_startPageNo > 1)
     {
         _ds.ClearReplyData(_threadId);
         LoadData(_startPageNo - 1);
     }
 }
Example #3
0
        public ReplyListViewForSpecifiedPostViewModel(CancellationTokenSource cts, int postId, ListView replyListView, Action beforeLoad, Action <int, int> afterLoad, Action <int> listViewScroll)
        {
            _postId         = postId;
            _replyListView  = replyListView;
            _beforeLoad     = beforeLoad;
            _afterLoad      = afterLoad;
            _listViewScroll = listViewScroll;
            _ds             = new ReplyListService();

            AddToFavoritesCommand = new DelegateCommand();
            AddToFavoritesCommand.ExecuteAction = async(p) =>
            {
                await SendService.SendAddToFavoritesActionAsync(cts, _threadId, _ds.GetThreadTitle(_threadId));
            };

            RefreshReplyCommand = new DelegateCommand();
            RefreshReplyCommand.ExecuteAction = (p) =>
            {
                _ds.ClearReplyData(_threadId);
                LoadData(1);
            };

            LoadPrevPageDataCommand = new DelegateCommand();
            LoadPrevPageDataCommand.ExecuteAction = (p) =>
            {
                if (_startPageNo > 1)
                {
                    _ds.ClearReplyData(_threadId);
                    LoadData(_startPageNo - 1);
                }
            };

            LoadLastPageDataCommand = new DelegateCommand();
            LoadLastPageDataCommand.ExecuteAction = (p) =>
            {
                _ds.ClearReplyData(_threadId);
                LoadData(_ds.GetReplyMaxPageNo());
            };

            FirstLoad(cts);
        }