示例#1
0
        /// <summary>
        /// Clear the incoming shared folders list.
        /// </summary>
        public void ClearIncomingSharedFolders()
        {
            InShares.ClearChildNodes();

            OnUiThread(() =>
            {
                OnPropertyChanged("HasInSharedFolders");
                OnPropertyChanged("NumberOfInSharedFolders");
                OnPropertyChanged("NumberOfInSharedFoldersText");
            });
        }
示例#2
0
        /// <summary>
        /// Gets the incoming shared folders and fills the list.
        /// </summary>
        public void GetIncomingSharedFolders()
        {
            // User must be online to perform this operation
            if (!IsUserOnline())
            {
                return;
            }

            // First cancel any other loading task that is busy
            CancelLoad();

            // Create the option to cancel
            CreateLoadCancelOption();

            InShares.SetProgressIndication(true);

            // Process is started so we can set the empty content template to loading already
            InShares.SetEmptyContentTemplate(true);

            MNodeList inSharesList = MegaSdk.getInShares();

            if (inSharesList == null)
            {
                OnUiThread(() =>
                {
                    new CustomMessageDialog(
                        AppMessages.AM_LoadFailed_Title,
                        AppMessages.AM_LoadInSharesFailed,
                        App.AppInformation,
                        MessageDialogButtons.Ok).ShowDialog();

                    InShares.SetEmptyContentTemplate(false);
                });

                return;
            }

            OnUiThread(() => InShares.ChildNodes.Clear());

            Task.Factory.StartNew(() =>
            {
                try
                {
                    int inSharesListSize = inSharesList.size();
                    for (int i = 0; i < inSharesListSize; i++)
                    {
                        // If the task has been cancelled, stop processing
                        if (LoadingCancelToken.IsCancellationRequested)
                        {
                            LoadingCancelToken.ThrowIfCancellationRequested();
                        }

                        MNode inSharedFolder = inSharesList.get(i);
                        if (inSharedFolder != null)
                        {
                            var _inSharedFolder = NodeService.CreateNew(this.MegaSdk, this.AppInformation,
                                                                        inSharedFolder, ContainerType.InShares, InShares.ChildNodes);

                            if (_inSharedFolder != null)
                            {
                                _inSharedFolder.DefaultImagePathData = VisualResources.FolderTypePath_shared;
                                OnUiThread(() => InShares.ChildNodes.Add(_inSharedFolder));
                            }
                        }
                    }

                    OnUiThread(() =>
                    {
                        OnPropertyChanged("HasInSharedFolders");
                        OnPropertyChanged("NumberOfInSharedFolders");
                        OnPropertyChanged("NumberOfInSharedFoldersText");
                    });
                }
                catch (OperationCanceledException)
                {
                    // Do nothing. Just exit this background process because a cancellation exception has been thrown
                }
                finally
                {
                    // Show the user that processing the childnodes is done
                    InShares.SetProgressIndication(false);

                    // Set empty content to folder instead of loading view
                    InShares.SetEmptyContentTemplate(false);
                }
            }, LoadingCancelToken, TaskCreationOptions.PreferFairness, TaskScheduler.Current);
        }